Add pysocks dependency for HTTP proxy support#660
Conversation
…ility google-api-python-client uses httplib2 for HTTP requests, which requires the PySocks package to route traffic through HTTP/SOCKS proxies. Without PySocks, httplib2 silently falls back to direct connections, ignoring HTTPS_PROXY environment variables entirely. This causes all googleapiclient API calls to fail with "[Errno 101] Network is unreachable" when the server runs behind a network proxy — such as container isolation tools like ToolHive (Stacklok) that enforce egress controls via a Squid proxy. The OAuth token exchange succeeds because google-auth-oauthlib uses the requests library (which respects proxy env vars), but the subsequent userinfo fetch and all Google API calls fail because they use httplib2. Changes: - Add pysocks>=1.7.1 to pyproject.toml dependencies - Add --no-sync flag to Dockerfile CMD to prevent uv from attempting PyPI access at runtime (blocked by network isolation egress policies) - Regenerate uv.lock Co-Authored-By: Conor Sherman <conor@conorsherman.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe Dockerfile's entrypoint command now includes the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
pysocks>=1.7.1as a dependency to enablehttplib2proxy support--no-syncflag to Dockerfile CMD to prevent runtime PyPI access in network-isolated containersuv.lockProblem
When running google-workspace-mcp behind an HTTP proxy (e.g., in a container with network isolation via ToolHive), all
googleapiclientAPI calls fail with:The OAuth token exchange succeeds, but the subsequent userinfo fetch and all Google API calls fail silently.
Root Cause
google-api-python-clientuseshttplib2for HTTP requests.httplib2has built-in proxy support, but it requires thePySockspackage as an optional dependency. Without PySocks installed,httplib2silently falls back to direct connections, completely ignoringHTTPS_PROXY/HTTP_PROXYenvironment variables.This is particularly insidious because:
google-auth-oauthlib→requests(which does respect proxy env vars) → succeeds ✅googleapiclient→httplib2(which ignores proxy env vars without PySocks) → fails ❌httplib2does not warn or error when PySocks is missing — it just silently bypasses the proxyThis means the server appears to partially work (OAuth completes) but then fails on every actual API call.
Who This Affects
Anyone running google-workspace-mcp in an environment with HTTP proxy requirements:
HTTPS_PROXYis set and direct internet access is blockedChanges
pyproject.tomlAdded
pysocks>=1.7.1to dependencies. This enableshttplib2's built-in proxy detection viaproxy_info_from_environment().DockerfileChanged
uv run main.py→uv run --no-sync main.py. Without--no-sync,uv runattempts dependency resolution at startup, which fails in network-isolated containers where PyPI is unreachable. All dependencies are already installed at build time viauv sync --frozen.Test Plan
httplib2detects proxy:python -c "import httplib2; print(httplib2.socks)"should show a module, notNoneHTTPS_PROXYset — confirm OAuth flow completes AND API calls succeed--no-syncflag🤖 Generated with Claude Code
Summary by CodeRabbit