Documentation
¶
Overview ¶
Package tool turns OpenAPI operations into MCP tool definitions and builds the upstream HTTP request for a tool call. One operation becomes one tool: its input schema merges the operation's parameters with the JSON body fields, and a Def remembers where each argument belongs (path, query, header, or body) so the request can be reconstructed faithfully.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRequest ¶
func BuildRequest(ctx context.Context, d Def, baseURL string, args map[string]any) (*http.Request, error)
BuildRequest turns a tool call's arguments into the upstream HTTP request for this operation, routing each argument to the path, query string, headers, or JSON body according to the Def. baseURL is the resolved API server root.
Types ¶
type Def ¶
type Def struct {
Name string
Description string
InputSchema map[string]any
// contains filtered or unexported fields
}
Def is a built MCP tool: its wire-facing name/description/schema plus the routing knowledge needed to turn arguments back into an HTTP request.
func Defs ¶
Defs builds tool definitions for every operation in the document. When readOnly is set, only safe (GET, HEAD) operations are exposed; filter, if non-empty, further narrows the set to operations it matches. Names are made unique and stable, and are assigned before filtering so a filter can match on the same name `ls` would show, regardless of what else got excluded.
type Filter ¶ added in v0.4.0
type Filter struct {
Include []string // substring or glob, matched against tool name, operationId, and path
Tags []string // exact match (case-insensitive) against an operation's tags
}
Filter narrows which operations become tools. An operation is kept if it matches any Include pattern or any Tag, so the two lists are OR'd together as one keep-set; an empty Filter keeps everything.