mcp-proxy 6.4.6 → 6.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -1
- package/dist/bin/mcp-proxy.mjs +15 -1
- package/dist/bin/mcp-proxy.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{stdio-BGZrO8Rz.mjs → stdio-DN-u_q7a.mjs} +5 -1
- package/dist/{stdio-BGZrO8Rz.mjs.map → stdio-DN-u_q7a.mjs.map} +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/bin/mcp-proxy.ts +23 -0
- package/src/startHTTPServer.ts +8 -1
package/README.md
CHANGED
|
@@ -62,6 +62,25 @@ options:
|
|
|
62
62
|
- `--sslKey`: Private keys filename in PEM format
|
|
63
63
|
- `--tunnel`: Expose the proxy via a public tunnel (see [Public Tunnel](#public-tunnel))
|
|
64
64
|
- `--tunnelSubdomain`: Request a specific subdomain for the tunnel (availability not guaranteed)
|
|
65
|
+
- `--corsAddAllowedHeader`: Add a header name to `Access-Control-Allow-Headers` (defaults preserved). Repeat to add multiple. Useful when running with `--apiKey` so browser preflights for `X-API-Key` succeed.
|
|
66
|
+
|
|
67
|
+
### Troubleshooting Python stdio servers
|
|
68
|
+
|
|
69
|
+
If a Python stdio MCP server times out with an error such as `Expected server to respond to ping`, make sure Python is running in unbuffered mode. Buffered stdout can delay MCP JSON-RPC messages long enough for the proxy to treat the server as unresponsive.
|
|
70
|
+
|
|
71
|
+
Use `python -u` when launching the server:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx mcp-proxy -- python -u -m your_package.mcp_server
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Alternatively, set `PYTHONUNBUFFERED=1`:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
PYTHONUNBUFFERED=1 npx mcp-proxy -- python -m your_package.mcp_server
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
MCP stdio servers should also reserve stdout for protocol messages. Send logs, warnings, and other diagnostic output to stderr, and use `--debug` when you need proxy-side logs.
|
|
65
84
|
|
|
66
85
|
### Public Tunnel
|
|
67
86
|
|
|
@@ -84,7 +103,7 @@ tunnel established at https://abcdefghij.tunnel.gla.ma
|
|
|
84
103
|
> [!NOTE]
|
|
85
104
|
> The requested subdomain may not be available. The actual URL will be displayed when the tunnel is established.
|
|
86
105
|
|
|
87
|
-
This feature is powered by [pipenet](https://github.com/
|
|
106
|
+
This feature is powered by [pipenet](https://github.com/punkpeye/pipenet) and sponsored by [glama.ai](https://glama.ai). For more information, see the [pipenet announcement](https://glama.ai/blog/2026-01-19-pipenet).
|
|
88
107
|
|
|
89
108
|
### Stateless Mode
|
|
90
109
|
|
|
@@ -318,6 +337,23 @@ await startHTTPServer({
|
|
|
318
337
|
});
|
|
319
338
|
```
|
|
320
339
|
|
|
340
|
+
#### CLI: adding allowed headers
|
|
341
|
+
|
|
342
|
+
The CLI exposes a single `--corsAddAllowedHeader` flag that appends to the
|
|
343
|
+
default `Access-Control-Allow-Headers` list (defaults preserved). The most
|
|
344
|
+
common use is unblocking the browser preflight for a custom auth header when
|
|
345
|
+
the proxy is started with `--apiKey`:
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
npx mcp-proxy --port 8080 --apiKey secret \
|
|
349
|
+
--corsAddAllowedHeader X-API-Key \
|
|
350
|
+
-- npx -y @modelcontextprotocol/server-filesystem /srv
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Repeat the flag to add more (`--corsAddAllowedHeader X-API-Key --corsAddAllowedHeader X-Other`).
|
|
354
|
+
For broader CORS overrides (origin allowlist, wildcard headers, disabling CORS),
|
|
355
|
+
use the programmatic `cors` option below.
|
|
356
|
+
|
|
321
357
|
#### Migration from Older Versions
|
|
322
358
|
|
|
323
359
|
If you were using mcp-proxy 5.5.6 and want the same permissive behavior in 5.9.0+:
|
package/dist/bin/mcp-proxy.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { D as __toESM, E as __commonJSMin, a as startHTTPServer, i as Client, n as serializeMessage, o as proxyServer, r as Server, t as ReadBuffer, w as InMemoryEventStore } from "../stdio-
|
|
2
|
+
import { D as __toESM, E as __commonJSMin, a as startHTTPServer, i as Client, n as serializeMessage, o as proxyServer, r as Server, t as ReadBuffer, w as InMemoryEventStore } from "../stdio-DN-u_q7a.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { basename, dirname, extname, join, normalize, relative, resolve } from "path";
|
|
5
5
|
import { format, inspect } from "util";
|
|
@@ -5053,6 +5053,11 @@ const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").
|
|
|
5053
5053
|
describe: "The timeout (in milliseconds) for initial connection to the MCP server (default: 60 seconds)",
|
|
5054
5054
|
type: "number"
|
|
5055
5055
|
},
|
|
5056
|
+
corsAddAllowedHeader: {
|
|
5057
|
+
array: true,
|
|
5058
|
+
describe: "Add a header name to Access-Control-Allow-Headers (defaults preserved). Repeat to add multiple, e.g. `--corsAddAllowedHeader X-API-Key`.",
|
|
5059
|
+
type: "string"
|
|
5060
|
+
},
|
|
5056
5061
|
debug: {
|
|
5057
5062
|
default: false,
|
|
5058
5063
|
describe: "Enable debug logging",
|
|
@@ -5129,6 +5134,14 @@ const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").
|
|
|
5129
5134
|
type: "string"
|
|
5130
5135
|
}
|
|
5131
5136
|
}).help().parseAsync();
|
|
5137
|
+
const corsOption = argv.corsAddAllowedHeader && argv.corsAddAllowedHeader.length > 0 ? { allowedHeaders: [...[
|
|
5138
|
+
"Content-Type",
|
|
5139
|
+
"Authorization",
|
|
5140
|
+
"Accept",
|
|
5141
|
+
"Mcp-Session-Id",
|
|
5142
|
+
"Mcp-Protocol-Version",
|
|
5143
|
+
"Last-Event-Id"
|
|
5144
|
+
], ...argv.corsAddAllowedHeader] } : void 0;
|
|
5132
5145
|
const dashDashArgs = argv["--"];
|
|
5133
5146
|
let finalCommand;
|
|
5134
5147
|
let finalArgs;
|
|
@@ -5180,6 +5193,7 @@ const proxy = async () => {
|
|
|
5180
5193
|
};
|
|
5181
5194
|
const server = await startHTTPServer({
|
|
5182
5195
|
apiKey: argv.apiKey,
|
|
5196
|
+
cors: corsOption,
|
|
5183
5197
|
createServer,
|
|
5184
5198
|
eventStore: new InMemoryEventStore(),
|
|
5185
5199
|
host: argv.host,
|