Documentation
¶
Overview ¶
Package mcp exposes the operations of a registry that set MCP: true as MCP tools, over stdio or streamable HTTP.
A tool's name is the operation name with dots replaced by underscores, its input schema is the registry's wire schema (including apply and confirm, without cli-only inputs), and its annotations follow the effect. Every call goes through the same op.Entry.CallJSON path as HTTP, so validation, the cli-only, apply and confirm rules and authorization are identical. A failed call is an isError result whose text is {"error": {code, message, suggestions}}, plus the provider details of op.Error that are set. The call's request _meta reaches the handler as op.Request.Meta.
Index ¶
Constants ¶
const MetaCLIConfirmed = "toolkit/cli_confirmed"
MetaCLIConfirmed is the tool _meta key set to true for an operation with CLIConfirmed. It is informational: the MCP tool still needs apply and confirm.
const MetaCLIImmediate = "toolkit/cli_immediate"
MetaCLIImmediate is the tool _meta key set to true for an operation with CLIImmediate. It is informational: the MCP tool still needs apply.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
Handler serves MCP over streamable HTTP, stateless with JSON responses, so it works behind a plain reverse proxy.
func NewServer ¶
NewServer returns an MCP server with one fresh tool per MCP operation. Only the immutable schema copies are shared between servers. httpReq is the inbound HTTP request for authorizers, or nil for local transports. A nil auth means op.DenyWrites.
func ServeStdio ¶
ServeStdio serves MCP on stdin and stdout until the client disconnects or ctx is done.
func Tool ¶
Tool is the MCP tool definition of e. The output schema is set only when the output is always a JSON object, as MCP requires. Any other output, including an op.Op whose Out is any or json.RawMessage, has no output schema, and its result is the JSON text alone, without structured content.
Types ¶
type ErrorBody ¶
ErrorBody is the text payload of an isError result. Result is the operation's partial output when the error carries one (op.Error.Result).
type Options ¶
type Options struct {
// Authorizer decides whether a caller may run an operation. Nil means the
// transport default: op.AllowAll for stdio, whose caller already runs the
// binary as the user, and op.DenyWrites for HTTP.
Authorizer op.Authorizer
}
Options configures the MCP surface.