updated 2026-11-26·5 min read
Deterministic CI Gate & Native MCP Server
Static AST boundary checks in CI/CD pipelines and the native Model Context Protocol (MCP) server for AI coding assistants.
Two things break polyglot backends in practice: four-minute Docker integration suites that developers skip on local commits, and an AI coding assistant editing a .sql migration with no idea a Rust stack buffer downstream only holds 200 slots.
Stokes runs both checks from the same parser and reachability core: a zero-container static CI gate (stokes verify --strict) and a native Model Context Protocol (MCP) server over stdio.
- Entrypoints (Developer CLI & AI Agents)
Developers invoke stokes verify --strict on push/PR; AI coding agents connect to stokes mcp over JSON-RPC 2.0 stdio.
- Boundary Parsing & Graph Walk
Stokes parses SQL, Protobuf, Python, and Rust boundary files (native Tree-sitter when present, Python regex fallback otherwise) to link upstream schemas to downstream buffers.
- Lockfile Digest Check
Normalized boundary declarations are hashed with SHA-256 and checked against stokes.lock.
- Deterministic Outputs
CLI emits Exit 0 (Verified), Exit 1 (Contract Violation), or Exit 2 (Missing Manifest); MCP returns stokes_boundary_graph, stokes_audit, and patch guidance.
Static AST CI Verification Gate
Because stokes verify --lockfile=stokes.lock --strict skips Docker containers, avoids booting databases, and never invokes rustc or mypy, a local gate finishes in a fraction of a second rather than minutes. Every check ends in one of five explicit exit codes:
| Exit Code | Semantic Status | Meaning & Remediation |
|---|---|---|
0 | VERIFIED | All boundary bounds hold and stokes.lock digests match. |
1 | CONTRACT_VIOLATION | Column-vs-buffer overflow, wildcards, or float traps found. Merge blocked. |
2 | INVALID_CONFIGURATION | Missing stokes.toml, malformed manifest, or missing/corrupted stokes.lock. Run stokes init or stokes scan. |
3 | FATAL_INTERNAL_ERROR | System I/O error or unhandled parsing fault. |
130 | INTERRUPTED | Received SIGINT (Ctrl+C) or timed out. |
GitHub Actions Gate Workflow (.github/workflows/stokes-gate.yml)
name: Stokes Cross-Boundary CI Gate
on:
pull_request:
branches: [main, release-*]
push:
branches: [main]
jobs:
boundary-audit:
name: Boundary Verification
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout Source Code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install Stokes
run: curl -fsSL https://trystokes.pages.dev/install.sh | sh
- name: Execute Fast Gate
run: |
stokes verify --strict \
--manifest=stokes.toml \
--lockfile=stokes.lock \
--format=github-annotations \
--json-out=stokes-result.json
- name: Check Artifact Conformance
if: failure()
run: |
echo "::error::Stokes Boundary Verification Failed!"
echo "::notice::Run 'stokes audit' locally to review synthesized diffs."
exit 1Native Model Context Protocol (MCP) Server
Standard LSP diagnostics stop at the file currently open in the editor. When an AI assistant proposes an upstream SQL migration, Stokes MCP checks the diff against downstream buffers before it touches disk:
- Agent Query
Agent calls stokes_inspect_channel(channel_id="analytics_to_edge_l7") or stokes_verify_patch before committing an upstream schema change.
- Reachability Evaluation
Stokes walks downstream consumers mapped to the channel.
- Capacity Check
Detects a downstream edge proxy allocating a fixed 200-slot stack buffer.
- Rejection & Guidance
On a proposed expansion to 202 columns, Stokes flags Risk = 202 / 200 = 1.01 > 1.0 and suggests expanding downstream capacity or using Dual-Zone partitioning.
- Patch Application
The agent patches the downstream consumer or scopes the SQL query before committing.
JSON-RPC 2.0 stokes_verify_patch Request & Response
// Request
{
"jsonrpc": "2.0",
"id": "req-042",
"method": "tools/call",
"params": {
"name": "stokes_verify_patch",
"arguments": {
"target_file": "migrations/001_bot_signals.sql",
"patch_content": "--- a/migrations/001_bot_signals.sql\n+++ b/migrations/001_bot_signals.sql\n@@ -10,2 +10,4 @@\n+ ja4_transport_entropy Float32,\n+ device_trust_score Float32,\n"
}
}
}
// Response
{
"jsonrpc": "2.0",
"id": "req-042",
"result": {
"is_safe": false,
"rule_id": "LINT-004",
"risk_ratio": 1.01,
"downstream_impacts": [
{
"channel_id": "analytics_to_edge_l7",
"consumer_repo": "cloudflame-proxy",
"consumer_file": "crates/cloudflame-proxy/src/engine/feature_ingest.rs",
"buffer_capacity": 200,
"new_cardinality": 202,
"panic_reachable": true
}
],
"remediation_guidance": "Do not commit this SQL migration yet. Run stokes_remediate to synthesize Dual-Zone (128 + 72) partitioning or expand downstream capacity first."
}
}MCP Tools, Resources & Agent Setup
- Exposed Tools:
stokes_audit,stokes_boundary_graph,stokes_remediate,stokes_inspect_channel,stokes_verify_patch. - Exposed Resources:
stokes://contracts,stokes://graph,stokes://lockfile.
Cursor, Claude Code, and IBM Bob 2.0 Configurations
// .cursor/mcp.json
{
"mcpServers": {
"stokes": {
"command": "stokes",
"args": ["mcp"],
"env": {
"STOKES_LOG_LEVEL": "info",
"STOKES_STRICT": "1"
}
}
}
}// ~/.claude/config.json
{
"mcpServers": {
"stokes-boundary-engine": {
"command": "stokes",
"args": ["mcp"],
"transport": "stdio"
}
}
}# stokes/subagents/mcp_bridge.py
class BobStokesMCPBridge:
def __init__(self, workspace: str) -> None:
self.workspace = workspace
self.engine = ReachabilityGraph()
async def handle_agent_pre_commit(self, file_path: str, diff: str) -> dict:
"""Invoked by Bob 2.0 before writing patches to disk."""
impact = self.engine.evaluate_diff_impact(file_path, diff)
if impact.violates_invariant:
return {
"allow_write": False,
"reason": impact.explanation,
"required_action": "EXPAND_DOWNSTREAM_BUFFER_FIRST"
}
return {"allow_write": True}Why Static Gate + MCP Beats Waiting on Full CI
| Feature | Legacy CI Linting | Static Analyzer (SonarQube) | Monorepo CI (Bazel) | Stokes Gate + MCP |
|---|---|---|---|---|
| Execution Cost | Full toolchain per repo | Full index build | Dependency graph + builds | Single-pass AST/regex scan (no Docker or rustc) |
| Cross-Language Analysis | None (Siloed) | Superficial rules | Dependency graph only | Cross-boundary reachability |
| Buffer Capacity Awareness | None | None | None | Stack/Cache bound (emitted <= capacity) |
| AI Agent Feedback | Post-commit only | Post-commit only | Post-commit only | Pre-commit via MCP JSON-RPC |
| Schema Lockfile | None | None | None | stokes.lock (SHA-256 ASTs) |
See MCP Protocol Specification and CLI Reference for complete JSON schemas and command flags.