Documentation
¶
Overview ¶
Package main demonstrates the go-codex MCP server adapter.
This example shows the three-layer workflow applied to MCP:
- Layer 1 — Codecs: define CalcInput, CalcOutput, Item, and their codecs.
- Layer 2 — api/mcp: declare Tool, Resource, Prompt as package-level values, register with a Builder, and inspect the static MCPSpec.
- Layer 3 — adapters/mcpgo: wire handles to a mark3labs/mcp-go server with an Observer for metrics and slog for structured logging.
The Observer wired into mcpgo.Options receives one event per tool/resource/ prompt call: RecordRequest("tool", name, statusCode, latency). Codec validation failures additionally fire RecordValidationError per field, enabling per-field error counters without any metrics library dependency.
The server is started in stdio mode when SERVE=1 is set. By default the example simulates calls, prints the observer summary, and exits.
Run with: go run ./examples/adapters-mcp
Click to show internal directories.
Click to hide internal directories.