Documentation
¶
Index ¶
- Constants
- func GenerateInputSchema(paramPtrs []interface{}, bodyPtr interface{}) (json.RawMessage, map[string]ParamSource, error)
- func NewMCPHandler(router *mux.Router, config Config) http.Handler
- func PopulateMCPServer(mcpServer *mcpsdk.Server, router *mux.Router, config Config) error
- type Config
- type ParamSource
Constants ¶
const DefaultMCPPath = "/mcp"
DefaultMCPPath is the default HTTP path for the MCP server endpoint.
Variables ¶
This section is empty.
Functions ¶
func GenerateInputSchema ¶
func GenerateInputSchema(paramPtrs []interface{}, bodyPtr interface{}) (json.RawMessage, map[string]ParamSource, error)
GenerateInputSchema builds a flat JSON Schema object and a ParamSource map from the given parameter and body struct pointers. All path/query params and body fields are merged into a single flat schema, making the tool input LLM-friendly. The returned paramSourceMap tracks the origin of each property so the executor can decompose arguments back into path vars, query vars, and body fields.
func NewMCPHandler ¶
NewMCPHandler creates an http.Handler that serves the MCP protocol over Streamable HTTP transport. It lazily discovers tools from the router on first connection, similar to how OpenAPI spec generation works.
Types ¶
type Config ¶
type Config struct {
// ServerName is the name of the MCP server. Defaults to openapi.Config.DocPageTitle.
ServerName string
// ServerVersion is the version of the MCP server. Defaults to "1.0.0".
ServerVersion string
// Path is the HTTP path for the Streamable HTTP transport. Defaults to "/mcp".
Path string
// IgnoredPaths are the routes that shouldn't be exposed as MCP tools.
IgnoredPaths []string
}
Config contains the configuration for the MCP server.
var MCPConfig Config
MCPConfig is the default MCP server config. You can update all fields to change:
- ServerName: the name of the MCP server. - ServerVersion: the version of the MCP server. - Path: the HTTP path for the MCP endpoint. - IgnoredPaths: the paths that shouldn't be exposed as MCP tools.
func (Config) GetServerName ¶
GetServerName returns the configured server name, or the fallback.
func (Config) GetServerVersion ¶
GetServerVersion returns the configured server version, or "1.0.0".
type ParamSource ¶
type ParamSource struct {
Source string // "path", "query", or "body"
Field string // original field name in the source struct
}
ParamSource tracks where an MCP tool argument should be routed when executing the handler.