feat(mcp-gateway): MCP gateway extension with 4-point security scanning#148
Merged
Conversation
Bridge pi to a LiteLLM-proxy MCP endpoint via two meta-tools (mcp_list_tools, mcp_call) that speak MCP streamable-HTTP JSON-RPC. Every piece of gateway-supplied text is scanned with the vendored shared security layer. Security model: - 4 scan points: outbound args (hard-block on dangerous/secret-material), inbound content, tool descriptions, and tool names+schemas in listings. - TOFU manifest pinning; mcp_call blocked when a server's manifest changes until /mcp-gateway accept-changes. - LiteLLM key never appears in tool output, config, notify text, or errors; transport-error messages are scanned/omitted; cross-finding secret scrub (descending-length ordering) prevents key fragments leaking via any finding. - Inbound DoS guard: SCAN_INPUT_CAP short-circuits before the O(n^2) scanner on >64KB gateway content (includeRiskyContent cannot bypass). - set-gateway normalizes to origin (strips userinfo/path/query). Reviewed adversarially by pi/GLM-5.2 across 4 rounds (REJECT -> HOLD-1 -> HOLD-2 -> ACCEPT); frozen build spec + review trail in mcp-gateway/docs/. Shared scanner amendments synced to all 4 vendored copies; verify-shared-sync extended to cover mcp-gateway. All test suites green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jgj3pnB7jzAtbSN8gemuAC
lantiscooperdev
approved these changes
Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bridge pi to a LiteLLM-proxy MCP endpoint. Two meta-tools —
mcp_list_toolsandmcp_call— speak MCP streamable-HTTP JSON-RPC tohttps://<gateway>/mcp/<server>; every piece of gateway-supplied text is scanned with the vendored shared security layer.Security model (4 scan points)
dangerousrisk or anysecret-materialfinding (a single credential blocks;includeRiskyContentcannot bypass — it is inbound-only).includeRiskyContentopt-in.Plus: TOFU manifest pinning (mcp_call blocked on manifest change until
/mcp-gateway accept-changes); the LiteLLM key never appears in output/config/notify/errors; transport-error messages scanned/omitted; cross-finding secret scrub (descending-length ordering) so no key fragment leaks via any finding's match; inbound DoS guard (SCAN_INPUT_CAPshort-circuits before the O(n²) scanner on >64 KB content);set-gatewaynormalizes to origin.Review trail
Adversarially reviewed by pi/GLM-5.2 over 4 rounds: REJECT (1×P1 + 6×P3) → HOLD-1 (residual key-leak) → HOLD-2 (prefix-subset fragment + O(n²) DoS) → ACCEPT. Frozen build spec and full review trail committed under
mcp-gateway/docs/(PLAN.md,REVIEW_R4.md).Test plan
bash mcp-gateway/test-fixtures/run-mcp-gateway-tests.sh— mcp-client + security-gating suites greenbash scripts/verify-shared-sync.sh— all 4 vendoredsecurity-scan.tscopies in sync (now includes mcp-gateway)node scripts/test-security-scan.mjs— shared scanner tests green (incl. new secret-scrub + prefix-subset assertions)npx tsx -e "import('./mcp-gateway/lib/mcp-client.ts')"— client import OK🤖 Generated with Claude Code