feat(proxy): implement upstream MCP forwarding (live call path was a no-op) - #280
Merged
imran-siddique merged 2 commits intoJun 11, 2026
Merged
Conversation
… path)
Proxy step 3 called self._mcp_gateway.call_tool(), a method that does not
exist on AGT MCPGateway -- the AttributeError was swallowed by the generic
except branch, so EVERY tool call was denied in the live runtime. All tests
mocked the nonexistent method, which is why the suite stayed green.
New pipeline, matching AGT's intended interception API:
3a. intercept_tool_call() pre-call check (rate limit, sanitization)
3b. _forward_to_upstream() JSON-RPC 2.0 tools/call POST to the attested
catalog entry's server.url via httpx
3c. size guard enforce config.max_response_size_bytes (DOS-002)
3d. intercept_tool_response() injection/credential/PII scan; honors
sanitized content
Upstream failures audit as faults and return 502 (UPSTREAM_UNAVAILABLE /
UPSTREAM_TOOL_ERROR), distinct from policy denies. Session sensitivity now
derives from the catalog entry's declared sensitivity_level; injection
detail derives from scanner threat categories.
Tests migrated to the new seam via a shared wire_mock_gateway() helper, plus
live-HTTP forwarding tests against a local mock MCP server. benchmarks.py
updated to the same seam.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 10, 2026
…tates the session (#282)
1 task
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
The most critical finding from today's codebase review: the live runtime could never execute a tool call. Proxy step 3 called
self._mcp_gateway.call_tool()-- a method that does not exist on AGT'sMCPGateway(it was# type: ignore'd). The resultingAttributeErrorwas swallowed by the broadexcept Exceptionbranch and recorded as an AGT deny, so every call returned 403. Every test mocked the nonexistent method, which is why CI stayed green.This PR implements the actual upstream forwarding using AGT's intended interception API:
intercept_tool_call()-- rate limit, parameter sanitizationagt_gateway:<reason>)_forward_to_upstream()-- JSON-RPC 2.0tools/callPOST to the attested catalogserver.url(httpx, 30s timeout)UPSTREAM_UNAVAILABLE/UPSTREAM_TOOL_ERROR)config.max_response_size_bytes(DOS-002, previously unenforced on egress)response_size_exceeded)intercept_tool_response()-- injection/credential/PII scan, honors sanitized contentresponse_blocked_by_scanner, auditinjection_detected)Session sensitivity now derives from the catalog entry's declared
sensitivity_level(attested data) instead of duck-typed attributes on a mock object. Upstream failures are 502s, not policy denies.Not in scope (follow-ups): TLS fingerprint pinning of upstream connections (
catalog.server.tls_fingerprintis currently unchecked), SSE transport.Test plan
tests/unit/test_upstream_forwarding.py: real HTTP round-trip against a local mock MCP server (text extraction, JSON-RPC error -> UpstreamToolError, unreachable -> UpstreamUnavailable)wire_mock_gateway()helperStacked on #279 (advice support).
Generated with Claude Code