@kya-os/mcp-i 1.6.1 → 1.6.2-canary.1
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/compiler/index.js +12 -2
- package/dist/compiler/parse-xmcp-config.js +5 -0
- package/dist/runtime/adapter-express.js +1 -1
- package/dist/runtime/adapter-nextjs.js +1 -1
- package/dist/runtime/http.js +1 -1
- package/dist/runtime/mcpi-runtime.js +7 -1
- package/dist/runtime/session.d.ts +13 -0
- package/dist/runtime/session.js +43 -0
- package/dist/runtime/stdio.js +1 -1
- package/dist/runtime/utils/tools.js +196 -23
- package/package.json +3 -3
|
@@ -208,7 +208,13 @@ class MCPIRuntime {
|
|
|
208
208
|
data = this.demoManager.addIdentityBadgeToResponse(data);
|
|
209
209
|
}
|
|
210
210
|
// Create response with proof
|
|
211
|
-
const
|
|
211
|
+
const proofOptions = {
|
|
212
|
+
...options,
|
|
213
|
+
...(session && session.clientDid
|
|
214
|
+
? { clientDid: session.clientDid }
|
|
215
|
+
: {}),
|
|
216
|
+
};
|
|
217
|
+
const response = await (0, proof_1.createProofResponse)(request, data, this.cachedIdentity, session, proofOptions);
|
|
212
218
|
// Update debug state with latest proof
|
|
213
219
|
if (this.debugManager && response.meta?.proof) {
|
|
214
220
|
this.debugManager.updateDebugState(response.meta.proof, session);
|
|
@@ -52,6 +52,19 @@ export declare class SessionManager {
|
|
|
52
52
|
* Generate a unique session ID
|
|
53
53
|
*/
|
|
54
54
|
private generateSessionId;
|
|
55
|
+
/**
|
|
56
|
+
* Generate a deterministic client identifier when the client
|
|
57
|
+
* does not provide one during the handshake.
|
|
58
|
+
*/
|
|
59
|
+
private generateClientId;
|
|
60
|
+
/**
|
|
61
|
+
* Normalize string fields from handshake metadata
|
|
62
|
+
*/
|
|
63
|
+
private normalizeClientInfoString;
|
|
64
|
+
/**
|
|
65
|
+
* Build MCP client metadata for the session when provided during handshake
|
|
66
|
+
*/
|
|
67
|
+
private buildClientInfo;
|
|
55
68
|
/**
|
|
56
69
|
* Generate a cryptographically secure nonce
|
|
57
70
|
*/
|
package/dist/runtime/session.js
CHANGED
|
@@ -76,6 +76,7 @@ class SessionManager {
|
|
|
76
76
|
await this.config.nonceCache.add(request.nonce, nonceTtlSeconds, request.agentDid);
|
|
77
77
|
// Generate session ID
|
|
78
78
|
const sessionId = this.generateSessionId();
|
|
79
|
+
const clientInfo = this.buildClientInfo(request);
|
|
79
80
|
// Create session context
|
|
80
81
|
const session = {
|
|
81
82
|
sessionId,
|
|
@@ -87,6 +88,7 @@ class SessionManager {
|
|
|
87
88
|
ttlMinutes: this.config.sessionTtlMinutes,
|
|
88
89
|
agentDid: request.agentDid, // Pass through agent DID for delegation verification
|
|
89
90
|
...(this.config.serverDid && { serverDid: this.config.serverDid }), // Include server DID if provided
|
|
91
|
+
...(clientInfo && { clientInfo }),
|
|
90
92
|
};
|
|
91
93
|
// Store session
|
|
92
94
|
this.sessions.set(sessionId, session);
|
|
@@ -143,6 +145,47 @@ class SessionManager {
|
|
|
143
145
|
const random = (0, crypto_1.randomBytes)(8).toString("hex");
|
|
144
146
|
return `sess_${timestamp}_${random}`;
|
|
145
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Generate a deterministic client identifier when the client
|
|
150
|
+
* does not provide one during the handshake.
|
|
151
|
+
*/
|
|
152
|
+
generateClientId() {
|
|
153
|
+
return `client_${(0, crypto_1.randomBytes)(6).toString("hex")}`;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Normalize string fields from handshake metadata
|
|
157
|
+
*/
|
|
158
|
+
normalizeClientInfoString(value) {
|
|
159
|
+
if (typeof value !== "string") {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
const trimmed = value.trim();
|
|
163
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Build MCP client metadata for the session when provided during handshake
|
|
167
|
+
*/
|
|
168
|
+
buildClientInfo(request) {
|
|
169
|
+
const hasMetadata = !!request.clientInfo ||
|
|
170
|
+
typeof request.clientProtocolVersion === "string" ||
|
|
171
|
+
request.clientCapabilities !== undefined;
|
|
172
|
+
if (!hasMetadata) {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
const source = request.clientInfo;
|
|
176
|
+
return {
|
|
177
|
+
name: this.normalizeClientInfoString(source?.name) ?? "unknown",
|
|
178
|
+
title: this.normalizeClientInfoString(source?.title),
|
|
179
|
+
version: this.normalizeClientInfoString(source?.version),
|
|
180
|
+
platform: this.normalizeClientInfoString(source?.platform),
|
|
181
|
+
vendor: this.normalizeClientInfoString(source?.vendor),
|
|
182
|
+
persistentId: this.normalizeClientInfoString(source?.persistentId),
|
|
183
|
+
clientId: this.normalizeClientInfoString(source?.clientId) ??
|
|
184
|
+
this.generateClientId(),
|
|
185
|
+
protocolVersion: this.normalizeClientInfoString(request.clientProtocolVersion),
|
|
186
|
+
capabilities: request.clientCapabilities,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
146
189
|
/**
|
|
147
190
|
* Generate a cryptographically secure nonce
|
|
148
191
|
*/
|