mcp-proxy 5.12.5 → 6.1.9
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/.github/workflows/main.yaml +4 -13
- package/README.md +26 -20
- package/dist/bin/mcp-proxy.mjs +36 -8
- package/dist/bin/mcp-proxy.mjs.map +1 -1
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +1 -1
- package/dist/{stdio-DBuYn6eo.mjs → stdio-BArgKxoc.mjs} +30 -8
- package/dist/stdio-BArgKxoc.mjs.map +1 -0
- package/jsr.json +1 -1
- package/package.json +2 -2
- package/src/bin/mcp-proxy.ts +38 -9
- package/src/startHTTPServer.test.ts +62 -0
- package/src/startHTTPServer.ts +45 -2
- package/tsconfig.json +1 -1
- package/dist/stdio-DBuYn6eo.mjs.map +0 -1
|
@@ -7,14 +7,11 @@ jobs:
|
|
|
7
7
|
test:
|
|
8
8
|
environment: release
|
|
9
9
|
name: Test
|
|
10
|
-
strategy:
|
|
11
|
-
fail-fast: true
|
|
12
|
-
matrix:
|
|
13
|
-
node:
|
|
14
|
-
- 22
|
|
15
10
|
runs-on: ubuntu-latest
|
|
16
11
|
permissions:
|
|
17
12
|
contents: write
|
|
13
|
+
issues: write
|
|
14
|
+
pull-requests: write
|
|
18
15
|
id-token: write
|
|
19
16
|
steps:
|
|
20
17
|
- name: setup repository
|
|
@@ -24,15 +21,10 @@ jobs:
|
|
|
24
21
|
- uses: pnpm/action-setup@v4
|
|
25
22
|
with:
|
|
26
23
|
version: 9
|
|
27
|
-
- name:
|
|
24
|
+
- name: Setup NodeJS
|
|
28
25
|
uses: actions/setup-node@v4
|
|
29
26
|
with:
|
|
30
|
-
|
|
31
|
-
node-version: ${{ matrix.node }}
|
|
32
|
-
- name: Setup NodeJS ${{ matrix.node }}
|
|
33
|
-
uses: actions/setup-node@v4
|
|
34
|
-
with:
|
|
35
|
-
node-version: ${{ matrix.node }}
|
|
27
|
+
node-version: 24
|
|
36
28
|
cache: "pnpm"
|
|
37
29
|
cache-dependency-path: "**/pnpm-lock.yaml"
|
|
38
30
|
- name: Install dependencies
|
|
@@ -45,4 +37,3 @@ jobs:
|
|
|
45
37
|
run: pnpm semantic-release
|
|
46
38
|
env:
|
|
47
39
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
48
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/README.md
CHANGED
|
@@ -21,12 +21,29 @@ npm install mcp-proxy
|
|
|
21
21
|
|
|
22
22
|
### Command-line
|
|
23
23
|
|
|
24
|
+
MCP Proxy supports two invocation patterns:
|
|
25
|
+
|
|
26
|
+
**Simple usage (no mcp-proxy options):**
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx mcp-proxy npx -y @anthropic/mcp-server-filesystem /path
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**With mcp-proxy options:**
|
|
33
|
+
|
|
24
34
|
```bash
|
|
25
|
-
npx mcp-proxy --port 8080 --shell tsx server.js
|
|
35
|
+
npx mcp-proxy --port 8080 --shell -- tsx server.js
|
|
26
36
|
```
|
|
27
37
|
|
|
28
38
|
This starts a server and `stdio` server (`tsx server.js`). The server listens on port 8080 and `/mcp` (streamable HTTP) and `/sse` (SSE) endpoints, and forwards messages to the `stdio` server.
|
|
29
39
|
|
|
40
|
+
> [!NOTE]
|
|
41
|
+
> **About the `--` separator:**
|
|
42
|
+
> - The `--` separator is **optional** when you don't need to pass options to mcp-proxy
|
|
43
|
+
> - Use `--` when you need to pass options to mcp-proxy (like `--port`, `--shell`, etc.) to clearly separate them from the command
|
|
44
|
+
> - Without `--`, the first positional argument is treated as the command, and all subsequent arguments are passed to that command
|
|
45
|
+
> - The `--` separator is also useful when the command itself has flags that might conflict with mcp-proxy options
|
|
46
|
+
|
|
30
47
|
options:
|
|
31
48
|
|
|
32
49
|
- `--server`: Set to `sse` or `stream` to only enable the respective transport (default: both)
|
|
@@ -39,20 +56,9 @@ options:
|
|
|
39
56
|
- `--debug`: Enable debug logging
|
|
40
57
|
- `--shell`: Spawn the server via the user's shell
|
|
41
58
|
- `--apiKey`: API key for authenticating requests (uses X-API-Key header)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
When wrapping a command that takes arguments starting with `-`, you must use `--` to prevent `mcp-proxy` from interpreting them as its own options. Everything after `--` is passed directly to the wrapped command.
|
|
46
|
-
|
|
47
|
-
For example, to wrap a command that uses the `-v` flag:
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
# Wrong: mcp-proxy will try to parse -v as its own option
|
|
51
|
-
npx mcp-proxy --port 8080 my-command -v
|
|
52
|
-
|
|
53
|
-
# Correct: use -- to pass -v to my-command
|
|
54
|
-
npx mcp-proxy --port 8080 -- my-command -v
|
|
55
|
-
```
|
|
59
|
+
- `--sslCa`: Filename to override the trusted CA certificates
|
|
60
|
+
- `--sslCert`: Cert chains filename in PEM format
|
|
61
|
+
- `--sslKey`: Private keys filename in PEM format
|
|
56
62
|
|
|
57
63
|
### Stateless Mode
|
|
58
64
|
|
|
@@ -68,10 +74,10 @@ Example usage:
|
|
|
68
74
|
|
|
69
75
|
```bash
|
|
70
76
|
# Enable stateless mode
|
|
71
|
-
npx mcp-proxy --port 8080 --stateless tsx server.js
|
|
77
|
+
npx mcp-proxy --port 8080 --stateless -- tsx server.js
|
|
72
78
|
|
|
73
79
|
# Stateless mode with stream-only transport
|
|
74
|
-
npx mcp-proxy --port 8080 --stateless --server stream tsx server.js
|
|
80
|
+
npx mcp-proxy --port 8080 --stateless --server stream -- tsx server.js
|
|
75
81
|
```
|
|
76
82
|
|
|
77
83
|
> [!NOTE]
|
|
@@ -96,14 +102,14 @@ Authentication is disabled by default for backward compatibility. To enable it,
|
|
|
96
102
|
**Command-line:**
|
|
97
103
|
|
|
98
104
|
```bash
|
|
99
|
-
npx mcp-proxy --port 8080 --apiKey "your-secret-key" tsx server.js
|
|
105
|
+
npx mcp-proxy --port 8080 --apiKey "your-secret-key" -- tsx server.js
|
|
100
106
|
```
|
|
101
107
|
|
|
102
108
|
**Environment variable:**
|
|
103
109
|
|
|
104
110
|
```bash
|
|
105
111
|
export MCP_PROXY_API_KEY="your-secret-key"
|
|
106
|
-
npx mcp-proxy --port 8080 tsx server.js
|
|
112
|
+
npx mcp-proxy --port 8080 -- tsx server.js
|
|
107
113
|
```
|
|
108
114
|
|
|
109
115
|
#### Client Configuration
|
|
@@ -401,5 +407,5 @@ const transport = tapTransport(new StdioClientTransport(), (event) => {
|
|
|
401
407
|
### Running MCP Proxy with a local server
|
|
402
408
|
|
|
403
409
|
```bash
|
|
404
|
-
tsx src/bin/mcp-proxy.ts --debug tsx src/fixtures/simple-stdio-server.ts
|
|
410
|
+
tsx src/bin/mcp-proxy.ts --debug -- tsx src/fixtures/simple-stdio-server.ts
|
|
405
411
|
```
|
package/dist/bin/mcp-proxy.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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-BArgKxoc.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";
|
|
6
|
+
import { readFileSync, readdirSync, statSync, writeFile } from "fs";
|
|
6
7
|
import { setTimeout as setTimeout$1 } from "node:timers";
|
|
7
8
|
import util from "node:util";
|
|
8
9
|
import { notStrictEqual, strictEqual } from "assert";
|
|
9
|
-
import { readFileSync, readdirSync, statSync, writeFile } from "fs";
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
import { readFileSync as readFileSync$1, readdirSync as readdirSync$1 } from "node:fs";
|
|
12
12
|
import { spawn } from "node:child_process";
|
|
@@ -5012,15 +5012,14 @@ var StdioClientTransport = class {
|
|
|
5012
5012
|
//#region src/bin/mcp-proxy.ts
|
|
5013
5013
|
util.inspect.defaultOptions.depth = 8;
|
|
5014
5014
|
if (!("EventSource" in global)) global.EventSource = EventSource;
|
|
5015
|
-
const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").command("$0
|
|
5016
|
-
demandOption: true,
|
|
5015
|
+
const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").command("$0 [command] [args...]", "Proxy an MCP stdio server over HTTP").positional("command", {
|
|
5017
5016
|
describe: "The command to run",
|
|
5018
5017
|
type: "string"
|
|
5019
5018
|
}).positional("args", {
|
|
5020
5019
|
array: true,
|
|
5021
5020
|
describe: "The arguments to pass to the command",
|
|
5022
5021
|
type: "string"
|
|
5023
|
-
}).env("MCP_PROXY").parserConfiguration({ "populate--": true }).options({
|
|
5022
|
+
}).usage("$0 [options] -- <command> [args...]\n $0 <command> [args...]").env("MCP_PROXY").parserConfiguration({ "populate--": true }).options({
|
|
5024
5023
|
apiKey: {
|
|
5025
5024
|
describe: "API key for authenticating requests (uses X-API-Key header)",
|
|
5026
5025
|
type: "string"
|
|
@@ -5069,6 +5068,18 @@ const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").
|
|
|
5069
5068
|
describe: "The SSE endpoint to listen on",
|
|
5070
5069
|
type: "string"
|
|
5071
5070
|
},
|
|
5071
|
+
sslCa: {
|
|
5072
|
+
describe: "Filename to override the trusted CA certificates",
|
|
5073
|
+
type: "string"
|
|
5074
|
+
},
|
|
5075
|
+
sslCert: {
|
|
5076
|
+
describe: "Cert chains filename in PEM format",
|
|
5077
|
+
type: "string"
|
|
5078
|
+
},
|
|
5079
|
+
sslKey: {
|
|
5080
|
+
describe: "Private keys filename in PEM format",
|
|
5081
|
+
type: "string"
|
|
5082
|
+
},
|
|
5072
5083
|
stateless: {
|
|
5073
5084
|
default: false,
|
|
5074
5085
|
describe: "Enable stateless mode for HTTP streamable transport (no session management)",
|
|
@@ -5080,9 +5091,23 @@ const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").
|
|
|
5080
5091
|
type: "string"
|
|
5081
5092
|
}
|
|
5082
5093
|
}).help().parseAsync();
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5094
|
+
const dashDashArgs = argv["--"];
|
|
5095
|
+
let finalCommand;
|
|
5096
|
+
let finalArgs;
|
|
5097
|
+
if (dashDashArgs && dashDashArgs.length > 0) [finalCommand, ...finalArgs] = dashDashArgs;
|
|
5098
|
+
else if (argv.command) {
|
|
5099
|
+
finalCommand = argv.command;
|
|
5100
|
+
finalArgs = argv.args || [];
|
|
5101
|
+
} else {
|
|
5102
|
+
console.error("Error: No command specified.");
|
|
5103
|
+
console.error("Usage: mcp-proxy [options] -- <command> [args...]");
|
|
5104
|
+
console.error(" or: mcp-proxy <command> [args...]");
|
|
5105
|
+
console.error("");
|
|
5106
|
+
console.error("Examples:");
|
|
5107
|
+
console.error(" mcp-proxy --port 8080 -- node server.js --port 3000");
|
|
5108
|
+
console.error(" mcp-proxy node server.js");
|
|
5109
|
+
process.exit(1);
|
|
5110
|
+
}
|
|
5086
5111
|
const connect = async (client) => {
|
|
5087
5112
|
const transport = new StdioClientTransport({
|
|
5088
5113
|
args: finalArgs,
|
|
@@ -5122,6 +5147,9 @@ const proxy = async () => {
|
|
|
5122
5147
|
host: argv.host,
|
|
5123
5148
|
port: argv.port,
|
|
5124
5149
|
sseEndpoint: argv.server && argv.server !== "sse" ? null : argv.sseEndpoint ?? argv.endpoint,
|
|
5150
|
+
sslCa: argv.sslCa,
|
|
5151
|
+
sslCert: argv.sslCert,
|
|
5152
|
+
sslKey: argv.sslKey,
|
|
5125
5153
|
stateless: argv.stateless,
|
|
5126
5154
|
streamEndpoint: argv.server && argv.server !== "stream" ? null : argv.streamEndpoint ?? argv.endpoint
|
|
5127
5155
|
});
|