mcp-proxy 5.12.5 → 6.1.8
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 +12 -20
- package/dist/bin/mcp-proxy.mjs +27 -14
- 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 +25 -19
- 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
|
@@ -22,11 +22,14 @@ npm install mcp-proxy
|
|
|
22
22
|
### Command-line
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
npx mcp-proxy --port 8080 --shell tsx server.js
|
|
25
|
+
npx mcp-proxy --port 8080 --shell -- tsx server.js
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
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
29
|
|
|
30
|
+
> [!NOTE]
|
|
31
|
+
> The `--` separator is required to separate mcp-proxy options from the command being proxied.
|
|
32
|
+
|
|
30
33
|
options:
|
|
31
34
|
|
|
32
35
|
- `--server`: Set to `sse` or `stream` to only enable the respective transport (default: both)
|
|
@@ -39,20 +42,9 @@ options:
|
|
|
39
42
|
- `--debug`: Enable debug logging
|
|
40
43
|
- `--shell`: Spawn the server via the user's shell
|
|
41
44
|
- `--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
|
-
```
|
|
45
|
+
- `--sslCa`: Filename to override the trusted CA certificates
|
|
46
|
+
- `--sslCert`: Cert chains filename in PEM format
|
|
47
|
+
- `--sslKey`: Private keys filename in PEM format
|
|
56
48
|
|
|
57
49
|
### Stateless Mode
|
|
58
50
|
|
|
@@ -68,10 +60,10 @@ Example usage:
|
|
|
68
60
|
|
|
69
61
|
```bash
|
|
70
62
|
# Enable stateless mode
|
|
71
|
-
npx mcp-proxy --port 8080 --stateless tsx server.js
|
|
63
|
+
npx mcp-proxy --port 8080 --stateless -- tsx server.js
|
|
72
64
|
|
|
73
65
|
# Stateless mode with stream-only transport
|
|
74
|
-
npx mcp-proxy --port 8080 --stateless --server stream tsx server.js
|
|
66
|
+
npx mcp-proxy --port 8080 --stateless --server stream -- tsx server.js
|
|
75
67
|
```
|
|
76
68
|
|
|
77
69
|
> [!NOTE]
|
|
@@ -96,14 +88,14 @@ Authentication is disabled by default for backward compatibility. To enable it,
|
|
|
96
88
|
**Command-line:**
|
|
97
89
|
|
|
98
90
|
```bash
|
|
99
|
-
npx mcp-proxy --port 8080 --apiKey "your-secret-key" tsx server.js
|
|
91
|
+
npx mcp-proxy --port 8080 --apiKey "your-secret-key" -- tsx server.js
|
|
100
92
|
```
|
|
101
93
|
|
|
102
94
|
**Environment variable:**
|
|
103
95
|
|
|
104
96
|
```bash
|
|
105
97
|
export MCP_PROXY_API_KEY="your-secret-key"
|
|
106
|
-
npx mcp-proxy --port 8080 tsx server.js
|
|
98
|
+
npx mcp-proxy --port 8080 -- tsx server.js
|
|
107
99
|
```
|
|
108
100
|
|
|
109
101
|
#### Client Configuration
|
|
@@ -401,5 +393,5 @@ const transport = tapTransport(new StdioClientTransport(), (event) => {
|
|
|
401
393
|
### Running MCP Proxy with a local server
|
|
402
394
|
|
|
403
395
|
```bash
|
|
404
|
-
tsx src/bin/mcp-proxy.ts --debug tsx src/fixtures/simple-stdio-server.ts
|
|
396
|
+
tsx src/bin/mcp-proxy.ts --debug -- tsx src/fixtures/simple-stdio-server.ts
|
|
405
397
|
```
|
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,7 @@ 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").
|
|
5016
|
-
demandOption: true,
|
|
5017
|
-
describe: "The command to run",
|
|
5018
|
-
type: "string"
|
|
5019
|
-
}).positional("args", {
|
|
5020
|
-
array: true,
|
|
5021
|
-
describe: "The arguments to pass to the command",
|
|
5022
|
-
type: "string"
|
|
5023
|
-
}).env("MCP_PROXY").parserConfiguration({ "populate--": true }).options({
|
|
5015
|
+
const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").usage("$0 [options] -- <command> [args...]").env("MCP_PROXY").parserConfiguration({ "populate--": true }).options({
|
|
5024
5016
|
apiKey: {
|
|
5025
5017
|
describe: "API key for authenticating requests (uses X-API-Key header)",
|
|
5026
5018
|
type: "string"
|
|
@@ -5069,6 +5061,18 @@ const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").
|
|
|
5069
5061
|
describe: "The SSE endpoint to listen on",
|
|
5070
5062
|
type: "string"
|
|
5071
5063
|
},
|
|
5064
|
+
sslCa: {
|
|
5065
|
+
describe: "Filename to override the trusted CA certificates",
|
|
5066
|
+
type: "string"
|
|
5067
|
+
},
|
|
5068
|
+
sslCert: {
|
|
5069
|
+
describe: "Cert chains filename in PEM format",
|
|
5070
|
+
type: "string"
|
|
5071
|
+
},
|
|
5072
|
+
sslKey: {
|
|
5073
|
+
describe: "Private keys filename in PEM format",
|
|
5074
|
+
type: "string"
|
|
5075
|
+
},
|
|
5072
5076
|
stateless: {
|
|
5073
5077
|
default: false,
|
|
5074
5078
|
describe: "Enable stateless mode for HTTP streamable transport (no session management)",
|
|
@@ -5080,9 +5084,15 @@ const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").
|
|
|
5080
5084
|
type: "string"
|
|
5081
5085
|
}
|
|
5082
5086
|
}).help().parseAsync();
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5087
|
+
const dashDashArgs = argv["--"];
|
|
5088
|
+
if (!dashDashArgs || dashDashArgs.length === 0) {
|
|
5089
|
+
console.error("Error: No command specified.");
|
|
5090
|
+
console.error("Usage: mcp-proxy [options] -- <command> [args...]");
|
|
5091
|
+
console.error("");
|
|
5092
|
+
console.error("Example: mcp-proxy --port 8080 -- node server.js --port 3000");
|
|
5093
|
+
process.exit(1);
|
|
5094
|
+
}
|
|
5095
|
+
const [finalCommand, ...finalArgs] = dashDashArgs;
|
|
5086
5096
|
const connect = async (client) => {
|
|
5087
5097
|
const transport = new StdioClientTransport({
|
|
5088
5098
|
args: finalArgs,
|
|
@@ -5122,6 +5132,9 @@ const proxy = async () => {
|
|
|
5122
5132
|
host: argv.host,
|
|
5123
5133
|
port: argv.port,
|
|
5124
5134
|
sseEndpoint: argv.server && argv.server !== "sse" ? null : argv.sseEndpoint ?? argv.endpoint,
|
|
5135
|
+
sslCa: argv.sslCa,
|
|
5136
|
+
sslCert: argv.sslCert,
|
|
5137
|
+
sslKey: argv.sslKey,
|
|
5125
5138
|
stateless: argv.stateless,
|
|
5126
5139
|
streamEndpoint: argv.server && argv.server !== "stream" ? null : argv.streamEndpoint ?? argv.endpoint
|
|
5127
5140
|
});
|