@acid-cat/mcp-handshake 0.19.0 → 0.21.0
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/index.d.ts +3 -3
- package/dist/index.js +29 -1
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export type WebHandler = (request: Request) => Promise<Response>;
|
|
2
2
|
export interface McpHandshakeOptions {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/** The maximum size of a request body, in bytes. Give the limit of the wrapped handler. The default is 1 MiB. */
|
|
4
|
+
readonly maximumBytes?: number | undefined;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* A web handler that serves the `initialize` handshake of revisions 2025-11-25 and 2025-06-18, and gives all other
|
|
8
8
|
* requests to `handler`. It adds these revisions to the `supportedProtocolVersions` of the Server Card of `handler`
|
|
9
9
|
* (spec/surfaces/mcp.md#server-card).
|
|
10
10
|
*/
|
|
11
|
-
export declare function mcpHandshake(handler: WebHandler, options?: McpHandshakeOptions): WebHandler;
|
|
11
|
+
export declare function mcpHandshake(handler: WebHandler, options?: McpHandshakeOptions): WebHandler;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
import { MCP_EVENTS_EXTENSION, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_KEY, MCP_SERVER_CARD_MEDIA_TYPE, isJsonObject, mcpDiscovered, mcpParamHeaders, mcpServerCardResponse, mcpServerUrlOfCardRequest, mcpWrappedRequest
|
|
1
|
+
import { MCP_EVENTS_EXTENSION, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_KEY, MCP_SERVER_CARD_MEDIA_TYPE, isJsonObject, mcpDiscovered, mcpParamHeaders, mcpServerCardResponse, mcpServerUrlOfCardRequest, mcpWrappedRequest } from "@acid-cat/spec-ts";
|
|
2
|
+
// ../shared-ts/src/request-body.ts
|
|
3
|
+
async function readBounded(request, maximumBytes) {
|
|
4
|
+
if (request.body === null) return { text: "" };
|
|
5
|
+
const reader = request.body.getReader();
|
|
6
|
+
const chunks = [];
|
|
7
|
+
let length = 0;
|
|
8
|
+
for (;;) {
|
|
9
|
+
const { done, value } = await reader.read();
|
|
10
|
+
if (done) break;
|
|
11
|
+
length += value.byteLength;
|
|
12
|
+
if (length > maximumBytes) {
|
|
13
|
+
await reader.cancel().catch(() => void 0);
|
|
14
|
+
return { rejection: "too-large" };
|
|
15
|
+
}
|
|
16
|
+
chunks.push(value);
|
|
17
|
+
}
|
|
18
|
+
const bytes = new Uint8Array(length);
|
|
19
|
+
let offset = 0;
|
|
20
|
+
for (const chunk of chunks) {
|
|
21
|
+
bytes.set(chunk, offset);
|
|
22
|
+
offset += chunk.byteLength;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
return { text: new TextDecoder("utf-8", { fatal: true }).decode(bytes) };
|
|
26
|
+
} catch {
|
|
27
|
+
return { rejection: "not-utf8" };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
2
30
|
// src/index.ts
|
|
3
31
|
/** The `initialize` handshake of earlier MCP revisions through HTTP (spec/surfaces/mcp.md#earlier-revisions-through-http). */
|
|
4
32
|
const HANDSHAKE_VERSIONS = ["2025-11-25", "2025-06-18"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acid-cat/mcp-handshake",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Serve MCP clients of the revisions with an initialize handshake from an AcidCat MCP server through HTTP, with no state. Part of the TypeScript reference implementation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acidcat",
|
|
@@ -31,10 +31,12 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@acid-cat/spec-ts": "0.
|
|
34
|
+
"@acid-cat/spec-ts": "0.21.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
+
"@acid-cat/shared-ts": "0.21.0",
|
|
37
38
|
"@types/node": "26.6.6",
|
|
39
|
+
"tsdown": "0.23.7",
|
|
38
40
|
"typescript": "7.0.2"
|
|
39
41
|
}
|
|
40
42
|
}
|