lietzsche;stokes

updated 2026-11-26·4 min read

Model Context Protocol (MCP) Specification

Native JSON-RPC 2.0 Model Context Protocol specification for Stokes: tool schemas, live resources, guided prompts, and IDE agent integration.

Stokes exposes a native Model Context Protocol (MCP 2024-11-05) server over stdio using JSON-RPC 2.0 framing, giving IBM Bob 2.0, Cursor, Claude Code, and Windsurf direct visibility into cross-compiler boundaries, reachability graphs, and stack buffer limits before they edit files.

  1. Agent Host Transport

    IDE host connects over stdio JSON-RPC 2.0 (or 4-byte length-prefixed binary sockets for IBM Bob 2.0 IPC).

  2. Stokes MCP Server Core

    JSON-RPC dispatcher routes requests into the Tree-sitter Invariant Analysis Engine and Autonomous Buffer Synthesizer.

  3. Tools, Resources & Guided Prompts

    Exposes inspection/synthesis tools, stokes://* live state URIs, and stokes_refactor_contract / stokes_explain_violation prompts.

Protocol Lifecycle & Connection Handshake

MCP initialize Handshake & notifications/initialized
// Client Request ->
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {
      "roots": { "listChanged": true },
      "sampling": {}
    },
    "clientInfo": { "name": "ibm-bob", "version": "2.0.0" }
  }
}

// Stokes Response <-
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "protocolVersion": "2024-11-05",
    "capabilities": { "tools": {}, "resources": {}, "prompts": {} },
    "serverInfo": { "name": "stokes-mcp", "version": "0.2.0" }
  }
}

// Client Notification ->
{
  "jsonrpc": "2.0",
  "method": "notifications/initialized",
  "params": {}
}

Exposed Tool Schemas

Tool NameRequired ArgsPurpose
stokes_auditNone (workspace_path, strict)Evaluates SQL, Python, Protobuf, and Rust boundaries; returns Risk Ratio and LINT-* drift hazards.
stokes_boundary_graphNone (workspace_path, include_isolated)Extracts the sparse Interface Boundary Compatibility Graph nodes and edges.
stokes_remediateitem_type (core_reserved_slots=128, adaptive_slots=72)Generates Dual-Zone select_nth_unstable_by Rust partitioning and currentDatabase() SQL patches.
stokes_inspect_channelchannel_idInspects a KV key, Kafka topic, or socket pattern for serialization guards.
stokes_verify_patchpatch_content (target_file)Simulates and verifies a unified diff against Stokes invariants before disk write.
Complete JSON Input Schemas & Sample Outputs
// stokes_audit sample response
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "STOKES BOUNDARY VERIFICATION REPORT\nWorkspace: /workspace/cloudflame\nPeak Cardinality Risk Ratio: 1.40 (FATAL CONTRACT DRIFT)\nViolations: [LINT-001: Unscoped system.columns reflection query in services/feature-pipeline/catalog_sync.py, LINT-004: Fixed stack buffer [Feature; 200] overflow in crates/cloudflame-proxy/src/engine/feature_ingest.rs]"
      }
    ]
  }
}
// stokes_boundary_graph sample output
{
  "nodes": [
    { "id": "sql_bot_signals", "tier": "analytical_storage", "file": "migrations/002_shard_definitions.sql", "cardinality": 280, "scoped": false },
    { "id": "wire_bot_signals", "tier": "wire_transport", "channel": "analytics_to_edge_l7", "serializer": "services/feature-pipeline/catalog_sync.py" },
    { "id": "rust_proxy_intake", "tier": "edge_proxy", "file": "crates/cloudflame-proxy/src/engine/feature_ingest.rs", "buffer_type": "[FeatureDescriptor; 200]", "capacity": 200 }
  ],
  "edges": [
    { "source": "sql_bot_signals", "target": "wire_bot_signals", "query": "SELECT name, type FROM system.columns WHERE table LIKE 'events%'" },
    { "source": "wire_bot_signals", "target": "rust_proxy_intake", "risk_ratio": 1.40, "status": "FATAL_DRIFT" }
  ]
}
// stokes_remediate inputSchema
{
  "name": "stokes_remediate",
  "inputSchema": {
    "type": "object",
    "properties": {
      "item_type": { "type": "string", "default": "FeatureDescriptor" },
      "core_reserved_slots": { "type": "integer", "default": 128 },
      "adaptive_slots": { "type": "integer", "default": 72 }
    },
    "required": ["item_type"]
  }
}
// stokes_inspect_channel & stokes_verify_patch inputSchemas
{
  "name": "stokes_inspect_channel",
  "inputSchema": {
    "type": "object",
    "properties": { "channel_id": { "type": "string" } },
    "required": ["channel_id"]
  }
}

{
  "name": "stokes_verify_patch",
  "inputSchema": {
    "type": "object",
    "properties": {
      "patch_content": { "type": "string" },
      "target_file": { "type": "string" }
    },
    "required": ["patch_content"]
  }
}

Resource URIs & Guided Prompts

Resource URIMIME TypeDescription
stokes://contractsapplication/jsonActive boundary contracts, buffer capacities, and field mappings from stokes.toml.
stokes://graphapplication/jsonDirected acyclic graph of multi-tier dependencies.
stokes://lockfiletext/plainCryptographic stokes.lock SHA-256 interface signatures.
  • stokes_refactor_contract: Reads stokes://contracts, replaces .try_into().unwrap() with Dual-Zone 128 + 72 select_nth_unstable_by partitioning, verifies via stokes_verify_patch, and prepares stokes.lock updates.
  • stokes_explain_violation: Explains why unchecked slice conversions trigger fleet restarts, detailing L1D cache bounds and Dual-Zone partitioning alternatives.

AI Agent Integration Setup

Cursor & Claude Code

Configure .cursor/mcp.json or claude_desktop_config.json with command: "stokes", args: ["mcp"] (or run claude mcp add stokes -- stokes mcp). Add .cursorrules directives requiring AND database = currentDatabase(), banning .try_into().unwrap(), and running stokes_audit before PRs.

IBM Bob 2.0 Autonomous IPC

Running stokes audit --with-bob or stokes remediate --agent=bob dispatches an AGENTS.md directive over /tmp/stokes-bob.sock using 4-byte big-endian uint32 length-prefixed framing (16 MB max budget, 16.6 ms render coalescing).

See Deterministic CI Gate & Native MCP Server and Parallel Language Workers & Event Bus for the underlying bus architecture.

Search wiki and portfolio

type to search across all entries.