Skip to main content

Module mcp

Module mcp 

Source
Expand description

Model Context Protocol server (#171).

Wraps the JSON API at /v1/* as MCP tools so any MCP-speaking host (Claude Code, Cursor, Codex, etc.) can invoke Lex actions natively. Stdio transport, JSON-RPC 2.0, hand-rolled — no SDK dependency, ~250 lines.

Run with lex serve --mcp (sticks to the same State shape as the HTTP server, just speaks a different protocol on stdin/stdout instead of HTTP).

Tools shipped in v1:

  • lex_check — POST /v1/check
  • lex_publish — POST /v1/publish
  • lex_run — POST /v1/run (effect policy passes through)
  • lex_stage_get — GET /v1/stage/
  • lex_stage_attestations — GET /v1/stage//attestations

Merge endpoints + trace/diff/replay land in v2; the v1 set covers the common agent loop (check → publish → run → read attestations).

Functions§

serve_mcp
Run the MCP server. Reads JSON-RPC requests from stdin (one per line), writes responses to stdout. Stops cleanly on EOF.