@mcp-i/core 1.1.0 → 1.1.3
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 +79 -151
- package/dist/auth/handshake.d.ts +4 -19
- package/dist/auth/handshake.d.ts.map +1 -1
- package/dist/auth/handshake.js +15 -52
- package/dist/auth/handshake.js.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/delegation/did-key-resolver.d.ts.map +1 -1
- package/dist/delegation/did-key-resolver.js +6 -9
- package/dist/delegation/did-key-resolver.js.map +1 -1
- package/dist/delegation/outbound-headers.d.ts +4 -2
- package/dist/delegation/outbound-headers.d.ts.map +1 -1
- package/dist/delegation/outbound-headers.js +3 -2
- package/dist/delegation/outbound-headers.js.map +1 -1
- package/dist/delegation/statuslist-manager.d.ts.map +1 -1
- package/dist/delegation/statuslist-manager.js +1 -1
- package/dist/delegation/statuslist-manager.js.map +1 -1
- package/dist/delegation/vc-verifier.d.ts.map +1 -1
- package/dist/delegation/vc-verifier.js +2 -2
- package/dist/delegation/vc-verifier.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/middleware/index.d.ts +0 -1
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +0 -1
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/with-mcpi-server.d.ts +9 -25
- package/dist/middleware/with-mcpi-server.d.ts.map +1 -1
- package/dist/middleware/with-mcpi-server.js +47 -62
- package/dist/middleware/with-mcpi-server.js.map +1 -1
- package/dist/middleware/with-mcpi.d.ts +5 -26
- package/dist/middleware/with-mcpi.d.ts.map +1 -1
- package/dist/middleware/with-mcpi.js +10 -108
- package/dist/middleware/with-mcpi.js.map +1 -1
- package/dist/providers/memory.js +2 -2
- package/dist/providers/memory.js.map +1 -1
- package/dist/session/manager.d.ts +1 -7
- package/dist/session/manager.d.ts.map +1 -1
- package/dist/session/manager.js +4 -20
- package/dist/session/manager.js.map +1 -1
- package/dist/utils/crypto-service.d.ts.map +1 -1
- package/dist/utils/crypto-service.js +10 -11
- package/dist/utils/crypto-service.js.map +1 -1
- package/dist/utils/did-helpers.d.ts +0 -12
- package/dist/utils/did-helpers.d.ts.map +1 -1
- package/dist/utils/did-helpers.js +0 -18
- package/dist/utils/did-helpers.js.map +1 -1
- package/package.json +2 -1
- package/src/middleware/with-mcpi-server.ts +1 -5
- package/dist/errors.d.ts +0 -42
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -45
- package/dist/errors.js.map +0 -1
- package/dist/middleware/mcpi-transport.d.ts +0 -39
- package/dist/middleware/mcpi-transport.d.ts.map +0 -1
- package/dist/middleware/mcpi-transport.js +0 -121
- package/dist/middleware/mcpi-transport.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/did-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMvD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IACnC,QAAQ,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MA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BAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD;AAQD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,UAAU,GAAG,MAAM,CAW1E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAMxE"}
|
|
@@ -190,22 +190,4 @@ export function generateDidKeyFromBase64(publicKeyBase64) {
|
|
|
190
190
|
const publicKeyBytes = Uint8Array.from(atob(publicKeyBase64), (c) => c.charCodeAt(0));
|
|
191
191
|
return generateDidKeyFromBytes(publicKeyBytes);
|
|
192
192
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Get the spec-compliant fragment identifier for a did:key DID.
|
|
195
|
-
*
|
|
196
|
-
* Per the did:key spec (W3C CCG), the fragment equals the multibase-encoded
|
|
197
|
-
* public key value (the DID-specific-id). For example:
|
|
198
|
-
* did:key:z6MkABC... → z6MkABC...
|
|
199
|
-
*
|
|
200
|
-
* @see https://w3c-ccg.github.io/did-key-spec/#document-creation-algorithm
|
|
201
|
-
* @param did - A did:key DID string
|
|
202
|
-
* @returns The fragment identifier (multibase value), or 'keys-1' as fallback for non-did:key
|
|
203
|
-
*/
|
|
204
|
-
export function didKeyFragment(did) {
|
|
205
|
-
if (did.startsWith('did:key:')) {
|
|
206
|
-
return did.slice('did:key:'.length);
|
|
207
|
-
}
|
|
208
|
-
// Fallback for non-did:key methods
|
|
209
|
-
return 'keys-1';
|
|
210
|
-
}
|
|
211
193
|
//# sourceMappingURL=did-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-helpers.js","sourceRoot":"","sources":["../../src/utils/did-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAA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CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,uBAAuB,CAAC,cAA0B;IAChE,yCAAyC;IACzC,MAAM,aAAa,GAAG,IAAI,UAAU,CAClC,yBAAyB,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CACzD,CAAC;IACF,aAAa,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IAC7C,aAAa,CAAC,GAAG,CAAC,cAAc,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAEpE,iDAAiD;IACjD,MAAM,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IAClD,OAAO,YAAY,aAAa,EAAE,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,wBAAwB,CAAC,eAAuB;IAC9D,yBAAyB;IACzB,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAClE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAChB,CAAC;IACF,OAAO,uBAAuB,CAAC,cAAc,CAAC,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-i/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Core library for MCP-I — delegation, proof, and session primitives for Model Context Protocol Identity",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"typecheck": "tsc --noEmit",
|
|
59
59
|
"lint": "eslint src --ext .ts",
|
|
60
60
|
"clean": "rm -rf dist",
|
|
61
|
+
"demo": "bash scripts/demo.sh",
|
|
61
62
|
"example:server": "npx tsx examples/node-server/server.ts",
|
|
62
63
|
"example:inspector": "npx @modelcontextprotocol/inspector npx tsx examples/node-server/server.ts --stdio"
|
|
63
64
|
},
|
|
@@ -71,11 +71,7 @@ export async function generateIdentity(
|
|
|
71
71
|
*/
|
|
72
72
|
interface McpServerLike {
|
|
73
73
|
connect(transport: Transport): Promise<unknown>;
|
|
74
|
-
registerTool(
|
|
75
|
-
name: string,
|
|
76
|
-
config: Record<string, unknown>,
|
|
77
|
-
handler: (args: unknown) => Promise<unknown>,
|
|
78
|
-
): void;
|
|
74
|
+
registerTool(...args: unknown[]): void;
|
|
79
75
|
}
|
|
80
76
|
|
|
81
77
|
/**
|
package/dist/errors.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP-I Canonical Error Codes
|
|
3
|
-
*
|
|
4
|
-
* Single source of truth for all wire-format error codes.
|
|
5
|
-
* Aligned with the error catalog at modelcontextprotocol-identity.io.
|
|
6
|
-
*
|
|
7
|
-
* Naming convention: snake_case, no protocol prefix.
|
|
8
|
-
* Follows OAuth 2.0 / Stripe conventions for readability and portability.
|
|
9
|
-
*/
|
|
10
|
-
export declare const MCPI_ERROR_CODES: {
|
|
11
|
-
readonly invalid_proof: "invalid_proof";
|
|
12
|
-
readonly invalid_jws: "invalid_jws";
|
|
13
|
-
readonly nonce_replay: "nonce_replay";
|
|
14
|
-
readonly timestamp_skew: "timestamp_skew";
|
|
15
|
-
readonly did_not_found: "did_not_found";
|
|
16
|
-
readonly invalid_public_key: "invalid_public_key";
|
|
17
|
-
readonly handshake_failed: "handshake_failed";
|
|
18
|
-
readonly session_expired: "session_expired";
|
|
19
|
-
readonly invalid_request: "invalid_request";
|
|
20
|
-
readonly needs_authorization: "needs_authorization";
|
|
21
|
-
readonly insufficient_scope: "insufficient_scope";
|
|
22
|
-
readonly delegation_expired: "delegation_expired";
|
|
23
|
-
readonly delegation_not_yet_valid: "delegation_not_yet_valid";
|
|
24
|
-
readonly delegation_revoked: "delegation_revoked";
|
|
25
|
-
readonly delegation_invalid: "delegation_invalid";
|
|
26
|
-
readonly budget_exceeded: "budget_exceeded";
|
|
27
|
-
readonly rate_limit_exceeded: "rate_limit_exceeded";
|
|
28
|
-
readonly invalid_token: "invalid_token";
|
|
29
|
-
readonly token_expired: "token_expired";
|
|
30
|
-
readonly mirror_pending: "mirror_pending";
|
|
31
|
-
readonly claim_failed: "claim_failed";
|
|
32
|
-
readonly configuration_error: "configuration_error";
|
|
33
|
-
readonly runtime_error: "runtime_error";
|
|
34
|
-
};
|
|
35
|
-
export type MCPIErrorCode = (typeof MCPI_ERROR_CODES)[keyof typeof MCPI_ERROR_CODES];
|
|
36
|
-
export interface MCPIErrorResponse {
|
|
37
|
-
code: MCPIErrorCode;
|
|
38
|
-
message: string;
|
|
39
|
-
details?: Record<string, unknown>;
|
|
40
|
-
}
|
|
41
|
-
export declare function createMCPIError(code: MCPIErrorCode, message: string, details?: Record<string, unknown>): MCPIErrorResponse;
|
|
42
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;CAqCnB,CAAC;AAEX,MAAM,MAAM,aAAa,GACvB,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE3D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,iBAAiB,CAEnB"}
|
package/dist/errors.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP-I Canonical Error Codes
|
|
3
|
-
*
|
|
4
|
-
* Single source of truth for all wire-format error codes.
|
|
5
|
-
* Aligned with the error catalog at modelcontextprotocol-identity.io.
|
|
6
|
-
*
|
|
7
|
-
* Naming convention: snake_case, no protocol prefix.
|
|
8
|
-
* Follows OAuth 2.0 / Stripe conventions for readability and portability.
|
|
9
|
-
*/
|
|
10
|
-
export const MCPI_ERROR_CODES = {
|
|
11
|
-
// Proof errors
|
|
12
|
-
invalid_proof: "invalid_proof",
|
|
13
|
-
invalid_jws: "invalid_jws",
|
|
14
|
-
nonce_replay: "nonce_replay",
|
|
15
|
-
timestamp_skew: "timestamp_skew",
|
|
16
|
-
// Identity / DID errors
|
|
17
|
-
did_not_found: "did_not_found",
|
|
18
|
-
invalid_public_key: "invalid_public_key",
|
|
19
|
-
// Session / Handshake errors
|
|
20
|
-
handshake_failed: "handshake_failed",
|
|
21
|
-
session_expired: "session_expired",
|
|
22
|
-
invalid_request: "invalid_request",
|
|
23
|
-
// Delegation errors
|
|
24
|
-
needs_authorization: "needs_authorization",
|
|
25
|
-
insufficient_scope: "insufficient_scope",
|
|
26
|
-
delegation_expired: "delegation_expired",
|
|
27
|
-
delegation_not_yet_valid: "delegation_not_yet_valid",
|
|
28
|
-
delegation_revoked: "delegation_revoked",
|
|
29
|
-
delegation_invalid: "delegation_invalid",
|
|
30
|
-
budget_exceeded: "budget_exceeded",
|
|
31
|
-
rate_limit_exceeded: "rate_limit_exceeded",
|
|
32
|
-
// Token errors
|
|
33
|
-
invalid_token: "invalid_token",
|
|
34
|
-
token_expired: "token_expired",
|
|
35
|
-
// Registry errors
|
|
36
|
-
mirror_pending: "mirror_pending",
|
|
37
|
-
claim_failed: "claim_failed",
|
|
38
|
-
// System errors
|
|
39
|
-
configuration_error: "configuration_error",
|
|
40
|
-
runtime_error: "runtime_error",
|
|
41
|
-
};
|
|
42
|
-
export function createMCPIError(code, message, details) {
|
|
43
|
-
return details ? { code, message, details } : { code, message };
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,eAAe;IACf,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,cAAc,EAAE,gBAAgB;IAEhC,wBAAwB;IACxB,aAAa,EAAE,eAAe;IAC9B,kBAAkB,EAAE,oBAAoB;IAExC,6BAA6B;IAC7B,gBAAgB,EAAE,kBAAkB;IACpC,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;IAElC,oBAAoB;IACpB,mBAAmB,EAAE,qBAAqB;IAC1C,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;IACxC,wBAAwB,EAAE,0BAA0B;IACpD,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;IACxC,eAAe,EAAE,iBAAiB;IAClC,mBAAmB,EAAE,qBAAqB;IAE1C,eAAe;IACf,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,eAAe;IAE9B,kBAAkB;IAClB,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;IAE5B,gBAAgB;IAChB,mBAAmB,EAAE,qBAAqB;IAC1C,aAAa,EAAE,eAAe;CACtB,CAAC;AAWX,MAAM,UAAU,eAAe,CAC7B,IAAmB,EACnB,OAAe,EACf,OAAiC;IAEjC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCPITransport — Proof-injecting Transport Wrapper
|
|
3
|
-
*
|
|
4
|
-
* Wraps any MCP Transport to intercept `tools/call` responses and attach
|
|
5
|
-
* MCP-I detached proofs. Uses only the public Transport interface — no
|
|
6
|
-
* private SDK internals accessed.
|
|
7
|
-
*
|
|
8
|
-
* The McpServer never knows this wrapper exists. It sees a normal transport.
|
|
9
|
-
* The connected client sees normal MCP responses with an added `_meta.proof`.
|
|
10
|
-
*
|
|
11
|
-
* How it works:
|
|
12
|
-
* 1. Incoming `tools/call` requests are captured (by id) to record tool
|
|
13
|
-
* name and arguments for proof generation.
|
|
14
|
-
* 2. Outgoing responses for those ids get a proof injected into `_meta`.
|
|
15
|
-
* 3. All other message types pass through unmodified.
|
|
16
|
-
*
|
|
17
|
-
* @module mcpi-transport
|
|
18
|
-
*/
|
|
19
|
-
import type { MCPIMiddleware } from "./with-mcpi.js";
|
|
20
|
-
/** Minimal Transport interface — matches @modelcontextprotocol/sdk Transport */
|
|
21
|
-
export interface Transport {
|
|
22
|
-
start(): Promise<void>;
|
|
23
|
-
send(message: JSONRPCMessage): Promise<void>;
|
|
24
|
-
close(): Promise<void>;
|
|
25
|
-
onmessage?: (message: JSONRPCMessage) => void;
|
|
26
|
-
onclose?: () => void;
|
|
27
|
-
onerror?: (error: Error) => void;
|
|
28
|
-
}
|
|
29
|
-
export type JSONRPCMessage = Record<string, unknown>;
|
|
30
|
-
/**
|
|
31
|
-
* Creates a transport wrapper that injects MCP-I proofs into `tools/call`
|
|
32
|
-
* responses.
|
|
33
|
-
*
|
|
34
|
-
* @param inner - The real transport (Stdio, HTTP, etc.)
|
|
35
|
-
* @param mcpi - Configured MCPIMiddleware instance
|
|
36
|
-
* @param exclude - Tool names to skip proof generation for
|
|
37
|
-
*/
|
|
38
|
-
export declare function createMCPITransport(inner: Transport, mcpi: MCPIMiddleware, exclude?: string[]): Transport;
|
|
39
|
-
//# sourceMappingURL=mcpi-transport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcpi-transport.d.ts","sourceRoot":"","sources":["../../src/middleware/mcpi-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,gBAAgB,CAAC;AAGtE,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAarD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,cAAc,EACpB,OAAO,GAAE,MAAM,EAAiC,GAC/C,SAAS,CAwGX"}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCPITransport — Proof-injecting Transport Wrapper
|
|
3
|
-
*
|
|
4
|
-
* Wraps any MCP Transport to intercept `tools/call` responses and attach
|
|
5
|
-
* MCP-I detached proofs. Uses only the public Transport interface — no
|
|
6
|
-
* private SDK internals accessed.
|
|
7
|
-
*
|
|
8
|
-
* The McpServer never knows this wrapper exists. It sees a normal transport.
|
|
9
|
-
* The connected client sees normal MCP responses with an added `_meta.proof`.
|
|
10
|
-
*
|
|
11
|
-
* How it works:
|
|
12
|
-
* 1. Incoming `tools/call` requests are captured (by id) to record tool
|
|
13
|
-
* name and arguments for proof generation.
|
|
14
|
-
* 2. Outgoing responses for those ids get a proof injected into `_meta`.
|
|
15
|
-
* 3. All other message types pass through unmodified.
|
|
16
|
-
*
|
|
17
|
-
* @module mcpi-transport
|
|
18
|
-
*/
|
|
19
|
-
import { logger } from "../logging/index.js";
|
|
20
|
-
/**
|
|
21
|
-
* Creates a transport wrapper that injects MCP-I proofs into `tools/call`
|
|
22
|
-
* responses.
|
|
23
|
-
*
|
|
24
|
-
* @param inner - The real transport (Stdio, HTTP, etc.)
|
|
25
|
-
* @param mcpi - Configured MCPIMiddleware instance
|
|
26
|
-
* @param exclude - Tool names to skip proof generation for
|
|
27
|
-
*/
|
|
28
|
-
export function createMCPITransport(inner, mcpi, exclude = ["_mcpi", "_mcpi_handshake"]) {
|
|
29
|
-
// Request id → { toolName, args } for pending tool calls
|
|
30
|
-
const pending = new Map();
|
|
31
|
-
const wrapper = {
|
|
32
|
-
start: () => inner.start(),
|
|
33
|
-
close: () => inner.close(),
|
|
34
|
-
// McpServer writes into wrapper.onmessage — forward to inner so the
|
|
35
|
-
// real transport can drive it.
|
|
36
|
-
set onmessage(handler) {
|
|
37
|
-
inner.onmessage = handler;
|
|
38
|
-
},
|
|
39
|
-
get onmessage() {
|
|
40
|
-
return inner.onmessage;
|
|
41
|
-
},
|
|
42
|
-
set onclose(handler) {
|
|
43
|
-
inner.onclose = handler;
|
|
44
|
-
},
|
|
45
|
-
get onclose() {
|
|
46
|
-
return inner.onclose;
|
|
47
|
-
},
|
|
48
|
-
set onerror(handler) {
|
|
49
|
-
inner.onerror = handler;
|
|
50
|
-
},
|
|
51
|
-
get onerror() {
|
|
52
|
-
return inner.onerror;
|
|
53
|
-
},
|
|
54
|
-
// McpServer calls send() for every outgoing message.
|
|
55
|
-
// Intercept tools/call responses here to inject proofs.
|
|
56
|
-
async send(message) {
|
|
57
|
-
const id = message.id;
|
|
58
|
-
const call = id !== undefined ? pending.get(id) : undefined;
|
|
59
|
-
if (call) {
|
|
60
|
-
pending.delete(id);
|
|
61
|
-
try {
|
|
62
|
-
const rawResult = message.result;
|
|
63
|
-
if (rawResult && !rawResult.isError) {
|
|
64
|
-
const handler = async () => rawResult;
|
|
65
|
-
const addProof = mcpi.wrapWithProof(call.toolName, handler);
|
|
66
|
-
const proofed = await addProof(call.args);
|
|
67
|
-
if (proofed._meta !== undefined) {
|
|
68
|
-
message = {
|
|
69
|
-
...message,
|
|
70
|
-
result: proofed,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
logger.error("[mcpi-transport] Proof injection failed", {
|
|
77
|
-
tool: call.toolName,
|
|
78
|
-
error: error instanceof Error ? error.message : String(error),
|
|
79
|
-
});
|
|
80
|
-
const rawResult = message.result;
|
|
81
|
-
if (rawResult) {
|
|
82
|
-
rawResult._meta = {
|
|
83
|
-
proofError: "Proof generation failed — response is unproven",
|
|
84
|
-
};
|
|
85
|
-
message = { ...message, result: rawResult };
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return inner.send(message);
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
// Intercept incoming messages from the real transport to capture
|
|
93
|
-
// tools/call requests before McpServer processes them.
|
|
94
|
-
// We defer setting inner.onmessage until McpServer has set wrapper.onmessage
|
|
95
|
-
// via server.connect() — so we proxy through the getter/setter above and
|
|
96
|
-
// add our interception in a one-time initializer on start().
|
|
97
|
-
const originalStart = inner.start.bind(inner);
|
|
98
|
-
wrapper.start = async () => {
|
|
99
|
-
await originalStart();
|
|
100
|
-
// At this point McpServer has called server.connect(wrapper) which set
|
|
101
|
-
// wrapper.onmessage = <McpServer handler>. That assignment forwarded to
|
|
102
|
-
// inner.onmessage via the setter above. Now we inject our interceptor.
|
|
103
|
-
const downstream = inner.onmessage;
|
|
104
|
-
inner.onmessage = (message) => {
|
|
105
|
-
if (message.method === "tools/call" &&
|
|
106
|
-
message.id !== undefined) {
|
|
107
|
-
const params = message.params;
|
|
108
|
-
const toolName = params?.name;
|
|
109
|
-
if (toolName && !exclude.includes(toolName)) {
|
|
110
|
-
pending.set(message.id, {
|
|
111
|
-
toolName,
|
|
112
|
-
args: params?.arguments ?? {},
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
downstream?.(message);
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
return wrapper;
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=mcpi-transport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcpi-transport.js","sourceRoot":"","sources":["../../src/middleware/mcpi-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAyB7C;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAgB,EAChB,IAAoB,EACpB,UAAoB,CAAC,OAAO,EAAE,iBAAiB,CAAC;IAEhD,yDAAyD;IACzD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEhD,MAAM,OAAO,GAAc;QACzB,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE;QAC1B,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE;QAE1B,oEAAoE;QACpE,+BAA+B;QAC/B,IAAI,SAAS,CAAC,OAAoD;YAChE,KAAK,CAAC,SAAS,GAAG,OAAO,CAAC;QAC5B,CAAC;QACD,IAAI,SAAS;YACX,OAAO,KAAK,CAAC,SAAS,CAAC;QACzB,CAAC;QAED,IAAI,OAAO,CAAC,OAAiC;YAC3C,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;QAC1B,CAAC;QACD,IAAI,OAAO;YACT,OAAO,KAAK,CAAC,OAAO,CAAC;QACvB,CAAC;QAED,IAAI,OAAO,CAAC,OAA2C;YACrD,KAAK,CAAC,OAAO,GAAG,O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