Skip to content

Commit 338df58

Browse files
authored
Merge pull request #131 from phoval/feat/proxy
feat: proxy support
2 parents 898139a + 782ed64 commit 338df58

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@ To bypass authentication, or to emit custom headers on all requests to your remo
135135
]
136136
```
137137

138+
* To enable an outbound HTTP(S) proxy for mcp-remote, add the `--enable-proxy` flag. When enabled, mcp-remote will use the proxy settings from common environment variables (for example `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`).
139+
140+
```json
141+
"args": [
142+
"mcp-remote",
143+
"https://remote.mcp.server/sse",
144+
"--enable-proxy"
145+
],
146+
"env": {
147+
"HTTPS_PROXY": "http://127.0.0.1:3128",
148+
"NO_PROXY": "localhost,127.0.0.1"
149+
}
150+
```
151+
138152
* To ignore specific tools from the remote server, add the `--ignore-tool` flag. This will filter out tools matching the specified patterns from both `tools/list` responses and block `tools/call` requests. Supports wildcard patterns with `*`.
139153

140154
```json

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"dependencies": {
3434
"express": "^4.21.2",
3535
"open": "^10.1.0",
36-
"strict-url-sanitise": "^0.0.1"
36+
"strict-url-sanitise": "^0.0.1",
37+
"undici": "^7.12.0"
3738
},
3839
"devDependencies": {
3940
"@modelcontextprotocol/sdk": "^1.17.3",

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import fs from 'fs'
1414
import { readFile, rm } from 'fs/promises'
1515
import path from 'path'
1616
import { version as MCP_REMOTE_VERSION } from '../../package.json'
17+
import { fetch, setGlobalDispatcher, RequestInit, EnvHttpProxyAgent } from 'undici'
1718

1819
// Global type declaration for typescript
1920
declare global {
@@ -629,6 +630,13 @@ export async function parseCommandLineArgs(args: string[], usage: string) {
629630
log('Debug mode enabled - detailed logs will be written to ~/.mcp-auth/')
630631
}
631632

633+
const enableProxy = args.includes('--enable-proxy')
634+
if (enableProxy) {
635+
// Use env proxy
636+
setGlobalDispatcher(new EnvHttpProxyAgent())
637+
log('HTTP proxy support enabled - using system HTTP_PROXY/HTTPS_PROXY environment variables')
638+
}
639+
632640
// Parse transport strategy
633641
let transportStrategy: TransportStrategy = 'http-first' // Default
634642
const transportIndex = args.indexOf('--transport')

0 commit comments

Comments
 (0)