@zenrows/mcp 2.0.5 → 2.0.6
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/dist/http.js +1 -12
- package/package.json +1 -1
package/dist/http.js
CHANGED
|
@@ -5,9 +5,6 @@ import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/
|
|
|
5
5
|
import { createServer } from "./server.js";
|
|
6
6
|
// ─── app ──────────────────────────────────────────────────────────────────────
|
|
7
7
|
const app = new Hono();
|
|
8
|
-
// Cache MCP client name per API key across invocations.
|
|
9
|
-
// Populated from the clientInfo field in MCP initialize requests.
|
|
10
|
-
const mcpClientCache = new Map();
|
|
11
8
|
// CORS — required for browser-side MCP clients (Claude.ai, Cursor web, etc.)
|
|
12
9
|
// All origins allowed: the API key is the auth mechanism, not the origin.
|
|
13
10
|
app.use(cors({
|
|
@@ -96,17 +93,9 @@ app.all("/mcp", async (c) => {
|
|
|
96
93
|
sessionIdGenerator: undefined, // stateless — no session tracking between requests
|
|
97
94
|
enableJsonResponse: true, // return JSON instead of SSE (simpler for Lambda + most MCP clients)
|
|
98
95
|
});
|
|
99
|
-
|
|
100
|
-
// creates a new server per request, so getClientVersion() is only set during
|
|
101
|
-
// the initialize request itself, not during subsequent tool calls).
|
|
102
|
-
const server = createServer(apiKey, mcpClientCache.get(apiKey));
|
|
96
|
+
const server = createServer(apiKey, c.req.raw.headers.get("user-agent") ?? undefined);
|
|
103
97
|
await server.connect(transport);
|
|
104
98
|
const response = await transport.handleRequest(c.req.raw);
|
|
105
|
-
// If this was an initialize request, getClientVersion() is now set — cache it
|
|
106
|
-
// so subsequent tool call requests can include x-mcp-client-name.
|
|
107
|
-
const resolvedName = server.server.getClientVersion()?.name;
|
|
108
|
-
if (resolvedName)
|
|
109
|
-
mcpClientCache.set(apiKey, resolvedName);
|
|
110
99
|
await transport.close();
|
|
111
100
|
return response;
|
|
112
101
|
});
|