Documentation
¶
Overview ¶
Code generated by apic; DO NOT EDIT.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("not implemented")
ErrNotImplemented is returned by UnimplementedMCPServer methods.
Functions ¶
func NewEngine ¶ added in v0.19.2
NewEngine builds this server's MCP engine from the supplied business-logic implementation. Every knob -- tools, descriptors, server identity, per-tool rate buckets, body cap, role and ownership policy -- is owned by the returned *mcpx.Engine, so a process may host several MCP surfaces with different tenants, tool sets and policies without cross-talk (ENG-4634 / GitLab #364).
It replaces Register(srv), which pushed all of the above into process-wide mcpx state and then published three package-level handler variables (MCPHandler / MCPWSHandler / MCPSTDIOFunc) that the LAST Register call in the process won. Mount the returned engine with eng.HandleHTTP / eng.ServeWS, or run eng.ServeSTDIO(ctx) for the stdio transport.
Callers append their own mcpx.Option values -- notably mcpx.WithAuthVerifier and mcpx.WithCallerBuilder, which the generated server supplies -- and later options win. Without a verifier the HTTP and WS transports fail closed with HTTP 401; without a caller builder the engine installs no caller, so a tool sees only what the verifier's context carries.
GEN-2026-05-29-06: the rate/burst arguments to mcpx.WithToolBuckets are derived from the operator's top-level "mcp" config block (mcp.rate / mcp.burst) -- the block is bound at the config root, not under "security". When the config leaves them unset the generator emits the historic defaults (100 rps / 20 burst) so existing consumers keep working unchanged; operators who need a tighter ceiling for a sensitive MCP surface can now configure it at codegen time:
{"mcp": {"rate": 60, "burst": 60}}
func NewTools ¶
func NewTools(srv MCPServerInterface) map[string]mcpx.Tool
NewTools builds the MCP tool map backed by srv.
func ToolDescriptors ¶
func ToolDescriptors() []mcpx.ToolDescriptor
ToolDescriptors returns the MCP tools/list metadata for every generated tool: name, optional title/description, and the inputSchema (a JSON Schema object that is the union of the tool's body, path, and query parameters). NewEngine passes these to mcpx.WithToolDescriptors so tools/list advertises a spec-compliant descriptor for each tool.
Types ¶
type MCPServerInterface ¶
type MCPServerInterface interface {
Create_item(ctx context.Context, params *types.ItemCreateReq) (*types.ItemCreateResp, error)
List_items(ctx context.Context, params *types.ItemListReq) (*types.ItemListResp, error)
}
MCPServerInterface defines the business logic contract for generated MCP tools. Embed UnimplementedMCPServer and override only the tools you implement.
ctx is the request-scoped context threaded from the MCP transport, bounded by the engine's per-call timeout (SONNY-792). On HTTP and WebSocket it is the context the server's auth verifier returned -- its claims (securex.ClaimsFromContext) and the request id -- plus the verified caller: callerctx.MustCaller(ctx) (or securex.MustCaller(ctx)), the same caller a REST handler on this server would see, built by securex.CallerFromRequest from what the verifier attested, with AuthMode set to the MCP surface's scheme. On WebSocket that caller is built once, at upgrade, and shared by every call on the connection. STDIO verifies nothing: ctx derives from the ctx the host passed to Engine.ServeSTDIO (the generated Serve passes its own), and the transport never manufactures one, so a host that needs a principal on STDIO installs it there first with mcpx.ContextWithCaller. The engine's per-tool role and ownership gates evaluate this same caller (ownership: a human caller's Subject only), so a tool never runs for a principal other than the one it reads. The caller is shared and read-only; with nothing verified it is KindUnknown, with no roles and no scopes. Pass ctx to every downstream call.
type UnimplementedMCPServer ¶
type UnimplementedMCPServer struct{}
UnimplementedMCPServer returns ErrNotImplemented for every MCP tool.
func (UnimplementedMCPServer) Create_item ¶
func (UnimplementedMCPServer) Create_item(_ context.Context, _ *types.ItemCreateReq) (*types.ItemCreateResp, error)
func (UnimplementedMCPServer) List_items ¶
func (UnimplementedMCPServer) List_items(_ context.Context, _ *types.ItemListReq) (*types.ItemListResp, error)