mcp

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
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

func Serve

func Serve(ctx context.Context, in io.Reader, out io.Writer, opts Options) error

Serve answers MCP requests read from in, writing replies to out, until in ends or ctx is cancelled. It returns nil when in reaches EOF, after every request already read has been answered. Requests are answered concurrently except tool calls, which run one at a time.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL