Skip to content

F022: MCP Server Implementation Plan

Implement an MCP (Model Context Protocol) Server for the CSTP Decision Engine. This allows any MCP-compliant agent (Claude Desktop, OpenClaw, other AI assistants) to natively discover and use CSTP capabilities without custom client code.

  • Bridge Pattern: Create a2a/mcp_server.py that wraps the existing Dispatcher.
  • Transport: Support Standard Input/Output (stdio) for local agents and SSE (Server-Sent Events) for remote.
  • Protocol: Implement MCP v1.0.0-rc.1 spec.

The MCP server will expose CSTP methods as Tools:

CSTP Method MCP Tool Name Description
cstp.queryDecisions query_decisions Find similar past decisions using semantic search
cstp.checkGuardrails check_action Validate an intended action against safety policies
cstp.recordDecision log_decision Record a final decision to the immutable log
cstp.reviewDecision review_outcome Record the outcome of a past decision
cstp.getCalibration get_stats Get accuracy and Brier score metrics
  • Add mcp python package dependency
  • Create a2a/mcp_server.py using mcp.server.fastmcp
  • Map query_decisions tool to dispatcher.query_decisions
  • Map check_action tool to dispatcher.check_guardrails
  • Verify local stdio connection with Claude Desktop
  • Map log_decision (record)
  • Map review_outcome (review)
  • Map get_stats (calibration)
  • Add input schema validation (Pydantic models)
  • Update Dockerfile to expose MCP entrypoint
  • Add SSE (HTTP) transport support for remote agents
  • Update documentation with “How to connect via MCP”
{
"mcpServers": {
"cstp": {
"command": "docker",
"args": ["exec", "-i", "cstp", "uv", "run", "python", "-m", "a2a.mcp_server"]
}
}
}
  1. Discovery: Agent sees query_decisions and check_action in its tool list.
  2. Execution: Agent can successfully query past decisions via the tool.
  3. Safety: Guardrails are enforced exactly as they are in the JSON-RPC API.