Documentation
¶
Overview ¶
Package mcp turns the operations of the Go model into MCP tools that call the generated client: the tools type that registers them on a server of the official Go SDK, one tool definition and handler per operation, and the input type of every tool.
Index ¶
Constants ¶
const ( PartTools layout.PartID = "mcp.tools" PartInputs layout.PartID = "mcp.inputs" )
The MCP parts.
const SDKPath = "github.com/modelcontextprotocol/go-sdk/mcp"
SDKPath is the import path of the MCP SDK the tools are written for.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AssignView ¶
AssignView fills Field from the input field From.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator builds the template data of the MCP parts.
func New ¶
New returns the generator of the tools of m: one per operation the config and x-mcp keep, webhooks left out. Tool names that clash are numbered, with a note; an x-mcp name the SDK would reject is replaced with a warning, and a name some hosts reject is kept with one. A default that does not fit its schema is left out of every input, with one warning.
type GroupView ¶
type GroupView struct {
Field string
Type string
Assigns []AssignView
}
GroupView is the parameters of one location: the options field that holds them, the type of that field, and the field of each parameter with the input field it comes from.
type InputView ¶
InputView is the input of one tool: a field per parameter and one for the body, tagged with the property names of the schema.
type InputsView ¶
type InputsView struct {
Inputs []InputView
}
InputsView is the data of the inputs part: the input type of every tool.
type Options ¶
type Options struct {
Client string
Namer *naming.Namer
DefaultSkip bool
User map[string]any
Descriptions bool
}
Options are the settings of the MCP generator. Client is the client type the tools call; DefaultSkip leaves every operation out unless x-mcp turns it on; User is the config's user-context. Descriptions copies the spec's descriptions into the comments of the inputs.
type ToolView ¶
type ToolView struct {
Name string
Tool string
Description string
Schema string
Input string
Options string
IsReadOnly bool
IsIdempotent bool
HasInput bool
IsRounded bool
Groups []GroupView
QueryString *AssignView
Body *AssignView
IsStream bool
HasResult bool
Text string
File string
HasNilCheck bool
}
ToolView is one tool: its definition and its handler. Name is the operation, Tool the tool name. IsRounded says the handler decodes the arguments again, past the SDK's float64. Of the result, Text is it as text and File as a file; with neither it is structured content. HasNilCheck says the handler checks it for nil.
type ToolsView ¶
type ToolsView struct {
Client string
MCP string
JSON string
Context string
Errors string
Runtime string
MCPTool string
Strings string
HasStream bool
HasFile bool
Tools []ToolView
User map[string]any
}
ToolsView is the data of the tools part. Client is the client interface the tools call, as the file writes it; MCP, JSON, Context, Errors, Runtime, MCPTool and Strings are the names the packages are imported under. HasStream says whether a tool answers with the streaming error, HasFile whether one answers with a file.