feat: add --proxy mode for transparent HTTP MCP interception#19
Merged
Conversation
…_mode() Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ndshake Adds ProxyServer with upstream tool merging, query_handle_tool_def() for advertising the local tool, and init_proxy_server() async fn that runs the MCP initialize + tools/list handshake with the upstream server. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Implements list_tools and call_tool for ProxyServer: local query_handle dispatch + upstream forwarding via spawn_blocking. Adds text_content helper and intercept_if_large stub (Task 5 placeholder). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replace intercept_if_large stub with real implementation that stores large responses as handles and returns a preview with build_preview_text/format_preview_value. Add 5 TDD unit tests covering passthrough, interception, and preview formatting.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replaces the inline prefix check with is_localhost_proxy_url(), which validates that the character immediately after "http://localhost" or "http://127.0.0.1" is a port separator, path, query, fragment, or end-of-string — blocking URLs like http://localhost.attacker.com from matching.
Adds two pytest integration tests (marked `integration`) that spin up an in-process HTTP MCP mock server, run the binary in proxy mode, and verify large responses are intercepted with a handle+preview while small responses pass through unchanged. Also registers the `integration` marker in pyproject.toml. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ground Claude Code was killing the proxy because it got no MCP response while the proxy was blocked waiting for OAuth. Now the server accepts stdio right away; list_tools/call_tool wait on a Notify that fires once the upstream handshake (and any browser OAuth flow) completes.
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
--proxy <url>flag tocontext-cutter-mcp— makes it a transparent stdio↔HTTP proxy in front of any HTTP MCP server--proxy-threshold, default 2 KB) are stored as handles and replaced with a compact preview;query_handleis injected alongside the upstream tools--proxy-token-filedelegates auth to a token file (e.g. Claude Code's saved OAuth token), with automatic browser-based re-authentication via OAuth 2.0 + PKCE when the token expiresUsage
{ "clickup": { "command": "npx", "args": [ "-y", "context-cutter-mcp", "--proxy", "https://mcp.clickup.com/mcp", "--proxy-token-file", "~/.claude/clickup-token" ] } }With explicit auth header instead of a token file:
{ "args": ["...", "--proxy-header", "Authorization: Bearer $TOKEN"] }What Claude sees for large responses
CLI flags added
--proxy <url>--proxy-threshold <bytes>2048--proxy-header <K: V>--proxy-token-file <path>Test plan
cargo test— all Rust unit tests passpytest— Python tests pass including 2 new integration tests (mock HTTP MCP server)context-cutter-mcpwith no flags) unchanged--helpshows all proxy flagsquery_handleextracted specific fields🤖 Generated with Claude Code