@mcp-i/core 1.1.0-canary.2 → 1.1.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/README.md +123 -333
- package/dist/auth/handshake.d.ts +19 -4
- package/dist/auth/handshake.d.ts.map +1 -1
- package/dist/auth/handshake.js +52 -15
- 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 +9 -6
- package/dist/delegation/did-key-resolver.js.map +1 -1
- package/dist/delegation/outbound-headers.d.ts +2 -4
- package/dist/delegation/outbound-headers.d.ts.map +1 -1
- package/dist/delegation/outbound-headers.js +2 -3
- 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/errors.d.ts +42 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +45 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/mcpi-transport.d.ts +39 -0
- package/dist/middleware/mcpi-transport.d.ts.map +1 -0
- package/dist/middleware/mcpi-transport.js +121 -0
- package/dist/middleware/mcpi-transport.js.map +1 -0
- package/dist/middleware/with-mcpi-server.d.ts +25 -9
- package/dist/middleware/with-mcpi-server.d.ts.map +1 -1
- package/dist/middleware/with-mcpi-server.js +62 -47
- package/dist/middleware/with-mcpi-server.js.map +1 -1
- package/dist/middleware/with-mcpi.d.ts +26 -5
- package/dist/middleware/with-mcpi.d.ts.map +1 -1
- package/dist/middleware/with-mcpi.js +108 -10
- 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 +7 -1
- package/dist/session/manager.d.ts.map +1 -1
- package/dist/session/manager.js +20 -4
- package/dist/session/manager.js.map +1 -1
- package/dist/utils/crypto-service.d.ts.map +1 -1
- package/dist/utils/crypto-service.js +11 -10
- package/dist/utils/crypto-service.js.map +1 -1
- package/dist/utils/did-helpers.d.ts +12 -0
- package/dist/utils/did-helpers.d.ts.map +1 -1
- package/dist/utils/did-helpers.js +18 -0
- package/dist/utils/did-helpers.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/errors.test.ts +56 -0
- package/src/__tests__/integration/full-flow.test.ts +1 -1
- package/src/__tests__/integration/mcp-enhance-server.test.ts +48 -5
- package/src/__tests__/integration/mcp-transport-context7.test.ts +19 -15
- package/src/__tests__/integration/mcp-transport.test.ts +13 -10
- package/src/__tests__/providers/base.test.ts +1 -1
- package/src/__tests__/providers/memory.test.ts +2 -2
- package/src/__tests__/utils/mock-providers.ts +2 -2
- package/src/auth/__tests__/handshake.test.ts +190 -0
- package/src/auth/handshake.ts +88 -21
- package/src/auth/index.ts +1 -0
- package/src/delegation/__tests__/did-key-resolver.test.ts +2 -2
- package/src/delegation/__tests__/outbound-headers.test.ts +16 -20
- package/src/delegation/__tests__/statuslist-manager.test.ts +120 -7
- package/src/delegation/__tests__/vc-verifier.test.ts +45 -3
- package/src/delegation/did-key-resolver.ts +11 -6
- package/src/delegation/outbound-headers.ts +1 -4
- package/src/delegation/statuslist-manager.ts +3 -1
- package/src/delegation/vc-verifier.ts +3 -2
- package/src/errors.ts +65 -0
- package/src/index.ts +10 -0
- package/src/middleware/__tests__/mcpi-transport.test.ts +150 -0
- package/src/middleware/__tests__/with-mcpi-server.test.ts +117 -0
- package/src/middleware/__tests__/with-mcpi.test.ts +124 -6
- package/src/middleware/index.ts +6 -0
- package/src/middleware/mcpi-transport.ts +162 -0
- package/src/middleware/with-mcpi-server.ts +83 -92
- package/src/middleware/with-mcpi.ts +147 -11
- package/src/proof/__tests__/errors.test.ts +79 -0
- package/src/proof/__tests__/verifier.test.ts +5 -5
- package/src/providers/memory.ts +2 -2
- package/src/session/__tests__/session-manager.test.ts +3 -3
- package/src/session/manager.ts +28 -6
- package/src/utils/crypto-service.ts +11 -10
- package/src/utils/did-helpers.ts +19 -0
|
@@ -8,4 +8,5 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { createMCPIMiddleware, type MCPIConfig, type MCPIDelegationConfig, type MCPIIdentityConfig, type MCPIMiddleware, type MCPIToolDefinition, type MCPIToolHandler, type MCPIServer, } from './with-mcpi.js';
|
|
10
10
|
export { withMCPI, generateIdentity, type WithMCPIOptions, } from './with-mcpi-server.js';
|
|
11
|
+
export { createMCPITransport, type Transport, type JSONRPCMessage, } from './mcpi-transport.js';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,cAAc,GACpB,MAAM,qBAAqB,CAAC"}
|
package/dist/middleware/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,oBAAoB,GAQrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,QAAQ,EACR,gBAAgB,GAEjB,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,oBAAoB,GAQrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,QAAQ,EACR,gBAAgB,GAEjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,mBAAmB,GAGpB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AAyE;IACzE,6DAA6D;IAC7D,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9C,OAAO,CAAC,KAAK,GAAG,KAAK,IAAI,EAAE;QACzB,MAAM,aAAa,EAAE,CAAC;QACtB,uEAAuE;QACvE,wEAAwE;QACxE,uEAAuE;QACvE,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC;QACnC,KAAK,CAAC,SAAS,GAAG,CAAC,OAAuB,EAAE,EAAE;YAC5C,IACE,OAAO,CAAC,MAAM,KAAK,YAAY;gBAC/B,OAAO,CAAC,EAAE,KAAK,SAAS,EACxB,CAAC;gBACD,MAAM,MAAM,GAAG,OAAO,CAAC,MAEV,CAAC;gBACd,MAAM,QAAQ,GAAG,MAAM,EAAE,IAAI,CAAC;gBAC9B,IAAI,QAAQ,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC5C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE;wBACtB,QAAQ;wBACR,IAAI,EAAE,MAAM,EAAE,SAAS,IAAI,EAAE;qBAC9B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
* import { withMCPI } from '@mcp-i/core/middleware';
|
|
9
9
|
* const mcpi = await withMCPI(server, { crypto: new NodeCryptoProvider() });
|
|
10
10
|
* // All tools registered on `server` now get proofs automatically.
|
|
11
|
+
* await server.connect(transport); // transport is transparently wrapped
|
|
11
12
|
*/
|
|
12
13
|
import type { CryptoProvider } from "../providers/base.js";
|
|
13
14
|
import { type MCPIIdentityConfig, type MCPIDelegationConfig, type MCPIMiddleware } from "./with-mcpi.js";
|
|
15
|
+
import { type Transport } from "./mcpi-transport.js";
|
|
14
16
|
export interface WithMCPIOptions {
|
|
15
17
|
/** Platform-specific crypto implementation (required) */
|
|
16
18
|
crypto: CryptoProvider;
|
|
@@ -28,6 +30,12 @@ export interface WithMCPIOptions {
|
|
|
28
30
|
excludeTools?: string[];
|
|
29
31
|
/** Delegation verification config */
|
|
30
32
|
delegation?: MCPIDelegationConfig;
|
|
33
|
+
/**
|
|
34
|
+
* How the MCP-I protocol tool is exposed on the server.
|
|
35
|
+
* - "tool" (default): auto-register `_mcpi`
|
|
36
|
+
* - "none": do not register MCP-I tool (use middleware APIs for custom runtime hooks)
|
|
37
|
+
*/
|
|
38
|
+
handshakeExposure?: "tool" | "none";
|
|
31
39
|
}
|
|
32
40
|
/**
|
|
33
41
|
* Generate a fresh Ed25519 identity for MCP-I.
|
|
@@ -37,23 +45,31 @@ export interface WithMCPIOptions {
|
|
|
37
45
|
*/
|
|
38
46
|
export declare function generateIdentity(crypto: CryptoProvider): Promise<MCPIIdentityConfig>;
|
|
39
47
|
/**
|
|
40
|
-
* McpServer
|
|
41
|
-
* Matches the public API
|
|
48
|
+
* Minimal McpServer interface — avoids hard dependency on @modelcontextprotocol/sdk.
|
|
49
|
+
* Matches the subset of McpServer's public API that withMCPI() uses.
|
|
42
50
|
*/
|
|
43
51
|
interface McpServerLike {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
registerTool(...args: any[]): void;
|
|
52
|
+
connect(transport: Transport): Promise<unknown>;
|
|
53
|
+
registerTool(name: string, config: Record<string, unknown>, handler: (args: unknown) => Promise<unknown>): void;
|
|
48
54
|
}
|
|
49
55
|
/**
|
|
50
56
|
* Add MCP-I to a McpServer instance.
|
|
51
57
|
*
|
|
52
58
|
* 1. Auto-generates Ed25519 identity (or uses provided one)
|
|
53
|
-
* 2. Registers `
|
|
54
|
-
* 3.
|
|
59
|
+
* 2. Registers `_mcpi` tool by default (`handshakeExposure: "tool"`)
|
|
60
|
+
* 3. Patches `server.connect()` to transparently wrap the transport with
|
|
61
|
+
* MCPITransport, which injects detached proofs into all `tools/call`
|
|
62
|
+
* responses using only the public Transport interface.
|
|
63
|
+
*
|
|
64
|
+
* The user-facing API is unchanged — register tools before or after this
|
|
65
|
+
* call, then connect as normal:
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* const mcpi = await withMCPI(server, { crypto: new NodeCryptoProvider() });
|
|
69
|
+
* await server.connect(transport); // MCPITransport wraps silently
|
|
70
|
+
* ```
|
|
55
71
|
*
|
|
56
|
-
* @param server
|
|
72
|
+
* @param server - McpServer instance
|
|
57
73
|
* @param options - Configuration
|
|
58
74
|
* @returns The MCPIMiddleware instance for advanced usage (wrapWithDelegation, etc.)
|
|
59
75
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-mcpi-server.d.ts","sourceRoot":"","sources":["../../src/middleware/with-mcpi-server.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"with-mcpi-server.d.ts","sourceRoot":"","sources":["../../src/middleware/with-mcpi-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG1E,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,MAAM,EAAE,cAAc,CAAC;IACvB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,4BAA4B;IAC5B,OAAO,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,iEAAiE;IACjE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,qCAAqC;IACrC,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,kBAAkB,CAAC,CAS7B;AAED;;;GAGG;AACH,UAAU,aAAa;IACrB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,YAAY,CACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAC3C,IAAI,CAAC;CACT;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,CAuEzB"}
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
* import { withMCPI } from '@mcp-i/core/middleware';
|
|
9
9
|
* const mcpi = await withMCPI(server, { crypto: new NodeCryptoProvider() });
|
|
10
10
|
* // All tools registered on `server` now get proofs automatically.
|
|
11
|
+
* await server.connect(transport); // transport is transparently wrapped
|
|
11
12
|
*/
|
|
12
|
-
import { generateDidKeyFromBase64 } from "../utils/did-helpers.js";
|
|
13
|
-
import { createMCPIMiddleware, } from "./with-mcpi.js";
|
|
13
|
+
import { generateDidKeyFromBase64, didKeyFragment } from "../utils/did-helpers.js";
|
|
14
|
+
import { MCPI_ACTIONS, createMCPIMiddleware, } from "./with-mcpi.js";
|
|
15
|
+
import { createMCPITransport } from "./mcpi-transport.js";
|
|
14
16
|
import { z } from "zod";
|
|
15
17
|
/**
|
|
16
18
|
* Generate a fresh Ed25519 identity for MCP-I.
|
|
@@ -23,7 +25,7 @@ export async function generateIdentity(crypto) {
|
|
|
23
25
|
const did = generateDidKeyFromBase64(keyPair.publicKey);
|
|
24
26
|
return {
|
|
25
27
|
did,
|
|
26
|
-
kid: `${did}
|
|
28
|
+
kid: `${did}#${didKeyFragment(did)}`,
|
|
27
29
|
privateKey: keyPair.privateKey,
|
|
28
30
|
publicKey: keyPair.publicKey,
|
|
29
31
|
};
|
|
@@ -32,10 +34,20 @@ export async function generateIdentity(crypto) {
|
|
|
32
34
|
* Add MCP-I to a McpServer instance.
|
|
33
35
|
*
|
|
34
36
|
* 1. Auto-generates Ed25519 identity (or uses provided one)
|
|
35
|
-
* 2. Registers `
|
|
36
|
-
* 3.
|
|
37
|
+
* 2. Registers `_mcpi` tool by default (`handshakeExposure: "tool"`)
|
|
38
|
+
* 3. Patches `server.connect()` to transparently wrap the transport with
|
|
39
|
+
* MCPITransport, which injects detached proofs into all `tools/call`
|
|
40
|
+
* responses using only the public Transport interface.
|
|
37
41
|
*
|
|
38
|
-
*
|
|
42
|
+
* The user-facing API is unchanged — register tools before or after this
|
|
43
|
+
* call, then connect as normal:
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* const mcpi = await withMCPI(server, { crypto: new NodeCryptoProvider() });
|
|
47
|
+
* await server.connect(transport); // MCPITransport wraps silently
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param server - McpServer instance
|
|
39
51
|
* @param options - Configuration
|
|
40
52
|
* @returns The MCPIMiddleware instance for advanced usage (wrapWithDelegation, etc.)
|
|
41
53
|
*/
|
|
@@ -47,47 +59,50 @@ export async function withMCPI(server, options) {
|
|
|
47
59
|
delegation: options.delegation,
|
|
48
60
|
autoSession: options.autoSession ?? true,
|
|
49
61
|
}, options.crypto);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
62
|
+
if ((options.handshakeExposure ?? "tool") === "tool") {
|
|
63
|
+
// Register the unified _mcpi tool for protocol operations.
|
|
64
|
+
server.registerTool("_mcpi", {
|
|
65
|
+
description: "MCP-I protocol — identity verification, session handshake, and server metadata",
|
|
66
|
+
annotations: { title: "MCP-I Protocol", readOnlyHint: true },
|
|
67
|
+
inputSchema: {
|
|
68
|
+
action: z
|
|
69
|
+
.enum(MCPI_ACTIONS)
|
|
70
|
+
.describe("Protocol operation to perform"),
|
|
71
|
+
nonce: z
|
|
72
|
+
.string()
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("Client-generated unique nonce (handshake)"),
|
|
75
|
+
audience: z
|
|
76
|
+
.string()
|
|
77
|
+
.optional()
|
|
78
|
+
.describe("Intended audience (handshake)"),
|
|
79
|
+
timestamp: z
|
|
80
|
+
.number()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe("Unix epoch seconds (handshake)"),
|
|
83
|
+
agentDid: z
|
|
84
|
+
.string()
|
|
85
|
+
.optional()
|
|
86
|
+
.describe("Client agent DID (handshake, optional)"),
|
|
87
|
+
},
|
|
88
|
+
}, async (args) => {
|
|
89
|
+
const result = await mcpi.handleMCPI(args);
|
|
90
|
+
return {
|
|
91
|
+
...result,
|
|
92
|
+
content: result.content.map((c) => ({ ...c, type: "text" })),
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// Auto-proof interception via transport wrapper (public API only).
|
|
97
|
+
//
|
|
98
|
+
// We patch server.connect() so that whatever transport the caller passes
|
|
99
|
+
// is silently wrapped with MCPITransport before McpServer sees it.
|
|
100
|
+
// Tool registration order does not matter — proofs are injected at the
|
|
101
|
+
// transport boundary, after McpServer has already dispatched the call.
|
|
102
|
+
if (options.proofAllTools !== false) {
|
|
103
|
+
const exclude = ["_mcpi", "_mcpi_handshake", ...(options.excludeTools ?? [])];
|
|
104
|
+
const originalConnect = server.connect.bind(server);
|
|
105
|
+
server.connect = (transport) => originalConnect(createMCPITransport(transport, mcpi, exclude));
|
|
91
106
|
}
|
|
92
107
|
return mcpi;
|
|
93
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-mcpi-server.js","sourceRoot":"","sources":["../../src/middleware/with-mcpi-server.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"with-mcpi-server.js","sourceRoot":"","sources":["../../src/middleware/with-mcpi-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EACL,YAAY,EACZ,oBAAoB,GAIrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAkB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAsB;IAEtB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC;IAC/C,MAAM,GAAG,GAAG,wBAAwB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACxD,OAAO;QACL,GAAG;QACH,GAAG,EAAE,GAAG,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE;QACpC,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,CAAC,wCAAwC,CAAC;aACtD;SACF,EACD,KAAK,EAAE,IAAa,EAAE,EAAE;YACtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAClC,IAA+B,CAChC,CAAC;YACF,OAAO;gBACL,GAAG,MAAM;gBACT,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,CAAC,CAAC;aACtE,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED,mEAAmE;IACnE,EAAE;IACF,yEAAyE;IACzE,mEAAmE;IACnE,uEAAuE;IACvE,uEAAuE;IACvE,IAAI,OAAO,CAAC,aAAa,KAAK,KAAK,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC;QAC9E,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,GAAG,CAAC,SAAoB,EAAE,EAAE,CACxC,eAAe,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Adds identity, session management, and proof generation to MCP servers.
|
|
5
5
|
*
|
|
6
6
|
* For most use cases, prefer the high-level `withMCPI()` adapter from
|
|
7
|
-
* `./with-mcpi-server.ts` which auto-registers the handshake
|
|
8
|
-
* auto-attaches proofs to all tool responses:
|
|
7
|
+
* `./with-mcpi-server.ts` which (by default) auto-registers the handshake
|
|
8
|
+
* tool and auto-attaches proofs to all tool responses:
|
|
9
9
|
*
|
|
10
10
|
* import { withMCPI } from '@mcp-i/core';
|
|
11
11
|
* await withMCPI(server, { crypto: new NodeCryptoProvider() });
|
|
@@ -24,7 +24,9 @@ export interface MCPIIdentityConfig {
|
|
|
24
24
|
kid: string;
|
|
25
25
|
privateKey: string;
|
|
26
26
|
publicKey: string;
|
|
27
|
+
agentName?: string;
|
|
27
28
|
}
|
|
29
|
+
export declare const MCPI_ACTIONS: readonly ["handshake", "identity", "reputation"];
|
|
28
30
|
export interface MCPIDelegationConfig {
|
|
29
31
|
/**
|
|
30
32
|
* Optional custom DID resolver. If it returns null, middleware falls back to
|
|
@@ -68,8 +70,8 @@ export interface MCPIConfig {
|
|
|
68
70
|
/**
|
|
69
71
|
* When true, automatically creates a session on the first tool call
|
|
70
72
|
* if no session exists. Useful for demos and development where
|
|
71
|
-
* MCP clients don't support the
|
|
72
|
-
* In production, MCP-I-aware
|
|
73
|
+
* MCP clients don't support the `_mcpi` handshake flow.
|
|
74
|
+
* In production, MCP-I-aware runtimes should execute handshake before tool calls.
|
|
73
75
|
*/
|
|
74
76
|
autoSession?: boolean;
|
|
75
77
|
}
|
|
@@ -109,11 +111,29 @@ export interface MCPIMiddleware {
|
|
|
109
111
|
/** The ProofGenerator instance for manual proof operations */
|
|
110
112
|
proofGenerator: ProofGenerator;
|
|
111
113
|
/**
|
|
114
|
+
* Unified tool definition for `_mcpi`.
|
|
115
|
+
* Include this in your ListToolsRequest handler's tool list.
|
|
116
|
+
*/
|
|
117
|
+
mcpiTool: MCPIToolDefinition;
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated Use `mcpiTool` (`_mcpi` with `action: "handshake"`).
|
|
112
120
|
* Tool definition for `_mcpi_handshake`.
|
|
113
121
|
* Include this in your ListToolsRequest handler's tool list.
|
|
114
122
|
*/
|
|
115
123
|
handshakeTool: MCPIToolDefinition;
|
|
116
124
|
/**
|
|
125
|
+
* Handle a unified `_mcpi` action. Use this in your CallToolRequest handler
|
|
126
|
+
* when `request.params.name === '_mcpi'`.
|
|
127
|
+
*/
|
|
128
|
+
handleMCPI(args: Record<string, unknown>): Promise<{
|
|
129
|
+
content: Array<{
|
|
130
|
+
type: string;
|
|
131
|
+
text: string;
|
|
132
|
+
}>;
|
|
133
|
+
isError?: boolean;
|
|
134
|
+
}>;
|
|
135
|
+
/**
|
|
136
|
+
* @deprecated Use `handleMCPI` with `action: "handshake"`.
|
|
117
137
|
* Handle a handshake call. Use this in your CallToolRequest handler
|
|
118
138
|
* when `request.params.name === '_mcpi_handshake'`.
|
|
119
139
|
*/
|
|
@@ -146,7 +166,8 @@ export interface MCPIMiddleware {
|
|
|
146
166
|
* Create MCP-I middleware for a standard MCP SDK Server.
|
|
147
167
|
*
|
|
148
168
|
* For most use cases, prefer {@link withMCPI} from `./with-mcpi-server.ts`
|
|
149
|
-
* which wraps this function and auto-registers handshake +
|
|
169
|
+
* which wraps this function and (by default) auto-registers handshake +
|
|
170
|
+
* auto-attaches proofs.
|
|
150
171
|
*
|
|
151
172
|
* Use `createMCPIMiddleware` directly when:
|
|
152
173
|
* - You use the low-level `Server` API (not `McpServer`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-mcpi.d.ts","sourceRoot":"","sources":["../../src/middleware/with-mcpi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,KAAK,cAAc,EACnB,aAAa,EACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,EAIf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,kBAAkB,EACxB,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAGL,KAAK,oBAAoB,EAE1B,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"with-mcpi.d.ts","sourceRoot":"","sources":["../../src/middleware/with-mcpi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,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