adapters-mcp

command
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 16 Imported by: 0

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

Jump to

Keyboard shortcuts

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