anthropics / anthropics/claude-agent-sdk-typescript
[BUG] HTTP MCP Servers Fail Behind Corporate Proxy in Agent SDK v0.2.38
- 主要言語
- Shell
- スター
- 1.8k
- フォーク
- 226
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
## Summary
HTTP-type MCP servers fail to connect with "The socket connection was closed unexpectedly" error when the SDK is used behind a corporate proxy with SSL inspection. SSE and stdio MCP servers work fine, and external HTTP servers (outside the proxy) also work.
## Root Cause
The bundled MCP transport code appears to make HTTP GET requests (for SSE handshake) without passing proxy configuration. While environment variables (HTTP_PROXY, HTTPS_PROXY) are set, they don't work with undici's ProxyAgent dispatcher, which is required for corporate proxies with SSL inspection.
## Reproduction
1. Configure HTTP MCP server behind corporate proxy
2. Set environment proxy variables:
- HTTP_PROXY=http://proxy.company.com:8080
- HTTPS_PROXY=http://proxy.company.com:8080
- NODE_EXTRA_CA_CERTS=/path/to/corporate/ca.pem
3. Call query() with MCP servers
4. Result: Connection fails with socket closed error
## Evidence
- ✅ POST requests TO MCP servers → Work (proxy config included)
- ❌ GET requests FROM MCP servers (SSE) → Fail (socket closes unexpectedly)
- ✅ External HTTP MCP servers → Work (no proxy needed)
- ✅ SSE-type MCP servers → Work (no issue)
Related upstream issue: https://github.com/modelcontextprotocol/typescript-sdk/issues/895
## Requested Solutions
- **Option A**: Add requestInit parameter to query() options for proxy dispatcher
- **Option B**: Ensure proxy environment variables work consistently for all request types
- **Option C**: Expose custom fetch function parameter to query()
## Version Info
- Agent SDK: v0.2.38 (latest)
- Environment: VSCode Extension (Node.js v22.x)
- Proxy: undici ProxyAgent with SSL inspection
## Impact
This completely blocks HTTP MCP server usage in enterprise environments with corporate proxies. This is a critical blocker for enterprise adoption of the Agent SDK.
Please advise on:
1. Is there a workaround available in v0.2.38?
2. Is this fixed in a newer version?
3. Can proxy configuration be exposed in query() options?
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。