fix: add corporate proxy support using https-proxy-agent (fixes #18) - #19
fix: add corporate proxy support using https-proxy-agent (fixes #18)#19zouyi100 wants to merge 2 commits into
Conversation
…oxy support Replace the undici-based proxy dispatcher approach with node-fetch and https-proxy-agent, which provides better compatibility across different proxy environments. - Remove undici dependency, add node-fetch and https-proxy-agent - Add nock dev dependency for clean HTTP mocking in tests - Refactor getProxyAgent to return HttpsProxyAgent instead of undici ProxyAgent - Add proxyFetch wrapper function for proxy-aware fetch calls - Update manifest_processor to use proxyFetch instead of raw fetch with dispatcher - Rewrite manifest_processor tests to use nock instead of global.fetch mocking - Add comprehensive getProxyAgent unit tests with proxy env var priority validation
|
Thanks for this, and for the tests. The proxy bug is real, I reproduced it locally. Since we're on Node 20+, native import { EnvHttpProxyAgent, setGlobalDispatcher } from 'undici';
setGlobalDispatcher(new EnvHttpProxyAgent());I tested it against a local proxy and it works. That lets us drop Your first commit used undici's Let's keep the const { hostname, port } = new URL(proxyUrl);
logger.debug(`Using proxy: ${hostname}:${port}`); |
|
Hi @zouyi100, any thoughts on the above? |
Summary
The MCP server originally does not work behind a corporate proxy because Node.js native
fetch()does not respectHTTP_PROXY/HTTPS_PROXYenvironment variables. This PR adds proxy support usinghttps-proxy-agentandnode-fetch, enabling the server to function correctly in proxied environments.Commits
bf73e5e- Initial proxy support: AddedgetProxyAgent()that reads proxy configuration fromHTTPS_PROXY,https_proxy,HTTP_PROXY,http_proxyenvironment variables.20f6bca- Replacedundiciwithnode-fetch+https-proxy-agentfor robust proxy support. AddedproxyFetch()wrapper, comprehensive unit tests withnock, and proper env var priority handling.Key Changes
node-fetchandhttps-proxy-agentas runtime dependencies; removedundicinockas dev dependency for clean HTTP mocking in testsgetProxyAgent()returns anHttpsProxyAgentbased on proxy env varsproxyFetch()wrapper routes all outbound requests through proxy when configuredHTTPS_PROXY>https_proxy>HTTP_PROXY>http_proxymanifest_processorto useproxyFetchinstead of rawfetchmanifest_processortests to usenockinstead of mockingglobal.fetchgetProxyAgentunit tests with proper env var isolationFixes #18