Documentation
¶
Overview ¶
Package mcp serves tools to AI agents on this computer only, three ways: the Model Context Protocol's Streamable HTTP transport at Path (JSON only, no event stream and no sessions: initialize, ping, tools/list and tools/call), the same tools as a plain HTTP API under APIPath, and a skill telling an agent how to use that API at SkillPath. Every request needs the bearer token, and a Host or Origin that is not this computer is refused, against DNS rebinding.
Index ¶
Constants ¶
const ( Path = "/mcp" APIPath = "/api/v1" SkillPath = "/skill" )
Where each way in is served.
const MaxBody = 1 << 20
MaxBody is the largest request accepted.
Variables ¶
var ErrBadPort = errors.New("mcp: port must be 1 to 65535")
ErrBadPort reports a port outside 1–65535.
var Versions = []string{"2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"}
Versions are the protocol versions spoken, newest first. A client asking for another gets the newest.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
Name, Version string
// Instructions tell the agent how to use the tools.
Instructions string
// Token is the bearer token every request carries. Empty refuses all.
Token string
Tools []Tool
// Skill is the skill's SKILL.md; nil serves none.
Skill func() string
}
Handler is the endpoint.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the endpoint listening on 127.0.0.1.
type Tool ¶
type Tool struct {
Name string
Description string
// Schema is the JSON Schema of the arguments.
Schema json.RawMessage
Call func(ctx context.Context, args json.RawMessage) (string, error)
}
Tool is one tool. Call's text is the result; an error is a failed result the agent reads, not a protocol error.