Skip to content

feat(mcp): add opt-in tool contract digests and pin checks - #32

Merged
ALikesToCode merged 1 commit into
integrate/gateway-waves-1-2from
feat/mcp-contract-drift
Oct 9, 2026
Merged

ALikesToCode merged 1 commit into
integrate/gateway-waves-1-2from
feat/mcp-contract-drift

Conversation

@ALikesToCode

Copy link
Copy Markdown
Owner

Summary

Adds MCP schema compatibility digests behind MCP_CONTRACT_DIGESTS_ENABLED, which defaults to false. While the flag is off, /mcp discovery and tool calls return exactly what they do today, and an X-MultiLLM-MCP-Contract header is ignored.

  • With the flag on, tools/list on both the Flask gateway and the edge Worker adds _meta.contract_digest:
    • to each visible tool;
    • to the result as a whole, covering only the tools the caller is authorized for and the selected toolsets.
  • A tool digest covers the tool name, the full input and output schemas, and the contract version. Descriptions are excluded, so wording changes don't break pins.
  • A client can pin a tool with X-MultiLLM-MCP-Contract: <digest>. On a mismatch, tools/call returns HTTP 409 mcp_contract_mismatch with Cache-Control: no-store.
    • The check runs after authentication and tool authorization.
    • It runs before execution, metering or provider dispatch.
  • Unpinned calls keep working when schemas change. There is no automatic retry, and a matching pin grants no extra permission.
  • scripts/build_knowledge_mcp_catalogue.py gains:
    • --baseline PATH, which writes a contract baseline;
    • --diff PATH, which classifies changes against it and exits 1 on a breaking change.
  • docs/mcp-contract-baseline.json is the current baseline.

Details are in docs/mcp-contract-drift.md.

Shared registrations

  • Added tests/test_mcp_contract_drift_worker.mjs to test:worker.
  • Added MCP_CONTRACT_DIGESTS_ENABLED to the Container env keys.
  • Added worker/knowledge/contract-drift.mjs to the secret firewall inventory.

Tests

  • tests/test_mcp_contract_drift.py and tests/test_mcp_contract_drift_worker.mjs: new, through the registered Flask and Worker /mcp paths.
  • Full Python suite: 3,241 passed, 2 skipped. ruff, mypy and bandit are clean.
  • npm run test:worker: 1,238 passed.
  • cf:migrations:check, test:deploy, free routes, client headers and the wrangler deploy --dry-run bundle all pass.
  • tests/test_frontend_build.mjs fails locally because @tailwindcss/cli is not installed. It fails the same way on main.

This is part of Wave 3. It is based on the Wave 2 integration branch (#25), and the Wave 3 integration PR adds the README line.

Add schema digests to /mcp tools/list on Flask and the edge Worker and reject a mismatched X-MultiLLM-MCP-Contract pin with 409 before dispatch, behind MCP_CONTRACT_DIGESTS_ENABLED, default off. The catalogue script gains --baseline and --diff.
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5626fd72-7864-4cdc-a337-ca53f1a21259

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
multillm-proxy 3153640 Oct 08 2026, 10:08 PM

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-08T22:12:14.432959Z 3153640 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ALikesToCode
ALikesToCode merged commit 9d43b50 into integrate/gateway-waves-1-2 Oct 9, 2026
5 of 7 checks passed
@ALikesToCode
ALikesToCode deleted the feat/mcp-contract-drift branch October 26, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant