Skip to content

feat(mcp-gateway): MCP gateway extension with 4-point security scanning#148

Merged
lantiscooperdev merged 1 commit into
mainfrom
feat/mcp-gateway
Jul 23, 2026
Merged

feat(mcp-gateway): MCP gateway extension with 4-point security scanning#148
lantiscooperdev merged 1 commit into
mainfrom
feat/mcp-gateway

Conversation

@lantisprime

Copy link
Copy Markdown
Owner

Summary

Bridge pi to a LiteLLM-proxy MCP endpoint. Two meta-tools — mcp_list_tools and mcp_call — speak MCP streamable-HTTP JSON-RPC to https://<gateway>/mcp/<server>; 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 risk or any secret-material finding (a single credential blocks; includeRiskyContent cannot bypass — it is inbound-only).
  • Inbound content — scanned; omitted unless safe or includeRiskyContent opt-in.
  • Tool descriptions — poisoned descriptions replaced with a placeholder.
  • Tool names + schemas — risky names/schemas omitted from listings (closes the "every gateway-supplied text" gap).

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_CAP short-circuits before the O(n²) scanner on >64 KB content); set-gateway normalizes 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 green
  • bash scripts/verify-shared-sync.sh — all 4 vendored security-scan.ts copies 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

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
lantiscooperdev merged commit 4fd35be into main Jul 23, 2026
1 check passed
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.

2 participants