@kya-os/mcp 1.2.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.
Files changed (182) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/LICENSE +21 -0
  3. package/README.md +135 -0
  4. package/dist/auth/handshake.d.ts +119 -0
  5. package/dist/auth/handshake.d.ts.map +1 -0
  6. package/dist/auth/handshake.js +267 -0
  7. package/dist/auth/handshake.js.map +1 -0
  8. package/dist/auth/index.d.ts +3 -0
  9. package/dist/auth/index.d.ts.map +1 -0
  10. package/dist/auth/index.js +2 -0
  11. package/dist/auth/index.js.map +1 -0
  12. package/dist/auth/types.d.ts +31 -0
  13. package/dist/auth/types.d.ts.map +1 -0
  14. package/dist/auth/types.js +7 -0
  15. package/dist/auth/types.js.map +1 -0
  16. package/dist/delegation/audience-validator.d.ts +9 -0
  17. package/dist/delegation/audience-validator.d.ts.map +1 -0
  18. package/dist/delegation/audience-validator.js +17 -0
  19. package/dist/delegation/audience-validator.js.map +1 -0
  20. package/dist/delegation/bitstring.d.ts +37 -0
  21. package/dist/delegation/bitstring.d.ts.map +1 -0
  22. package/dist/delegation/bitstring.js +117 -0
  23. package/dist/delegation/bitstring.js.map +1 -0
  24. package/dist/delegation/cascading-revocation.d.ts +45 -0
  25. package/dist/delegation/cascading-revocation.d.ts.map +1 -0
  26. package/dist/delegation/cascading-revocation.js +150 -0
  27. package/dist/delegation/cascading-revocation.js.map +1 -0
  28. package/dist/delegation/delegation-graph.d.ts +49 -0
  29. package/dist/delegation/delegation-graph.d.ts.map +1 -0
  30. package/dist/delegation/delegation-graph.js +99 -0
  31. package/dist/delegation/delegation-graph.js.map +1 -0
  32. package/dist/delegation/did-key-resolver.d.ts +64 -0
  33. package/dist/delegation/did-key-resolver.d.ts.map +1 -0
  34. package/dist/delegation/did-key-resolver.js +157 -0
  35. package/dist/delegation/did-key-resolver.js.map +1 -0
  36. package/dist/delegation/did-web-resolver.d.ts +83 -0
  37. package/dist/delegation/did-web-resolver.d.ts.map +1 -0
  38. package/dist/delegation/did-web-resolver.js +218 -0
  39. package/dist/delegation/did-web-resolver.js.map +1 -0
  40. package/dist/delegation/index.d.ts +21 -0
  41. package/dist/delegation/index.d.ts.map +1 -0
  42. package/dist/delegation/index.js +21 -0
  43. package/dist/delegation/index.js.map +1 -0
  44. package/dist/delegation/outbound-headers.d.ts +79 -0
  45. package/dist/delegation/outbound-headers.d.ts.map +1 -0
  46. package/dist/delegation/outbound-headers.js +138 -0
  47. package/dist/delegation/outbound-headers.js.map +1 -0
  48. package/dist/delegation/outbound-proof.d.ts +43 -0
  49. package/dist/delegation/outbound-proof.d.ts.map +1 -0
  50. package/dist/delegation/outbound-proof.js +52 -0
  51. package/dist/delegation/outbound-proof.js.map +1 -0
  52. package/dist/delegation/statuslist-manager.d.ts +47 -0
  53. package/dist/delegation/statuslist-manager.d.ts.map +1 -0
  54. package/dist/delegation/statuslist-manager.js +139 -0
  55. package/dist/delegation/statuslist-manager.js.map +1 -0
  56. package/dist/delegation/storage/memory-graph-storage.d.ts +70 -0
  57. package/dist/delegation/storage/memory-graph-storage.d.ts.map +1 -0
  58. package/dist/delegation/storage/memory-graph-storage.js +145 -0
  59. package/dist/delegation/storage/memory-graph-storage.js.map +1 -0
  60. package/dist/delegation/storage/memory-statuslist-storage.d.ts +19 -0
  61. package/dist/delegation/storage/memory-statuslist-storage.d.ts.map +1 -0
  62. package/dist/delegation/storage/memory-statuslist-storage.js +33 -0
  63. package/dist/delegation/storage/memory-statuslist-storage.js.map +1 -0
  64. package/dist/delegation/utils.d.ts +49 -0
  65. package/dist/delegation/utils.d.ts.map +1 -0
  66. package/dist/delegation/utils.js +131 -0
  67. package/dist/delegation/utils.js.map +1 -0
  68. package/dist/delegation/vc-issuer.d.ts +56 -0
  69. package/dist/delegation/vc-issuer.d.ts.map +1 -0
  70. package/dist/delegation/vc-issuer.js +80 -0
  71. package/dist/delegation/vc-issuer.js.map +1 -0
  72. package/dist/delegation/vc-verifier.d.ts +112 -0
  73. package/dist/delegation/vc-verifier.d.ts.map +1 -0
  74. package/dist/delegation/vc-verifier.js +280 -0
  75. package/dist/delegation/vc-verifier.js.map +1 -0
  76. package/dist/errors.d.ts +42 -0
  77. package/dist/errors.d.ts.map +1 -0
  78. package/dist/errors.js +45 -0
  79. package/dist/errors.js.map +1 -0
  80. package/dist/index.d.ts +47 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/index.js +56 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/logging/index.d.ts +2 -0
  85. package/dist/logging/index.d.ts.map +1 -0
  86. package/dist/logging/index.js +2 -0
  87. package/dist/logging/index.js.map +1 -0
  88. package/dist/logging/logger.d.ts +23 -0
  89. package/dist/logging/logger.d.ts.map +1 -0
  90. package/dist/logging/logger.js +82 -0
  91. package/dist/logging/logger.js.map +1 -0
  92. package/dist/middleware/index.d.ts +12 -0
  93. package/dist/middleware/index.d.ts.map +1 -0
  94. package/dist/middleware/index.js +12 -0
  95. package/dist/middleware/index.js.map +1 -0
  96. package/dist/middleware/mcpi-transport.d.ts +39 -0
  97. package/dist/middleware/mcpi-transport.d.ts.map +1 -0
  98. package/dist/middleware/mcpi-transport.js +121 -0
  99. package/dist/middleware/mcpi-transport.js.map +1 -0
  100. package/dist/middleware/with-mcpi-server.d.ts +78 -0
  101. package/dist/middleware/with-mcpi-server.d.ts.map +1 -0
  102. package/dist/middleware/with-mcpi-server.js +109 -0
  103. package/dist/middleware/with-mcpi-server.js.map +1 -0
  104. package/dist/middleware/with-mcpi.d.ts +202 -0
  105. package/dist/middleware/with-mcpi.d.ts.map +1 -0
  106. package/dist/middleware/with-mcpi.js +625 -0
  107. package/dist/middleware/with-mcpi.js.map +1 -0
  108. package/dist/proof/errors.d.ts +49 -0
  109. package/dist/proof/errors.d.ts.map +1 -0
  110. package/dist/proof/errors.js +61 -0
  111. package/dist/proof/errors.js.map +1 -0
  112. package/dist/proof/generator.d.ts +65 -0
  113. package/dist/proof/generator.d.ts.map +1 -0
  114. package/dist/proof/generator.js +163 -0
  115. package/dist/proof/generator.js.map +1 -0
  116. package/dist/proof/index.d.ts +4 -0
  117. package/dist/proof/index.d.ts.map +1 -0
  118. package/dist/proof/index.js +4 -0
  119. package/dist/proof/index.js.map +1 -0
  120. package/dist/proof/verifier.d.ts +108 -0
  121. package/dist/proof/verifier.d.ts.map +1 -0
  122. package/dist/proof/verifier.js +299 -0
  123. package/dist/proof/verifier.js.map +1 -0
  124. package/dist/providers/base.d.ts +64 -0
  125. package/dist/providers/base.d.ts.map +1 -0
  126. package/dist/providers/base.js +19 -0
  127. package/dist/providers/base.js.map +1 -0
  128. package/dist/providers/index.d.ts +4 -0
  129. package/dist/providers/index.d.ts.map +1 -0
  130. package/dist/providers/index.js +4 -0
  131. package/dist/providers/index.js.map +1 -0
  132. package/dist/providers/memory.d.ts +33 -0
  133. package/dist/providers/memory.d.ts.map +1 -0
  134. package/dist/providers/memory.js +102 -0
  135. package/dist/providers/memory.js.map +1 -0
  136. package/dist/providers/node-crypto.d.ts +26 -0
  137. package/dist/providers/node-crypto.d.ts.map +1 -0
  138. package/dist/providers/node-crypto.js +69 -0
  139. package/dist/providers/node-crypto.js.map +1 -0
  140. package/dist/session/index.d.ts +2 -0
  141. package/dist/session/index.d.ts.map +1 -0
  142. package/dist/session/index.js +2 -0
  143. package/dist/session/index.js.map +1 -0
  144. package/dist/session/manager.d.ts +83 -0
  145. package/dist/session/manager.d.ts.map +1 -0
  146. package/dist/session/manager.js +267 -0
  147. package/dist/session/manager.js.map +1 -0
  148. package/dist/types/protocol.d.ts +320 -0
  149. package/dist/types/protocol.d.ts.map +1 -0
  150. package/dist/types/protocol.js +229 -0
  151. package/dist/types/protocol.js.map +1 -0
  152. package/dist/utils/base58.d.ts +31 -0
  153. package/dist/utils/base58.d.ts.map +1 -0
  154. package/dist/utils/base58.js +104 -0
  155. package/dist/utils/base58.js.map +1 -0
  156. package/dist/utils/base64.d.ts +13 -0
  157. package/dist/utils/base64.d.ts.map +1 -0
  158. package/dist/utils/base64.js +99 -0
  159. package/dist/utils/base64.js.map +1 -0
  160. package/dist/utils/crypto-service.d.ts +37 -0
  161. package/dist/utils/crypto-service.d.ts.map +1 -0
  162. package/dist/utils/crypto-service.js +154 -0
  163. package/dist/utils/crypto-service.js.map +1 -0
  164. package/dist/utils/did-helpers.d.ts +168 -0
  165. package/dist/utils/did-helpers.d.ts.map +1 -0
  166. package/dist/utils/did-helpers.js +211 -0
  167. package/dist/utils/did-helpers.js.map +1 -0
  168. package/dist/utils/ed25519-constants.d.ts +18 -0
  169. package/dist/utils/ed25519-constants.d.ts.map +1 -0
  170. package/dist/utils/ed25519-constants.js +21 -0
  171. package/dist/utils/ed25519-constants.js.map +1 -0
  172. package/dist/utils/index.d.ts +5 -0
  173. package/dist/utils/index.d.ts.map +1 -0
  174. package/dist/utils/index.js +5 -0
  175. package/dist/utils/index.js.map +1 -0
  176. package/package.json +115 -0
  177. package/schemas/README.md +117 -0
  178. package/schemas/delegation-credential.json +312 -0
  179. package/schemas/detached-proof.json +97 -0
  180. package/schemas/handshake-request.json +84 -0
  181. package/schemas/handshake-response.json +67 -0
  182. package/schemas/well-known-mcpi.json +176 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Transport-aware Logger for MCP-I
3
+ *
4
+ * Provides a lightweight, dependency-free logging interface that:
5
+ * - Maps log levels correctly for Cloudflare Workers
6
+ * - Routes all logs to stderr for stdio transport (so stdout remains protocol-only)
7
+ * - Supports runtime configuration of log level and transport mode
8
+ */
9
+ const SEVERITY = {
10
+ debug: 10,
11
+ info: 20,
12
+ warn: 30,
13
+ error: 40,
14
+ };
15
+ export function createDefaultConsoleLogger() {
16
+ let level = 'info';
17
+ let forceStderr = false;
18
+ function shouldLog(l) {
19
+ return SEVERITY[l] >= SEVERITY[level];
20
+ }
21
+ function write(l, ...args) {
22
+ if (!shouldLog(l))
23
+ return;
24
+ if (forceStderr) {
25
+ console.error(...args);
26
+ return;
27
+ }
28
+ switch (l) {
29
+ case 'debug':
30
+ if (typeof console.debug === 'function') {
31
+ console.debug(...args);
32
+ }
33
+ else {
34
+ console.log(...args);
35
+ }
36
+ break;
37
+ case 'info':
38
+ if (typeof console.info === 'function') {
39
+ console.info(...args);
40
+ }
41
+ else {
42
+ console.log(...args);
43
+ }
44
+ break;
45
+ case 'warn':
46
+ if (typeof console.warn === 'function') {
47
+ console.warn(...args);
48
+ }
49
+ else {
50
+ console.error(...args);
51
+ }
52
+ break;
53
+ case 'error':
54
+ console.error(...args);
55
+ break;
56
+ }
57
+ }
58
+ return {
59
+ configure(opts = {}) {
60
+ if (opts.level)
61
+ level = opts.level;
62
+ if (opts.forceStderr === true) {
63
+ forceStderr = true;
64
+ }
65
+ else if (opts.forceStderr === false) {
66
+ forceStderr = false;
67
+ }
68
+ else if (opts.transport === 'stdio') {
69
+ forceStderr = true;
70
+ }
71
+ else if (opts.transport === 'sse' || opts.transport === 'http') {
72
+ forceStderr = false;
73
+ }
74
+ },
75
+ debug: (...a) => write('debug', ...a),
76
+ info: (...a) => write('info', ...a),
77
+ warn: (...a) => write('warn', ...a),
78
+ error: (...a) => write('error', ...a),
79
+ };
80
+ }
81
+ export const logger = createDefaultConsoleLogger();
82
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logging/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,QAAQ,GAA0B;IACtC,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;CACV,CAAC;AAUF,MAAM,UAAU,0BAA0B;IACxC,IAAI,KAAK,GAAU,MAAM,CAAC;IAC1B,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,SAAS,SAAS,CAAC,CAAQ;QACzB,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC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AE,CAAC;gBAC9B,WAAW,GAAG,IAAI,CAAC;YACrB,CAAC;iBAAM,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;gBACtC,WAAW,GAAG,KAAK,CAAC;YACtB,CAAC;iBAAM,IAAI,IAAI,CAAC,SAAS,KAAK,OAAO,EAAE,CAAC;gBACtC,WAAW,GAAG,IAAI,CAAC;YACrB,CAAC;iBAAM,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,IAAI,IAAI,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;gBACjE,WAAW,GAAG,KAAK,CAAC;YACtB,CAAC;QACH,CAAC;QACD,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACrC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACnC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACnC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;KACtC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,0BAA0B,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * MCP-I Middleware
3
+ *
4
+ * Primary entry point: `withMCPI(server, { crypto })` — adds identity,
5
+ * handshake, and auto-proofs to any McpServer instance in one call.
6
+ *
7
+ * For the low-level `Server` API or custom patterns, use `createMCPIMiddleware` directly.
8
+ */
9
+ export { createMCPIMiddleware, type MCPIConfig, type MCPIDelegationConfig, type MCPIIdentityConfig, type MCPIMiddleware, type MCPIToolDefinition, type MCPIToolHandler, type MCPIServer, } from './with-mcpi.js';
10
+ export { withMCPI, generateIdentity, type WithMCPIOptions, } from './with-mcpi-server.js';
11
+ export { createMCPITransport, type Transport, type JSONRPCMessage, } from './mcpi-transport.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AAE/B,OAAO,EACL,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,cAAc,GACpB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * MCP-I Middleware
3
+ *
4
+ * Primary entry point: `withMCPI(server, { crypto })` — adds identity,
5
+ * handshake, and auto-proofs to any McpServer instance in one call.
6
+ *
7
+ * For the low-level `Server` API or custom patterns, use `createMCPIMiddleware` directly.
8
+ */
9
+ export { createMCPIMiddleware, } from './with-mcpi.js';
10
+ export { withMCPI, generateIdentity, } from './with-mcpi-server.js';
11
+ export { createMCPITransport, } from './mcpi-transport.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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;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
+ {"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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 * McpServer Adapter for MCP-I
3
+ *
4
+ * Adds MCP-I identity, session management, and proof generation to a
5
+ * standard McpServer instance with a single function call.
6
+ *
7
+ * Usage:
8
+ * import { withMCPI } from '@kya-os/mcp/middleware';
9
+ * const mcpi = await withMCPI(server, { crypto: new NodeCryptoProvider() });
10
+ * // All tools registered on `server` now get proofs automatically.
11
+ * await server.connect(transport); // transport is transparently wrapped
12
+ */
13
+ import type { CryptoProvider } from "../providers/base.js";
14
+ import { type MCPIIdentityConfig, type MCPIDelegationConfig, type MCPIMiddleware } from "./with-mcpi.js";
15
+ import { type Transport } from "./mcpi-transport.js";
16
+ export interface WithMCPIOptions {
17
+ /** Platform-specific crypto implementation (required) */
18
+ crypto: CryptoProvider;
19
+ /** Identity config — auto-generated if omitted */
20
+ identity?: MCPIIdentityConfig;
21
+ /** Session configuration */
22
+ session?: {
23
+ sessionTtlMinutes?: number;
24
+ };
25
+ /** Auto-create sessions for non-MCP-I clients (default: true) */
26
+ autoSession?: boolean;
27
+ /** Attach proofs to all tool responses (default: true) */
28
+ proofAllTools?: boolean;
29
+ /** Tools to skip proof generation for */
30
+ excludeTools?: string[];
31
+ /** Delegation verification config */
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";
39
+ }
40
+ /**
41
+ * Generate a fresh Ed25519 identity for MCP-I.
42
+ *
43
+ * @param crypto - Platform-specific crypto provider
44
+ * @returns Identity config with DID, kid, and key material
45
+ */
46
+ export declare function generateIdentity(crypto: CryptoProvider): Promise<MCPIIdentityConfig>;
47
+ /**
48
+ * Minimal McpServer interface — avoids hard dependency on @modelcontextprotocol/sdk.
49
+ * Matches the subset of McpServer's public API that withMCPI() uses.
50
+ */
51
+ interface McpServerLike {
52
+ connect(transport: Transport): Promise<unknown>;
53
+ registerTool(...args: unknown[]): void;
54
+ }
55
+ /**
56
+ * Add MCP-I to a McpServer instance.
57
+ *
58
+ * 1. Auto-generates Ed25519 identity (or uses provided one)
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
+ * ```
71
+ *
72
+ * @param server - McpServer instance
73
+ * @param options - Configuration
74
+ * @returns The MCPIMiddleware instance for advanced usage (wrapWithDelegation, etc.)
75
+ */
76
+ export declare function withMCPI(server: McpServerLike, options: WithMCPIOptions): Promise<MCPIMiddleware>;
77
+ export {};
78
+ //# sourceMappingURL=with-mcpi-server.d.ts.map
@@ -0,0 +1 @@
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,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,CAuEzB"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * McpServer Adapter for MCP-I
3
+ *
4
+ * Adds MCP-I identity, session management, and proof generation to a
5
+ * standard McpServer instance with a single function call.
6
+ *
7
+ * Usage:
8
+ * import { withMCPI } from '@kya-os/mcp/middleware';
9
+ * const mcpi = await withMCPI(server, { crypto: new NodeCryptoProvider() });
10
+ * // All tools registered on `server` now get proofs automatically.
11
+ * await server.connect(transport); // transport is transparently wrapped
12
+ */
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";
16
+ import { z } from "zod";
17
+ /**
18
+ * Generate a fresh Ed25519 identity for MCP-I.
19
+ *
20
+ * @param crypto - Platform-specific crypto provider
21
+ * @returns Identity config with DID, kid, and key material
22
+ */
23
+ export async function generateIdentity(crypto) {
24
+ const keyPair = await crypto.generateKeyPair();
25
+ const did = generateDidKeyFromBase64(keyPair.publicKey);
26
+ return {
27
+ did,
28
+ kid: `${did}#${didKeyFragment(did)}`,
29
+ privateKey: keyPair.privateKey,
30
+ publicKey: keyPair.publicKey,
31
+ };
32
+ }
33
+ /**
34
+ * Add MCP-I to a McpServer instance.
35
+ *
36
+ * 1. Auto-generates Ed25519 identity (or uses provided one)
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.
41
+ *
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
51
+ * @param options - Configuration
52
+ * @returns The MCPIMiddleware instance for advanced usage (wrapWithDelegation, etc.)
53
+ */
54
+ export async function withMCPI(server, options) {
55
+ const identity = options.identity ?? (await generateIdentity(options.crypto));
56
+ const mcpi = createMCPIMiddleware({
57
+ identity,
58
+ session: options.session,
59
+ delegation: options.delegation,
60
+ autoSession: options.autoSession ?? true,
61
+ }, options.crypto);
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));
106
+ }
107
+ return mcpi;
108
+ }
109
+ //# sourceMappingURL=with-mcpi-server.js.map
@@ -0,0 +1 @@
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;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