mcp/v1

The app's Model Context Protocol endpoint, so agents (a Claude connector, Claude Code, any Streamable HTTP client) can work with it. It stays at /mcp: people paste that URL, MCP versions itself in the protocol, and OAuth tokens are bound to the resource URL.

What every provider serves the same way, the contract owns:

  • The routes: /mcp, and its protected resource metadata at /.well-known/oauth-protected-resource/mcp.
  • The tools: every wire contract the app provides, one tool per operation (restore_points, bulkmail_start, ...), with an input schema from the operation's types and called through the contract, so the same superuser check, scopes and hooks apply as over HTTP; and tools extensions add with AddTool.

A provider brings the protocol, sign-in and any tools of its own (MCP adds pb_* tools over the REST API). Replace it and the contract tools stay.

A service (mcp.go).

Use

Add https://<host>/mcp to an MCP client and sign in. In Go, an extension adds a tool that isn't a contract operation, and tells agents what its tools are for:

mcpv1.AddTool(app, mcpv1.Tool{
	Name:        "notes_summarize_week",
	Description: "Summarizes this week's notes.",
	ReadOnly:    true,
	Call: func(ctx context.Context, a extkit.Auth, args json.RawMessage) (any, error) { ... },
})
mcpv1.AddInstructions(app, "Use notes_summarize_week for weekly reviews.")

mcpv1.Tools(app) lists what every provider serves.

Provide

Implement mcpv1.Endpoint (ServeMCP for requests to /mcp, Metadata for the protected resource metadata), provide it, and bind the routes once:

mcpv1.Contract.ProvideDefault(app, myServer{})
mcpv1.Bind(app)

Serve mcpv1.Tools(app) in tools/list and tools/call, calling each tool as the signed-in caller.

/mcp skips PocketBase's pbRejectUnknownToken, so the provider rejects a bad token itself: a request with an Authorization header and no signed-in caller (e.Auth is nil) gets 401 with a WWW-Authenticate: Bearer error="invalid_token" challenge, never a guest's answer.

Extensions

Extension
mcp provides (default)
wasm works with

License

MIT