@mcp-i/core 1.1.1 → 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/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,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,OAAO,CAAC;QAC1B,CAAC;QACD,IAAI,OAAO;YACT,OAAO,KAAK,CAAC,OAAO,CAAC;QACvB,CAAC;QAED,qDAAqD;QACrD,wDAAwD;QACxD,KAAK,CAAC,IAAI,CAAC,OAAuB;YAChC,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,GAAG,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,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