mcp

package
v0.19.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Code generated by apic; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("not implemented")

ErrNotImplemented is returned by UnimplementedMCPServer methods.

Functions

func NewEngine added in v0.19.2

func NewEngine(srv MCPServerInterface, opts ...mcpx.Option) (*mcpx.Engine, error)

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, which the generated server supplies -- and later options win. Without a verifier the HTTP and WS transports fail closed with HTTP 401.

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. The ctx is the request-scoped context threaded from the MCP transport (HTTP/WS carry the auth-verifier-enriched context; STDIO passes context.Background()).

type UnimplementedMCPServer

type UnimplementedMCPServer struct{}

UnimplementedMCPServer returns ErrNotImplemented for every MCP tool.

func (UnimplementedMCPServer) Create_item

func (UnimplementedMCPServer) List_items

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL