Documentation
¶
Overview ¶
Package mcp serves Spackle to AI clients over the Model Context Protocol: JSON-RPC 2.0 messages, one per line, read from one stream and written to another (the stdio transport). It offers tools and nothing else, and it never opens a listener.
The protocol layer is written by hand on the standard library because the server needs only initialize, ping, tools/list and tools/call, and a dependency would have to be justified for four methods.
The safety model is that the operator who starts the server sets every limit (which directories may be scanned, whether a model may be called, the config and its budgets) and a tool call can only choose within them.
Index ¶
Constants ¶
const ProtocolVersion = "2025-06-18"
ProtocolVersion is the newest MCP revision the server speaks. It is also the answer to a client that asks for a revision the server does not know.
Variables ¶
var ErrOptions = errors.New("invalid MCP server options")
ErrOptions marks a Serve failure caused by the options the operator gave (for example a root that is not a directory), so the CLI can report it as a usage error.
Functions ¶
Types ¶
type Check ¶
type Check struct {
Area string `json:"area"`
Name string `json:"name"`
Status string `json:"status"` // ok|missing|warn|fail
Note string `json:"note"`
}
Check is one row of the doctor tool's output.
type Options ¶
type Options struct {
// Roots are the only directories the scan tool may be pointed at. Empty
// means the working directory.
Roots []string
// Config is the operator's configuration, with flags already applied.
Config config.Config
// AllowModel lets scans call the configured model. Without it scans run
// the deterministic stages only, so a client cannot spend the operator's
// money.
AllowModel bool
// Version is reported to the client as the server version.
Version string
// Doctor runs the environment checks for the doctor tool. It is passed
// in because the checks live in the CLI package, which imports this one.
Doctor func(ctx context.Context) []Check
// Log receives status lines (stderr). Nil discards them. Standard output
// is never used for status: it carries protocol messages only.
Log io.Writer
// Scan runs a scan; nil means engine.Run. Tests inject a fake.
Scan func(ctx context.Context, opts engine.Options) (engine.Result, error)
}
Options configure the server. Everything here comes from the operator's command line and config file; nothing in it can be changed by a tool call.