Documentation
¶
Overview ¶
Package mcp is a minimal Model Context Protocol server over stdio: enough of the protocol (initialize, ping, tools/list, tools/call as newline-delimited JSON-RPC 2.0) for an agent to call notenv's tools, and nothing more. Hand-rolled deliberately: like internal/ui, it adds zero new supply-chain surface, and the subset it speaks is small enough to audit in one sitting.
Requests are handled sequentially in arrival order; there is no cancellation and no server-initiated traffic. Handlers' results travel as text content. The transport's stdin/stdout belong to the protocol; prompts and logging elsewhere in notenv already go to /dev/tty and stderr, so a handler can run the full app stack without corrupting the stream.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
Server serves a fixed tool set over one stdio session.
type Tool ¶
type Tool struct {
Name string
Description string
ReadOnly bool
InputSchema map[string]any
OutputSchema map[string]any
Handler func(ctx context.Context, args json.RawMessage) (any, error)
}
Tool is one callable tool: a name, the description an agent picks it by, JSON-Schema input and output declarations, and the handler. A handler error becomes a tool-level error result (isError), not a protocol error: the agent gets to read it and adapt. A non-string handler result is returned both ways the spec wants it: serialized into text content and, when an OutputSchema is declared, as structuredContent. ReadOnly renders as the readOnlyHint annotation, so clients can skip confirmation for tools that cannot change anything.