mcpv1
import mcpv1 "pocketone.dev/ext/contracts/mcp/v1"
Package mcpv1 is the mcp/v1 contract: the app's Model Context Protocol endpoint, so agents (a Claude connector, Claude Code, any Streamable HTTP client) can work with it. The endpoint stays at /mcp, the one path people paste: MCP versions itself in the protocol, and OAuth tokens are bound to the resource URL.
The contract owns what every provider serves the same way: the routes (/mcp and its protected resource metadata under /.well-known/), and the tools. Tools come from three places: every wire contract the app provides (its operations, called through the contract, so the same scope check and hooks apply), tools extensions add with AddTool, and the provider's own (ext/mcp's pb_* tools over the REST API). Swap the provider and the contract tools stay.
Source: ext/contracts/mcp/v1.
Constants
const MetadataPath = "/.well-known/oauth-protected-resource" + Path
MetadataPath is its protected resource metadata (RFC 9728); the bare well-known path answers too.
const Path = "/mcp"
Path is where the endpoint is served.
Variables
var Contract = extkit.NewContract[Endpoint]("mcp/v1", extkit.One)
Contract is mcp/v1.
Functions
AddInstructions
func AddInstructions(app core.App, text string)
AddInstructions adds a paragraph to what the server tells clients when they connect (what your tools are for).
AddTool
func AddTool(app core.App, t Tool)
AddTool adds a tool to app's MCP server (call it in Register). A second tool with the same name replaces the first.
Bind
func Bind(app core.App)
Bind serves the provider's endpoint at /mcp and its metadata on app. Providers call it in Register; it binds once.
Instructions
func Instructions(app core.App) []string
Instructions are the paragraphs extensions added.
Types
Endpoint
type Endpoint interface {
// ServeMCP answers one request to /mcp (Streamable HTTP: POST; GET and DELETE answer 405 without sessions).
ServeMCP(e *core.RequestEvent) error
// Metadata is the protected resource metadata for /mcp: where clients sign in.
Metadata(e *core.RequestEvent) map[string]any
}
Endpoint is an app's MCP server.
Tool
type Tool struct {
// Name: lowercase `<extension>_<verb>_<noun>`, unique per app.
Name string
Title string
Description string
// InputSchema is a JSON Schema object for the arguments (nil: none).
InputSchema map[string]any
ReadOnly bool
Destructive bool
// Scope is the token scope a connection limited to scopes needs to see and call it ("" for any).
Scope string
// SuperuserOnly hides it from other callers in tools/list (presentation: Call still decides).
SuperuserOnly bool
// Call runs it as a (the signed-in caller, as extkit.Auth); the result is any JSON-able value.
Call func(ctx context.Context, a extkit.Auth, args json.RawMessage) (any, error)
}
Tool is a tool an extension adds to the app's MCP server, whoever provides it.
Tools
func Tools(app core.App) []Tool
Tools are the tools every provider serves on app, by name: every provided wire contract's operations, then the ones extensions added (which win on a name clash).
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.