Documentation
¶
Overview ¶
Package mcpserver serves an app's generated MCP tools over the Go MCP SDK (github.com/modelcontextprotocol/go-sdk).
1 tool is 1 RPC that the app exposes to agents: its name, its JSON Schemas, the effect that becomes its hints, and the call itself. The server puts the caller in the call's context, so that the generated permission check runs inside it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Annotations ¶
func Annotations(effect Effect) *mcp.ToolAnnotations
Annotations returns the hints of 1 effect:
read: readOnlyHint true, destructiveHint false, openWorldHint false write: readOnlyHint false, destructiveHint false, openWorldHint false outward: readOnlyHint false, destructiveHint true, openWorldHint true
An effect the package does not know gets an outward tool's hints, so that a later effect never arrives as a harmless 1.
func NewServer ¶
NewServer returns an MCP server with 1 tool for each tool of tools, and the caller of every call.
The tools are registered with the SDK's raw handler: the server validates no argument and no result, and each call passes its arguments to the tool as they arrive.
func ServeStdio ¶
func ServeStdio(ctx context.Context, server *mcp.Server, in io.ReadCloser, out io.WriteCloser) error
ServeStdio runs server on 1 standard input and 1 standard output, as an app's stdio MCP server.
The transport is newline-delimited JSON over those 2 streams, and it needs no token: the process belongs to the local user, so build the server with authz.LocalCaller, and its tools act as that user. ServeStdio returns when the stream ends or the context is cancelled.
Types ¶
type Tool ¶
type Tool struct {
// Name is the tool's name: the RPC name in snake_case.
Name string
// Description tells an agent when to call the tool.
Description string
// Effect is what the call does; it decides the tool's hints.
Effect Effect
// InputSchema is the JSON Schema of the call's arguments.
InputSchema json.RawMessage
// OutputSchema is the JSON Schema of the call's result, or nil.
OutputSchema json.RawMessage
// Call runs the call with the caller in its context, and returns the
// response. It decodes args, which are 1 JSON object in the proto3 JSON
// form of the RPC's request, and reports an error for empty or malformed
// arguments.
Call func(ctx context.Context, args json.RawMessage) (proto.Message, error)
}
Tool is 1 MCP tool of an app: 1 RPC that the app exposes to agents.