mcp-proxy 6.5.3 → 6.5.5
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 +23 -2
- package/dist/bin/mcp-proxy.mjs +17 -2
- package/dist/bin/mcp-proxy.mjs.map +1 -1
- package/dist/index.d.mts +41 -2
- package/dist/index.mjs +1 -1
- package/dist/{stdio-DNR9B0BZ.mjs → stdio-Be0Fx2iV.mjs} +99 -5
- package/dist/stdio-Be0Fx2iV.mjs.map +1 -0
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/InMemoryEventStore.test.ts +96 -0
- package/src/InMemoryEventStore.ts +51 -0
- package/src/bin/mcp-proxy.ts +21 -2
- package/src/index.ts +2 -1
- package/src/startHTTPServer.test.ts +205 -0
- package/src/startHTTPServer.ts +145 -10
- package/dist/stdio-DNR9B0BZ.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ options:
|
|
|
55
55
|
- `--connectionTimeout`: Timeout in milliseconds for the initial connection to the MCP server (default: 60000, which is 60 seconds)
|
|
56
56
|
- `--requestTimeout`: Timeout in milliseconds for requests to the MCP server (default: 300000, which is 5 minutes)
|
|
57
57
|
- `--keepAliveTimeout`: HTTP keep-alive timeout in milliseconds for stateful stream sessions (default: 300000, which is 5 minutes)
|
|
58
|
+
- `--eventStore`: Enable the streamable HTTP transport's resumability event store, which lets clients replay missed messages after a reconnect (default: `true`). Use `--no-eventStore` to disable it entirely for request/response-only deployments that don't need replay and would rather avoid the memory overhead. See [Resumability and memory use](#resumability-and-memory-use).
|
|
59
|
+
- `--eventStoreMaxEvents`: Maximum number of buffered events the resumability event store retains per session before it evicts the oldest (default: 1000). Ignored when `--no-eventStore` is set.
|
|
58
60
|
- `--debug`: Enable debug logging
|
|
59
61
|
- `--shell`: Spawn the server via the user's shell
|
|
60
62
|
- `--apiKey`: API key for authenticating requests (uses X-API-Key header)
|
|
@@ -417,7 +419,6 @@ const { close } = await startHTTPServer({
|
|
|
417
419
|
createServer: async () => {
|
|
418
420
|
return new Server();
|
|
419
421
|
},
|
|
420
|
-
eventStore: new InMemoryEventStore(),
|
|
421
422
|
port: 8080,
|
|
422
423
|
stateless: false, // Optional: enable stateless mode for streamable HTTP transport
|
|
423
424
|
});
|
|
@@ -428,7 +429,8 @@ close();
|
|
|
428
429
|
Options:
|
|
429
430
|
|
|
430
431
|
- `createServer`: Function that creates a new server instance for each connection
|
|
431
|
-
- `eventStore`: Event store for streamable HTTP transport (optional)
|
|
432
|
+
- `eventStore`: Event store for the streamable HTTP transport's resumability support (optional). Pass `false` to disable resumability entirely; omit to get a fresh, bounded `InMemoryEventStore` per session (see `eventStoreMaxEvents`); pass an `EventStore` instance to bring your own (e.g. persistent/cross-process), shared across all sessions. See [Resumability and memory use](#resumability-and-memory-use).
|
|
433
|
+
- `eventStoreMaxEvents`: Caps how many events the auto-created per-session `InMemoryEventStore` retains before evicting the oldest (default: 1000). Only applies when `eventStore` is not explicitly provided.
|
|
432
434
|
- `port`: Port number to listen on
|
|
433
435
|
- `host`: Host to bind to (default: "::")
|
|
434
436
|
- `keepAliveTimeout`: HTTP keep-alive timeout in milliseconds for stateful stream sessions (default: 300000)
|
|
@@ -441,6 +443,25 @@ Options:
|
|
|
441
443
|
- `onClose`: Callback when a server disconnects (optional)
|
|
442
444
|
- `onUnhandledRequest`: Callback for unhandled HTTP requests (optional)
|
|
443
445
|
|
|
446
|
+
##### Resumability and memory use
|
|
447
|
+
|
|
448
|
+
The streamable HTTP transport can retain server→client messages so a client
|
|
449
|
+
that reconnects with a `Last-Event-ID` can resume where it left off. By
|
|
450
|
+
default, `mcp-proxy` gives each session its own `InMemoryEventStore` capped at
|
|
451
|
+
1000 buffered events (oldest evicted first via `--eventStoreMaxEvents` /
|
|
452
|
+
`eventStoreMaxEvents`), so a long-lived session's memory use stays bounded
|
|
453
|
+
instead of growing for as long as the process runs.
|
|
454
|
+
|
|
455
|
+
If you don't need resume-after-reconnect - for example, a short-lived
|
|
456
|
+
request/response deployment - disable the store entirely with
|
|
457
|
+
`--no-eventStore` (CLI) or `eventStore: false` (library) to drop the
|
|
458
|
+
resumability bookkeeping altogether.
|
|
459
|
+
|
|
460
|
+
If you need resumability with a larger replay window or one backed by shared
|
|
461
|
+
storage (e.g. Redis) across multiple proxy processes, pass your own
|
|
462
|
+
`EventStore` implementation as `eventStore`; in that case you're responsible
|
|
463
|
+
for bounding its size.
|
|
464
|
+
|
|
444
465
|
#### `startStdioServer`
|
|
445
466
|
|
|
446
467
|
Starts a proxy that listens on a `stdio`, and sends messages to the attached `sse` or `streamable` server.
|
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
|
|
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 } from "../stdio-Be0Fx2iV.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";
|
|
@@ -5067,6 +5067,16 @@ const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").
|
|
|
5067
5067
|
describe: "The endpoint to listen on",
|
|
5068
5068
|
type: "string"
|
|
5069
5069
|
},
|
|
5070
|
+
eventStore: {
|
|
5071
|
+
default: true,
|
|
5072
|
+
describe: "Enable the streamable HTTP transport's resumability event store, which lets clients replay missed messages after a reconnect. Use --no-eventStore to disable it entirely for request/response-only deployments that don't need this and would rather avoid the memory overhead",
|
|
5073
|
+
type: "boolean"
|
|
5074
|
+
},
|
|
5075
|
+
eventStoreMaxEvents: {
|
|
5076
|
+
default: 1e3,
|
|
5077
|
+
describe: "Maximum number of buffered events the resumability event store retains (per session) before it evicts the oldest; bounds memory use. Ignored when --no-eventStore is set",
|
|
5078
|
+
type: "number"
|
|
5079
|
+
},
|
|
5070
5080
|
gracefulShutdownTimeout: {
|
|
5071
5081
|
default: 5e3,
|
|
5072
5082
|
describe: "The timeout (in milliseconds) for graceful shutdown",
|
|
@@ -5139,6 +5149,10 @@ const argv = await yargs_default(hideBin(process.argv)).scriptName("mcp-proxy").
|
|
|
5139
5149
|
type: "string"
|
|
5140
5150
|
}
|
|
5141
5151
|
}).help().parseAsync();
|
|
5152
|
+
if (!(argv.eventStoreMaxEvents >= 1)) {
|
|
5153
|
+
console.error(`Error: --eventStoreMaxEvents must be a number >= 1 (got ${String(argv.eventStoreMaxEvents)}). Use --no-eventStore to disable the event store instead.`);
|
|
5154
|
+
process.exit(1);
|
|
5155
|
+
}
|
|
5142
5156
|
const corsOption = argv.corsAddAllowedHeader && argv.corsAddAllowedHeader.length > 0 ? { allowedHeaders: [...[
|
|
5143
5157
|
"Content-Type",
|
|
5144
5158
|
"Authorization",
|
|
@@ -5200,7 +5214,8 @@ const proxy = async () => {
|
|
|
5200
5214
|
apiKey: argv.apiKey,
|
|
5201
5215
|
cors: corsOption,
|
|
5202
5216
|
createServer,
|
|
5203
|
-
eventStore:
|
|
5217
|
+
eventStore: argv.eventStore ? void 0 : false,
|
|
5218
|
+
eventStoreMaxEvents: argv.eventStoreMaxEvents,
|
|
5204
5219
|
host: argv.host,
|
|
5205
5220
|
keepAliveTimeout: argv.keepAliveTimeout,
|
|
5206
5221
|
port: argv.port,
|