mr-magic-mcp-server 0.1.21 → 0.1.23
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/.env.example +1 -0
- package/README.md +20 -0
- package/package.json +1 -1
- package/src/transport/mcp-http-server.js +9 -1
package/.env.example
CHANGED
|
@@ -119,6 +119,7 @@ MR_MAGIC_TOOL_ARG_CHUNK_SIZE=400 # Chunk size in chars (only used when LOG_TOOL
|
|
|
119
119
|
# Streamable HTTP MCP transport diagnostics
|
|
120
120
|
MR_MAGIC_MCP_HTTP_DIAGNOSTICS=0 # Set to 1 to log enriched request diagnostics at transport ingress
|
|
121
121
|
MR_MAGIC_ALLOWED_HOSTS= # Optional. Comma-separated extra allowed hostnames for DNS rebinding protection when binding to 0.0.0.0 (e.g. custom domains). RENDER_EXTERNAL_HOSTNAME is auto-included on Render.
|
|
122
|
+
MR_MAGIC_SESSIONLESS=0 # Set to 1 to force sessionless mode (each request handled by a fresh server/transport, no in-memory session). Auto-enabled on Render. Set manually on ECS, Fly.io, Railway, etc.
|
|
122
123
|
|
|
123
124
|
# SDK repro harness verbose HTTP logging
|
|
124
125
|
MR_MAGIC_SDK_REPRO_HTTP_DEBUG=0 # Set to 1 for verbose HTTP previews in the SDK repro harness script
|
package/README.md
CHANGED
|
@@ -103,6 +103,7 @@ grouped below by purpose.
|
|
|
103
103
|
| `MR_MAGIC_ROOT` | _(project root)_ | Override the project root used for `.env` and `.cache` path resolution. |
|
|
104
104
|
| `MR_MAGIC_ENV_PATH` | _(auto)_ | Point to a specific `.env` file instead of `<project root>/.env`. |
|
|
105
105
|
| `MR_MAGIC_ALLOWED_HOSTS` | _(empty)_ | Comma-separated extra hostnames allowed for DNS rebinding protection when binding to `0.0.0.0`. `RENDER_EXTERNAL_HOSTNAME` is included automatically on Render. Only needed for custom domains. |
|
|
106
|
+
| `MR_MAGIC_SESSIONLESS` | `0` | Set to `1` to force **sessionless mode** on the MCP Streamable HTTP server — each request is handled by a fresh, temporary server/transport with no in-memory session state. Auto-enabled on Render (see below). |
|
|
106
107
|
|
|
107
108
|
### Genius credentials
|
|
108
109
|
|
|
@@ -315,6 +316,25 @@ Recommended Render service settings:
|
|
|
315
316
|
> your Render environment so the DNS rebinding protection accepts requests with
|
|
316
317
|
> those `Host` headers.
|
|
317
318
|
|
|
319
|
+
#### Sessionless mode on Render (automatic)
|
|
320
|
+
|
|
321
|
+
When `RENDER=true` is detected, the MCP Streamable HTTP server automatically operates
|
|
322
|
+
in **sessionless mode**. This is essential for multi-instance deployments where Render
|
|
323
|
+
routes requests across several processes:
|
|
324
|
+
|
|
325
|
+
- An `initialize` request served by **Instance A** would store the session in A's
|
|
326
|
+
in-memory `Map`. A follow-up `tools/list` call routed to **Instance B** cannot
|
|
327
|
+
find that session and returns `{"error": "Session not found. …"}`.
|
|
328
|
+
- In sessionless mode, every request — `initialize`, `tools/list`, `tools/call`, etc.
|
|
329
|
+
— is handled by a fresh, short-lived `Server + StreamableHTTPServerTransport` pair.
|
|
330
|
+
No `Mcp-Session-Id` header is issued and no session state is stored. Each request
|
|
331
|
+
is fully self-contained and works correctly regardless of which instance handles it.
|
|
332
|
+
|
|
333
|
+
You do **not** need to set `MR_MAGIC_SESSIONLESS=1` manually on Render — it is
|
|
334
|
+
auto-enabled via the platform-injected `RENDER` env var. Set `MR_MAGIC_SESSIONLESS=1`
|
|
335
|
+
explicitly on other multi-instance platforms (ECS, Fly.io, Railway, etc.) where
|
|
336
|
+
a similar load-balanced, stateless deployment is used.
|
|
337
|
+
|
|
318
338
|
### Transport selection
|
|
319
339
|
|
|
320
340
|
| Transport | Command | Use case |
|
package/package.json
CHANGED
|
@@ -87,7 +87,15 @@ function createMcpServer() {
|
|
|
87
87
|
export async function startMcpHttpServer(options = {}) {
|
|
88
88
|
const logger = createLogger('mcp-http-server');
|
|
89
89
|
const httpDiagnostics = process.env.MR_MAGIC_MCP_HTTP_DIAGNOSTICS === '1';
|
|
90
|
-
|
|
90
|
+
// Sessionless mode: skip persistent in-memory session tracking so every
|
|
91
|
+
// request is handled independently. This is required on platforms like
|
|
92
|
+
// Render.com that run multiple instances (a session created on instance A is
|
|
93
|
+
// invisible to instance B). Auto-enable when the RENDER env var is present,
|
|
94
|
+
// or when MR_MAGIC_SESSIONLESS=1 is set explicitly.
|
|
95
|
+
const configuredSessionless =
|
|
96
|
+
Boolean(options.sessionless) ||
|
|
97
|
+
Boolean(process.env.MR_MAGIC_SESSIONLESS) ||
|
|
98
|
+
Boolean(process.env.RENDER);
|
|
91
99
|
const host = options.remote
|
|
92
100
|
? '0.0.0.0'
|
|
93
101
|
: options.host || process.env.HOST || (process.env.RENDER ? '0.0.0.0' : '127.0.0.1');
|