Skip to content

security(mcp): per-tool read-only gate for MCP over HTTP - #1441

Merged
ajianaz merged 4 commits into
developfrom
security/mcp-read-only-gate
Oct 13, 2026
Merged

ajianaz merged 4 commits into
developfrom
security/mcp-read-only-gate

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

What

  • Per-tool gate in uteke-mcp. MCP now checks each tool call against the caller's access. Pieces:
    • Access { Full, ReadOnly }
    • READ_ONLY_TOOLS: 22 read tools
    • handle_jsonrpc_as(uteke, raw, access)
  • Refusal shape. A read-only caller using any other tool gets a tool result with isError: true and the text Read-only token cannot use <tool>. Nothing runs.
  • HTTP server.
    • POST /mcp is now registered writes: false.
    • The bridge passes Access::ReadOnly for a read-only token and Access::Full otherwise.
  • Unchanged. The stdio transport (handle_jsonrpc) is still full access.
  • Docs. docs/mcp.md gains a "Read-only tokens" section, docs/configuration.md is corrected, and there is a CHANGELOG Security entry.

Why

Part of #1439: one behaviour on every surface. Before this change:

  • /mcp was a write route, so a read-only token could not call any MCP tool, not even recall. docs/mcp.md already recommended a read-only token "for clients that only need to recall".
  • Once a token reached /mcp, nothing inside MCP was gated.

uteke-cloud already refuses destructive MCP tools for read-only keys and returns route refusals as MCP tool errors. This brings OSS in line.

Contract. This is additive for CORE:

  • Write tokens and stdio behave as before.
  • Read-only tokens only gain the read tools.
  • writes is #[serde(skip)], so docs/core-contract.json and docs/api-reference.md are byte-identical.

Testing

  • Commands. All pass and are clean:
    • cargo test -p uteke-mcp: 34 passed, including 7 read_only_gate_tests
    • cargo test -p uteke-server: all suites pass, including mcp_read_only_tests and the existing read_only_token_gets_403_on_exactly_the_writing_rows
    • cargo fmt --all -- --check
    • cargo clippy --workspace --all-targets -- -D warnings
    • cargo run -p docgen && git diff --exit-code docs/: no diff
  • uteke-mcp tests.
    • Read-only is refused a write tool, and nothing is written (count 0).
    • Read-only can call a read tool.
    • Full access is unchanged.
    • A read-only notification for a write tool runs nothing.
    • The uteke_room_document alias is read-only.
    • The allowlist is pinned by a snapshot test.
  • uteke-server tests.
    • A read-only token reaches uteke_stats.
    • A read-only token is refused uteke_remember with isError, and nothing is stored.
    • A write token is unchanged.
    • A cross-check maps every READ_ONLY_TOOLS entry to a registry row with writes: false, in both directions.
  • Not tested. No server test covers auth-disabled /mcp calling a write tool (it resolves to Access::Full). tools/list still lists every tool for read-only callers; filtering it is a possible follow-up.

@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

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