@kya-os/mcp-i 0.1.0-alpha.3.9 → 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 (328) hide show
  1. package/README.md +350 -213
  2. package/dist/149.js +1 -0
  3. package/dist/189.js +1 -0
  4. package/dist/261.js +1 -0
  5. package/dist/28.js +1 -0
  6. package/dist/295.js +1 -0
  7. package/dist/460.js +1 -0
  8. package/dist/570.js +1 -0
  9. package/dist/634.js +1 -0
  10. package/dist/647.js +1 -0
  11. package/dist/67.js +1 -0
  12. package/dist/739.js +1 -0
  13. package/dist/742.js +1 -0
  14. package/dist/904.js +1 -0
  15. package/dist/938.js +1 -0
  16. package/dist/auth/api-key.d.ts +16 -0
  17. package/dist/auth/api-key.js +82 -0
  18. package/dist/auth/jwt.d.ts +43 -0
  19. package/dist/auth/jwt.js +51 -0
  20. package/dist/auth/oauth/factory.d.ts +12 -0
  21. package/dist/auth/oauth/factory.js +36 -0
  22. package/dist/auth/oauth/index.d.ts +5 -0
  23. package/dist/auth/oauth/index.js +27 -0
  24. package/dist/auth/oauth/providers/proxy-provider.d.ts +13 -0
  25. package/dist/auth/oauth/providers/proxy-provider.js +159 -0
  26. package/dist/auth/oauth/router.d.ts +4 -0
  27. package/dist/auth/oauth/router.js +294 -0
  28. package/dist/auth/oauth/storage/memory-storage.d.ts +12 -0
  29. package/dist/auth/oauth/storage/memory-storage.js +40 -0
  30. package/dist/auth/oauth/types.d.ts +112 -0
  31. package/dist/cache/__tests__/cloudflare-kv-nonce-cache.test.d.ts +4 -0
  32. package/dist/cache/__tests__/cloudflare-kv-nonce-cache.test.js +176 -0
  33. package/dist/cache/__tests__/concurrency.test.d.ts +5 -0
  34. package/dist/cache/__tests__/concurrency.test.js +300 -0
  35. package/dist/cache/__tests__/dynamodb-nonce-cache.test.d.ts +4 -0
  36. package/dist/cache/__tests__/dynamodb-nonce-cache.test.js +176 -0
  37. package/dist/cache/__tests__/memory-nonce-cache.test.d.ts +4 -0
  38. package/dist/cache/__tests__/memory-nonce-cache.test.js +132 -0
  39. package/dist/cache/__tests__/nonce-cache-factory-simple.test.d.ts +4 -0
  40. package/dist/cache/__tests__/nonce-cache-factory-simple.test.js +133 -0
  41. package/dist/cache/__tests__/nonce-cache-factory.test.d.ts +4 -0
  42. package/dist/cache/__tests__/nonce-cache-factory.test.js +252 -0
  43. package/dist/cache/__tests__/redis-nonce-cache.test.d.ts +4 -0
  44. package/dist/cache/__tests__/redis-nonce-cache.test.js +95 -0
  45. package/dist/cache/cloudflare-kv-nonce-cache.d.ts +14 -0
  46. package/dist/cache/cloudflare-kv-nonce-cache.js +93 -0
  47. package/dist/cache/dynamodb-nonce-cache.d.ts +15 -0
  48. package/dist/cache/dynamodb-nonce-cache.js +92 -0
  49. package/dist/cache/index.d.ts +16 -0
  50. package/dist/cache/index.js +32 -0
  51. package/dist/cache/memory-nonce-cache.d.ts +44 -0
  52. package/dist/cache/memory-nonce-cache.js +105 -0
  53. package/dist/cache/nonce-cache-factory.d.ts +20 -0
  54. package/dist/cache/nonce-cache-factory.js +208 -0
  55. package/dist/cache/redis-nonce-cache.d.ts +14 -0
  56. package/dist/cache/redis-nonce-cache.js +53 -0
  57. package/dist/compiler/compiler-context.d.ts +23 -0
  58. package/dist/compiler/compiler-context.js +24 -0
  59. package/dist/compiler/config/constants.d.ts +41 -0
  60. package/dist/compiler/config/constants.js +45 -0
  61. package/dist/compiler/config/index.d.ts +252 -0
  62. package/dist/compiler/config/index.js +15 -0
  63. package/dist/compiler/config/injection.d.ts +26 -0
  64. package/dist/compiler/config/injection.js +58 -0
  65. package/dist/compiler/config/schemas/experimental/index.d.ts +91 -0
  66. package/dist/compiler/config/schemas/experimental/index.js +16 -0
  67. package/dist/compiler/config/schemas/experimental/oauth.d.ts +74 -0
  68. package/dist/compiler/config/schemas/experimental/oauth.js +25 -0
  69. package/dist/compiler/config/schemas/index.d.ts +6 -0
  70. package/dist/compiler/config/schemas/index.js +17 -0
  71. package/dist/compiler/config/schemas/paths.d.ts +9 -0
  72. package/dist/compiler/config/schemas/paths.js +12 -0
  73. package/dist/compiler/config/schemas/transport/http.d.ts +82 -0
  74. package/dist/compiler/config/schemas/transport/http.js +33 -0
  75. package/dist/compiler/config/schemas/transport/stdio.d.ts +9 -0
  76. package/dist/compiler/config/schemas/transport/stdio.js +15 -0
  77. package/dist/compiler/config/schemas/webpack.d.ts +3 -0
  78. package/dist/compiler/config/schemas/webpack.js +15 -0
  79. package/dist/compiler/config/types.d.ts +1 -0
  80. package/dist/compiler/config/types.js +2 -0
  81. package/dist/compiler/config/utils.d.ts +20 -0
  82. package/dist/compiler/config/utils.js +36 -0
  83. package/dist/compiler/generate-env-code.d.ts +1 -0
  84. package/dist/compiler/generate-env-code.js +8 -0
  85. package/dist/compiler/generate-import-code.d.ts +1 -0
  86. package/dist/compiler/generate-import-code.js +24 -0
  87. package/dist/compiler/get-webpack-config/get-entries.d.ts +3 -0
  88. package/dist/compiler/get-webpack-config/get-entries.js +29 -0
  89. package/dist/compiler/get-webpack-config/get-externals.d.ts +7 -0
  90. package/dist/compiler/get-webpack-config/get-externals.js +88 -0
  91. package/dist/compiler/get-webpack-config/get-injected-variables.d.ts +8 -0
  92. package/dist/compiler/get-webpack-config/get-injected-variables.js +25 -0
  93. package/dist/compiler/get-webpack-config/index.d.ts +4 -0
  94. package/dist/compiler/get-webpack-config/index.js +101 -0
  95. package/dist/compiler/get-webpack-config/plugins.d.ts +8 -0
  96. package/dist/compiler/get-webpack-config/plugins.js +132 -0
  97. package/dist/compiler/get-webpack-config/resolve-tsconfig-paths.d.ts +9 -0
  98. package/dist/compiler/get-webpack-config/resolve-tsconfig-paths.js +40 -0
  99. package/dist/compiler/index.d.ts +6 -0
  100. package/dist/compiler/index.js +194 -0
  101. package/dist/compiler/on-first-build.d.ts +3 -0
  102. package/dist/compiler/on-first-build.js +58 -0
  103. package/dist/compiler/parse-xmcp-config.d.ts +9 -0
  104. package/dist/compiler/parse-xmcp-config.js +155 -0
  105. package/dist/compiler/start-http-server.d.ts +1 -0
  106. package/dist/compiler/start-http-server.js +34 -0
  107. package/dist/index.d.ts +12 -0
  108. package/dist/index.js +38 -0
  109. package/dist/index.js.LICENSE.txt +49 -0
  110. package/dist/runtime/__tests__/audit.test.d.ts +4 -0
  111. package/dist/runtime/__tests__/audit.test.js +328 -0
  112. package/dist/runtime/__tests__/identity.test.d.ts +4 -0
  113. package/dist/runtime/__tests__/identity.test.js +164 -0
  114. package/dist/runtime/__tests__/mcpi-runtime.test.d.ts +4 -0
  115. package/dist/runtime/__tests__/mcpi-runtime.test.js +372 -0
  116. package/dist/runtime/__tests__/proof.test.d.ts +4 -0
  117. package/dist/runtime/__tests__/proof.test.js +302 -0
  118. package/dist/runtime/__tests__/session.test.d.ts +4 -0
  119. package/dist/runtime/__tests__/session.test.js +254 -0
  120. package/dist/runtime/__tests__/well-known.test.d.ts +4 -0
  121. package/dist/runtime/__tests__/well-known.test.js +312 -0
  122. package/dist/runtime/adapter-express.js +2 -0
  123. package/dist/runtime/adapter-express.js.LICENSE.txt +252 -0
  124. package/dist/runtime/adapter-nextjs.js +2 -0
  125. package/dist/runtime/adapter-nextjs.js.LICENSE.txt +53 -0
  126. package/dist/runtime/adapters/express/index.d.ts +2 -0
  127. package/dist/runtime/adapters/express/index.js +48 -0
  128. package/dist/runtime/adapters/nextjs/index.d.ts +8 -0
  129. package/dist/runtime/adapters/nextjs/index.js +18 -0
  130. package/dist/runtime/audit.d.ts +93 -0
  131. package/dist/runtime/audit.js +212 -0
  132. package/dist/runtime/debug.d.ts +118 -0
  133. package/dist/runtime/debug.js +612 -0
  134. package/dist/runtime/delegation-hooks.d.ts +85 -0
  135. package/dist/runtime/delegation-hooks.js +116 -0
  136. package/dist/runtime/demo.d.ts +71 -0
  137. package/dist/runtime/demo.js +135 -0
  138. package/dist/runtime/headers.d.ts +1 -0
  139. package/dist/runtime/headers.js +9 -0
  140. package/dist/runtime/http.js +2 -0
  141. package/dist/runtime/http.js.LICENSE.txt +252 -0
  142. package/dist/runtime/identity.d.ts +105 -0
  143. package/dist/runtime/identity.js +232 -0
  144. package/dist/runtime/index.d.ts +16 -0
  145. package/dist/runtime/index.js +56 -0
  146. package/dist/runtime/mcpi-runtime.d.ts +164 -0
  147. package/dist/runtime/mcpi-runtime.js +352 -0
  148. package/dist/runtime/proof.d.ts +87 -0
  149. package/dist/runtime/proof.js +223 -0
  150. package/dist/runtime/session.d.ts +88 -0
  151. package/dist/runtime/session.js +216 -0
  152. package/dist/runtime/stdio.js +2 -0
  153. package/dist/runtime/stdio.js.LICENSE.txt +1 -0
  154. package/dist/runtime/templates/home.d.ts +2 -0
  155. package/dist/runtime/templates/home.js +50 -0
  156. package/dist/runtime/transports/http/base-streamable-http.d.ts +25 -0
  157. package/dist/runtime/transports/http/base-streamable-http.js +16 -0
  158. package/dist/runtime/transports/http/http-context.d.ts +9 -0
  159. package/dist/runtime/transports/http/http-context.js +8 -0
  160. package/dist/runtime/transports/http/index.js +55 -0
  161. package/dist/runtime/transports/http/setup-cors.d.ts +4 -0
  162. package/dist/runtime/transports/http/setup-cors.js +24 -0
  163. package/dist/runtime/transports/http/stateless-streamable-http.d.ts +39 -0
  164. package/dist/runtime/transports/http/stateless-streamable-http.js +331 -0
  165. package/dist/runtime/transports/stdio/index.d.ts +1 -0
  166. package/dist/runtime/transports/stdio/index.js +51 -0
  167. package/dist/runtime/utils/server.d.ts +42 -0
  168. package/dist/runtime/utils/server.js +39 -0
  169. package/dist/runtime/utils/tools.d.ts +8 -0
  170. package/dist/runtime/utils/tools.js +115 -0
  171. package/dist/runtime/verifier-middleware.d.ts +76 -0
  172. package/dist/runtime/verifier-middleware.js +322 -0
  173. package/dist/runtime/well-known.d.ts +151 -0
  174. package/dist/runtime/well-known.js +258 -0
  175. package/dist/storage/config.d.ts +28 -0
  176. package/dist/storage/config.js +79 -0
  177. package/dist/storage/delegation.d.ts +59 -0
  178. package/dist/storage/delegation.js +130 -0
  179. package/dist/storage/merkle-verifier.d.ts +84 -0
  180. package/dist/storage/merkle-verifier.js +261 -0
  181. package/dist/test/__tests__/nonce-cache-integration.test.d.ts +1 -0
  182. package/dist/test/__tests__/nonce-cache-integration.test.js +116 -0
  183. package/dist/test/__tests__/nonce-cache.test.d.ts +1 -0
  184. package/dist/test/__tests__/nonce-cache.test.js +122 -0
  185. package/dist/test/__tests__/runtime-integration.test.d.ts +4 -0
  186. package/dist/test/__tests__/runtime-integration.test.js +192 -0
  187. package/dist/test/__tests__/test-infrastructure.test.d.ts +4 -0
  188. package/dist/test/__tests__/test-infrastructure.test.js +178 -0
  189. package/dist/test/deterministic-keys.d.ts +31 -0
  190. package/dist/test/deterministic-keys.js +108 -0
  191. package/dist/test/examples/test-usage-example.d.ts +140 -0
  192. package/dist/test/examples/test-usage-example.js +175 -0
  193. package/dist/test/index.d.ts +11 -0
  194. package/dist/test/index.js +27 -0
  195. package/dist/test/local-verification.d.ts +28 -0
  196. package/dist/test/local-verification.js +342 -0
  197. package/dist/test/mock-identity-provider.d.ts +96 -0
  198. package/dist/test/mock-identity-provider.js +243 -0
  199. package/dist/test/runtime-integration.d.ts +63 -0
  200. package/dist/test/runtime-integration.js +140 -0
  201. package/dist/test/test-environment.d.ts +26 -0
  202. package/dist/test/test-environment.js +50 -0
  203. package/dist/types/declarations.d.ts +1 -0
  204. package/dist/types/declarations.js +6 -0
  205. package/dist/types/middleware.d.ts +2 -0
  206. package/dist/types/middleware.js +2 -0
  207. package/dist/types/tool.d.ts +80 -0
  208. package/dist/types/tool.js +2 -0
  209. package/dist/utils/cli-icons.d.ts +3 -0
  210. package/dist/utils/cli-icons.js +7 -0
  211. package/dist/utils/constants.d.ts +6 -0
  212. package/dist/utils/constants.js +13 -0
  213. package/dist/utils/context.d.ts +33 -0
  214. package/dist/utils/context.js +58 -0
  215. package/dist/utils/file-watcher.d.ts +19 -0
  216. package/dist/utils/file-watcher.js +49 -0
  217. package/dist/utils/fs-utils.d.ts +2 -0
  218. package/dist/utils/fs-utils.js +22 -0
  219. package/dist/utils/path-validation.d.ts +3 -0
  220. package/dist/utils/path-validation.js +56 -0
  221. package/dist/utils/spawn-process.d.ts +9 -0
  222. package/dist/utils/spawn-process.js +50 -0
  223. package/dist/utils/subscribable.d.ts +12 -0
  224. package/dist/utils/subscribable.js +44 -0
  225. package/package.json +91 -77
  226. package/dist/cjs/auto.js +0 -16
  227. package/dist/cjs/cli-mode.d.ts +0 -16
  228. package/dist/cjs/cli-mode.js +0 -32
  229. package/dist/cjs/crypto.d.ts +0 -16
  230. package/dist/cjs/crypto.js +0 -212
  231. package/dist/cjs/dev-helper.d.ts +0 -3
  232. package/dist/cjs/dev-helper.js +0 -46
  233. package/dist/cjs/encrypted-storage.d.ts +0 -11
  234. package/dist/cjs/encrypted-storage.js +0 -73
  235. package/dist/cjs/index.d.ts +0 -56
  236. package/dist/cjs/index.js +0 -727
  237. package/dist/cjs/logger.d.ts +0 -32
  238. package/dist/cjs/logger.js +0 -85
  239. package/dist/cjs/nextjs.d.ts +0 -10
  240. package/dist/cjs/nextjs.js +0 -83
  241. package/dist/cjs/platform-info.d.ts +0 -36
  242. package/dist/cjs/platform-info.js +0 -274
  243. package/dist/cjs/polling.d.ts +0 -13
  244. package/dist/cjs/polling.js +0 -52
  245. package/dist/cjs/registry/index.d.ts +0 -12
  246. package/dist/cjs/registry/index.js +0 -56
  247. package/dist/cjs/registry/knowthat.d.ts +0 -17
  248. package/dist/cjs/registry/knowthat.js +0 -173
  249. package/dist/cjs/rotation.d.ts +0 -35
  250. package/dist/cjs/rotation.js +0 -102
  251. package/dist/cjs/storage.d.ts +0 -41
  252. package/dist/cjs/storage.js +0 -163
  253. package/dist/cjs/transport.d.ts +0 -35
  254. package/dist/cjs/transport.js +0 -300
  255. package/dist/cjs/types.d.ts +0 -206
  256. package/dist/cjs/vercel-adapter.d.ts +0 -8
  257. package/dist/cjs/vercel-adapter.js +0 -67
  258. package/dist/esm/auto.d.ts +0 -13
  259. package/dist/esm/auto.d.ts.map +0 -1
  260. package/dist/esm/auto.js +0 -30
  261. package/dist/esm/auto.js.map +0 -1
  262. package/dist/esm/cli-mode.d.ts +0 -52
  263. package/dist/esm/cli-mode.d.ts.map +0 -1
  264. package/dist/esm/cli-mode.js +0 -59
  265. package/dist/esm/cli-mode.js.map +0 -1
  266. package/dist/esm/crypto.d.ts +0 -51
  267. package/dist/esm/crypto.d.ts.map +0 -1
  268. package/dist/esm/crypto.js +0 -230
  269. package/dist/esm/crypto.js.map +0 -1
  270. package/dist/esm/dev-helper.d.ts +0 -15
  271. package/dist/esm/dev-helper.d.ts.map +0 -1
  272. package/dist/esm/dev-helper.js +0 -63
  273. package/dist/esm/dev-helper.js.map +0 -1
  274. package/dist/esm/encrypted-storage.d.ts +0 -19
  275. package/dist/esm/encrypted-storage.d.ts.map +0 -1
  276. package/dist/esm/encrypted-storage.js +0 -48
  277. package/dist/esm/encrypted-storage.js.map +0 -1
  278. package/dist/esm/index.d.ts +0 -129
  279. package/dist/esm/index.d.ts.map +0 -1
  280. package/dist/esm/index.js +0 -853
  281. package/dist/esm/index.js.map +0 -1
  282. package/dist/esm/logger.d.ts +0 -46
  283. package/dist/esm/logger.d.ts.map +0 -1
  284. package/dist/esm/logger.js +0 -100
  285. package/dist/esm/logger.js.map +0 -1
  286. package/dist/esm/nextjs.d.ts +0 -22
  287. package/dist/esm/nextjs.d.ts.map +0 -1
  288. package/dist/esm/nextjs.js +0 -83
  289. package/dist/esm/nextjs.js.map +0 -1
  290. package/dist/esm/package.json +0 -1
  291. package/dist/esm/platform-info.d.ts +0 -74
  292. package/dist/esm/platform-info.d.ts.map +0 -1
  293. package/dist/esm/platform-info.js +0 -293
  294. package/dist/esm/platform-info.js.map +0 -1
  295. package/dist/esm/polling.d.ts +0 -29
  296. package/dist/esm/polling.d.ts.map +0 -1
  297. package/dist/esm/polling.js +0 -76
  298. package/dist/esm/polling.js.map +0 -1
  299. package/dist/esm/registry/index.d.ts +0 -43
  300. package/dist/esm/registry/index.d.ts.map +0 -1
  301. package/dist/esm/registry/index.js +0 -89
  302. package/dist/esm/registry/index.js.map +0 -1
  303. package/dist/esm/registry/knowthat.d.ts +0 -44
  304. package/dist/esm/registry/knowthat.d.ts.map +0 -1
  305. package/dist/esm/registry/knowthat.js +0 -220
  306. package/dist/esm/registry/knowthat.js.map +0 -1
  307. package/dist/esm/rotation.d.ts +0 -57
  308. package/dist/esm/rotation.d.ts.map +0 -1
  309. package/dist/esm/rotation.js +0 -133
  310. package/dist/esm/rotation.js.map +0 -1
  311. package/dist/esm/storage.d.ts +0 -65
  312. package/dist/esm/storage.d.ts.map +0 -1
  313. package/dist/esm/storage.js +0 -160
  314. package/dist/esm/storage.js.map +0 -1
  315. package/dist/esm/transport.d.ts +0 -52
  316. package/dist/esm/transport.d.ts.map +0 -1
  317. package/dist/esm/transport.js +0 -340
  318. package/dist/esm/transport.js.map +0 -1
  319. package/dist/esm/types.d.ts +0 -293
  320. package/dist/esm/types.d.ts.map +0 -1
  321. package/dist/esm/types.js +0 -5
  322. package/dist/esm/types.js.map +0 -1
  323. package/dist/esm/vercel-adapter.d.ts +0 -26
  324. package/dist/esm/vercel-adapter.d.ts.map +0 -1
  325. package/dist/esm/vercel-adapter.js +0 -80
  326. package/dist/esm/vercel-adapter.js.map +0 -1
  327. /package/dist/{cjs → auth/oauth}/types.js +0 -0
  328. /package/dist/{cjs/auto.d.ts → runtime/transports/http/index.d.ts} +0 -0
@@ -1,300 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransportFactory = exports.RuntimeDetector = exports.AxiosTransport = exports.FetchTransport = void 0;
4
- class FetchTransport {
5
- async post(url, data, options) {
6
- const controller = new AbortController();
7
- const timeout = options?.timeout || 30000;
8
- const timeoutId = setTimeout(() => controller.abort(), timeout);
9
- try {
10
- const response = await fetch(url, {
11
- method: 'POST',
12
- headers: {
13
- 'Content-Type': 'application/json',
14
- ...options?.headers
15
- },
16
- body: JSON.stringify(data),
17
- signal: controller.signal
18
- });
19
- clearTimeout(timeoutId);
20
- if (!response.ok) {
21
- let errorMessage = '';
22
- let errorData = null;
23
- try {
24
- errorData = await response.json();
25
- if (errorData.suggestion) {
26
- errorMessage = `${errorData.error || errorData.message || 'Request failed'}. ${errorData.suggestion}`;
27
- }
28
- else {
29
- errorMessage = errorData.message || errorData.error || '';
30
- }
31
- }
32
- catch {
33
- errorMessage = await response.text();
34
- }
35
- if (response.status === 429) {
36
- throw new Error('Rate limit exceeded. Please wait a few minutes and try again.');
37
- }
38
- else if (response.status === 403) {
39
- throw new Error('Access forbidden. Please check your API credentials.');
40
- }
41
- else if (response.status === 404) {
42
- throw new Error('API endpoint not found. The service might be unavailable.');
43
- }
44
- else if (response.status === 500 || response.status === 502 || response.status === 503) {
45
- throw new Error('Server error during registration. This might be a temporary issue. Please try again in a few moments.');
46
- }
47
- else if (response.status === 400) {
48
- throw new Error(`Bad request: ${errorMessage || 'Invalid registration data'}`);
49
- }
50
- throw new Error(`HTTP ${response.status}: ${errorMessage || 'Request failed'}`);
51
- }
52
- const responseData = await response.json();
53
- return {
54
- data: responseData,
55
- status: response.status,
56
- headers: Object.fromEntries(response.headers.entries())
57
- };
58
- }
59
- catch (error) {
60
- clearTimeout(timeoutId);
61
- if (error.name === 'AbortError') {
62
- throw new Error('Request timeout. The server is taking too long to respond. Please try again.');
63
- }
64
- throw error;
65
- }
66
- }
67
- async get(url, options) {
68
- const controller = new AbortController();
69
- const timeout = options?.timeout || 30000;
70
- const timeoutId = setTimeout(() => controller.abort(), timeout);
71
- try {
72
- const response = await fetch(url, {
73
- method: 'GET',
74
- headers: options?.headers,
75
- signal: controller.signal
76
- });
77
- clearTimeout(timeoutId);
78
- if (!response.ok) {
79
- let errorMessage = '';
80
- let errorData = null;
81
- try {
82
- errorData = await response.json();
83
- if (errorData.suggestion) {
84
- errorMessage = `${errorData.error || errorData.message || 'Request failed'}. ${errorData.suggestion}`;
85
- }
86
- else {
87
- errorMessage = errorData.message || errorData.error || '';
88
- }
89
- }
90
- catch {
91
- errorMessage = await response.text();
92
- }
93
- if (response.status === 429) {
94
- throw new Error('Rate limit exceeded. Please wait a few minutes and try again.');
95
- }
96
- else if (response.status === 403) {
97
- throw new Error('Access forbidden. Please check your API credentials.');
98
- }
99
- else if (response.status === 404) {
100
- throw new Error('API endpoint not found. The service might be unavailable.');
101
- }
102
- else if (response.status === 500 || response.status === 502 || response.status === 503) {
103
- throw new Error('Server error during registration. This might be a temporary issue. Please try again in a few moments.');
104
- }
105
- else if (response.status === 400) {
106
- throw new Error(`Bad request: ${errorMessage || 'Invalid registration data'}`);
107
- }
108
- throw new Error(`HTTP ${response.status}: ${errorMessage || 'Request failed'}`);
109
- }
110
- const responseData = await response.json();
111
- return {
112
- data: responseData,
113
- status: response.status,
114
- headers: Object.fromEntries(response.headers.entries())
115
- };
116
- }
117
- catch (error) {
118
- clearTimeout(timeoutId);
119
- if (error.name === 'AbortError') {
120
- throw new Error('Request timeout. The server is taking too long to respond. Please try again.');
121
- }
122
- throw error;
123
- }
124
- }
125
- }
126
- exports.FetchTransport = FetchTransport;
127
- class AxiosTransport {
128
- async post(url, data, options) {
129
- const axios = await this.getAxios();
130
- try {
131
- const response = await axios.post(url, data, {
132
- timeout: options?.timeout || 30000,
133
- headers: options?.headers
134
- });
135
- return {
136
- data: response.data,
137
- status: response.status,
138
- headers: response.headers
139
- };
140
- }
141
- catch (error) {
142
- if (error.response) {
143
- const status = error.response.status;
144
- let errorMessage = '';
145
- if (error.response.data?.suggestion) {
146
- errorMessage = `${error.response.data.error || error.response.data.message || 'Request failed'}. ${error.response.data.suggestion}`;
147
- }
148
- else {
149
- errorMessage = error.response.data?.message || error.response.data?.error || '';
150
- }
151
- if (status === 429) {
152
- throw new Error('Rate limit exceeded. Please wait a few minutes and try again.');
153
- }
154
- else if (status === 403) {
155
- throw new Error('Access forbidden. Please check your API credentials.');
156
- }
157
- else if (status === 404) {
158
- throw new Error('API endpoint not found. The service might be unavailable.');
159
- }
160
- else if (status === 500 || status === 502 || status === 503) {
161
- throw new Error('Server error during registration. This might be a temporary issue. Please try again in a few moments.');
162
- }
163
- else if (status === 400) {
164
- throw new Error(`Bad request: ${errorMessage || 'Invalid registration data'}`);
165
- }
166
- throw new Error(`HTTP ${status}: ${errorMessage || 'Request failed'}`);
167
- }
168
- else if (error.request) {
169
- throw new Error('No response from server. Please check your internet connection.');
170
- }
171
- else {
172
- throw new Error(error.message || 'Request failed');
173
- }
174
- }
175
- }
176
- async get(url, options) {
177
- const axios = await this.getAxios();
178
- try {
179
- const response = await axios.get(url, {
180
- timeout: options?.timeout || 30000,
181
- headers: options?.headers
182
- });
183
- return {
184
- data: response.data,
185
- status: response.status,
186
- headers: response.headers
187
- };
188
- }
189
- catch (error) {
190
- if (error.response) {
191
- const status = error.response.status;
192
- let errorMessage = '';
193
- if (error.response.data?.suggestion) {
194
- errorMessage = `${error.response.data.error || error.response.data.message || 'Request failed'}. ${error.response.data.suggestion}`;
195
- }
196
- else {
197
- errorMessage = error.response.data?.message || error.response.data?.error || '';
198
- }
199
- if (status === 429) {
200
- throw new Error('Rate limit exceeded. Please wait a few minutes and try again.');
201
- }
202
- else if (status === 403) {
203
- throw new Error('Access forbidden. Please check your API credentials.');
204
- }
205
- else if (status === 404) {
206
- throw new Error('API endpoint not found. The service might be unavailable.');
207
- }
208
- else if (status === 500 || status === 502 || status === 503) {
209
- throw new Error('Server error. This might be a temporary issue. Please try again in a few moments.');
210
- }
211
- else if (status === 400) {
212
- throw new Error(`Bad request: ${errorMessage || 'Invalid request data'}`);
213
- }
214
- throw new Error(`HTTP ${status}: ${errorMessage || 'Request failed'}`);
215
- }
216
- else if (error.request) {
217
- throw new Error('No response from server. Please check your internet connection.');
218
- }
219
- else {
220
- throw new Error(error.message || 'Request failed');
221
- }
222
- }
223
- }
224
- async getAxios() {
225
- if (!this.axiosInstance) {
226
- try {
227
- const axios = require('axios');
228
- this.axiosInstance = axios.default || axios;
229
- }
230
- catch (error) {
231
- throw new Error('axios is not installed. Please install it with: npm install axios\n' +
232
- 'Or use the fetch transport instead by setting transport: "fetch" in options');
233
- }
234
- }
235
- return this.axiosInstance;
236
- }
237
- }
238
- exports.AxiosTransport = AxiosTransport;
239
- class RuntimeDetector {
240
- static isEdgeRuntime() {
241
- return !!(globalThis.EdgeRuntime ||
242
- process.env.NEXT_RUNTIME === 'edge' ||
243
- process.env.VERCEL_EDGE ||
244
- globalThis.Deno ||
245
- globalThis.Bun);
246
- }
247
- static isNodeRuntime() {
248
- return !!(process.versions?.node &&
249
- !this.isEdgeRuntime() &&
250
- !this.isNextJs());
251
- }
252
- static isNextJs() {
253
- return !!(process.env.NEXT_RUNTIME ||
254
- globalThis.__NEXT_DATA__ ||
255
- process.env.NEXT_PUBLIC_VERCEL_ENV);
256
- }
257
- static hasFetch() {
258
- return typeof globalThis.fetch === 'function';
259
- }
260
- static isLambda() {
261
- return !!(process.env.AWS_LAMBDA_FUNCTION_NAME ||
262
- process.env.LAMBDA_TASK_ROOT ||
263
- process.env._HANDLER);
264
- }
265
- }
266
- exports.RuntimeDetector = RuntimeDetector;
267
- class TransportFactory {
268
- static create(options) {
269
- const transportType = options?.transport || 'auto';
270
- if (transportType === 'fetch') {
271
- if (!RuntimeDetector.hasFetch()) {
272
- throw new Error('Fetch is not available in this runtime');
273
- }
274
- return new FetchTransport();
275
- }
276
- if (transportType === 'axios') {
277
- return new AxiosTransport();
278
- }
279
- if (transportType === 'auto') {
280
- if (RuntimeDetector.isEdgeRuntime() && RuntimeDetector.hasFetch()) {
281
- return new FetchTransport();
282
- }
283
- if (RuntimeDetector.isNextJs() && RuntimeDetector.hasFetch()) {
284
- return new FetchTransport();
285
- }
286
- if (RuntimeDetector.isLambda() && RuntimeDetector.hasFetch()) {
287
- return new FetchTransport();
288
- }
289
- if (RuntimeDetector.isNodeRuntime()) {
290
- return new AxiosTransport();
291
- }
292
- if (RuntimeDetector.hasFetch()) {
293
- return new FetchTransport();
294
- }
295
- return new AxiosTransport();
296
- }
297
- throw new Error(`Unknown transport type: ${transportType}`);
298
- }
299
- }
300
- exports.TransportFactory = TransportFactory;
@@ -1,206 +0,0 @@
1
- export type RegistryName = string;
2
- export type RegistryTier = 'verified';
3
- export interface RegistryConfig {
4
- include?: string[] | 'verified';
5
- exclude?: string[];
6
- }
7
- export interface RegistryStatus {
8
- name: string;
9
- status: 'active' | 'pending' | 'failed';
10
- registeredAt?: string;
11
- type?: 'primary' | 'secondary';
12
- error?: string;
13
- }
14
- export interface RegistryAdapter {
15
- name: string;
16
- type: 'primary' | 'secondary';
17
- publish(data: any): Promise<any>;
18
- verify?(did: string): Promise<boolean>;
19
- }
20
- export interface RegistryPublishData {
21
- did: string;
22
- name: string;
23
- description?: string;
24
- repository?: string;
25
- publicKey: string;
26
- metadata?: Record<string, any>;
27
- }
28
- export interface RegistryPublishResult {
29
- success: boolean;
30
- registryAgentId?: string;
31
- profileUrl?: string;
32
- error?: string;
33
- claimUrl?: string;
34
- claimToken?: string;
35
- generatedKeys?: {
36
- publicKey: string;
37
- privateKey: string;
38
- warning: string;
39
- };
40
- }
41
- export type DirectoryPreference = string[] | 'verified' | 'none';
42
- export type DirectoryName = 'smithery' | 'glama' | string;
43
- export interface MCPIdentityProgressEvent {
44
- stage: 'checking_existing' | 'generating_keys' | 'registering' | 'saving' | 'complete';
45
- progress: number;
46
- message?: string;
47
- data?: any;
48
- }
49
- export interface MCPIdentityProgressCallback {
50
- (event: MCPIdentityProgressEvent): void;
51
- }
52
- export interface MCPIdentityOptions {
53
- name?: string;
54
- description?: string;
55
- repository?: string;
56
- apiEndpoint?: string;
57
- persistencePath?: string;
58
- storage?: 'file' | 'memory' | 'auto';
59
- memoryKey?: string;
60
- transport?: 'axios' | 'fetch' | 'auto';
61
- processingMode?: 'sync' | 'async' | 'auto';
62
- registryEndpoint?: 'cli' | 'auto-register' | 'auto';
63
- timestampTolerance?: number;
64
- enableNonceTracking?: boolean;
65
- encryptionPassword?: string;
66
- directories?: DirectoryPreference;
67
- mode?: 'development' | 'production';
68
- logger?: Logger;
69
- logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
70
- onProgress?: MCPIdentityProgressCallback;
71
- registrationPollInterval?: number;
72
- registrationMaxPollingTime?: number;
73
- registrationPollBackoff?: boolean;
74
- }
75
- export interface MCPServer {
76
- setRequestHandler(method: string, handler: Function): void;
77
- connect(transport: any): Promise<void>;
78
- serverInfo?: {
79
- capabilities?: Record<string, any>;
80
- };
81
- }
82
- export interface MCPMiddleware {
83
- (server: MCPServer, identity: any): void;
84
- }
85
- export interface MCPRequest<T = any> {
86
- method: string;
87
- params?: T;
88
- }
89
- export interface MCPResponse<T = any> {
90
- content?: T;
91
- error?: {
92
- code: number;
93
- message: string;
94
- };
95
- }
96
- export interface Logger {
97
- debug(message: string, ...args: any[]): void;
98
- info(message: string, ...args: any[]): void;
99
- warn(message: string, ...args: any[]): void;
100
- error(message: string, ...args: any[]): void;
101
- }
102
- export interface AutoRegisterResponse {
103
- success: boolean;
104
- did: string;
105
- agent: {
106
- id: string;
107
- slug: string;
108
- name: string;
109
- url: string;
110
- };
111
- keys: {
112
- publicKey: string;
113
- privateKey?: string;
114
- };
115
- }
116
- export interface AsyncRegistrationResponse {
117
- success: boolean;
118
- jobId: string;
119
- status: string;
120
- message: string;
121
- estimatedTime: string;
122
- }
123
- export interface RegistrationStatusResponse {
124
- jobId: string;
125
- status: 'pending' | 'processing' | 'completed' | 'failed';
126
- result?: AutoRegisterResponse;
127
- error?: {
128
- message: string;
129
- code?: string;
130
- };
131
- progress?: number;
132
- estimatedTimeRemaining?: number;
133
- }
134
- export interface CLIRegisterRequest {
135
- name: string;
136
- description?: string;
137
- repository?: string;
138
- publicKey?: string;
139
- }
140
- export interface CLIRegisterResponse {
141
- success: boolean;
142
- did: string;
143
- agent: {
144
- id: string;
145
- slug: string;
146
- name: string;
147
- url: string;
148
- };
149
- claimUrl: string;
150
- claimToken: string;
151
- keys?: {
152
- publicKey: string;
153
- privateKey: string;
154
- warning: string;
155
- };
156
- responseTime: number;
157
- }
158
- export interface PersistedIdentity {
159
- did: string;
160
- publicKey: string;
161
- privateKey: string;
162
- agentId: string;
163
- agentSlug: string;
164
- registeredAt: string;
165
- directories?: DirectoryPreference;
166
- }
167
- export interface RegistrationData {
168
- name: string;
169
- description?: string;
170
- repository?: string;
171
- publicKey?: string;
172
- directories?: DirectoryPreference;
173
- metadata?: Record<string, any>;
174
- }
175
- export interface Challenge {
176
- nonce: string;
177
- timestamp: number;
178
- verifier_did?: string;
179
- scope?: string[];
180
- }
181
- export interface ChallengeResponse {
182
- did: string;
183
- signature: string;
184
- timestamp: number;
185
- nonce: string;
186
- publicKey?: string;
187
- }
188
- export interface MCPICapabilities {
189
- version: string;
190
- did: string;
191
- publicKey: string;
192
- conformanceLevel: number;
193
- handshakeSupported: boolean;
194
- handshakeEndpoint?: string;
195
- verificationEndpoint?: string;
196
- registry?: string;
197
- }
198
- export interface SignedResponse<T = any> {
199
- [key: string]: any;
200
- _mcp_identity: {
201
- did: string;
202
- signature: string;
203
- timestamp: string;
204
- conformanceLevel?: number;
205
- };
206
- }
@@ -1,8 +0,0 @@
1
- import { MCPIdentityOptions, PersistedIdentity } from './types';
2
- export interface VercelMCPIdentityOptions extends MCPIdentityOptions {
3
- envPrefix?: string;
4
- showClaimInstructions?: boolean;
5
- }
6
- export declare function loadIdentityFromEnv(prefix?: string): PersistedIdentity | null;
7
- export declare function generateEnvInstructions(identity: PersistedIdentity, prefix?: string): string;
8
- export declare function showVercelDeveloperInstructions(identity: PersistedIdentity, claimUrl?: string): void;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadIdentityFromEnv = loadIdentityFromEnv;
4
- exports.generateEnvInstructions = generateEnvInstructions;
5
- exports.showVercelDeveloperInstructions = showVercelDeveloperInstructions;
6
- const logger_1 = require("./logger");
7
- function loadIdentityFromEnv(prefix = 'MCP_IDENTITY_') {
8
- const logger = (0, logger_1.getLogger)();
9
- try {
10
- const did = process.env[`${prefix}DID`];
11
- const publicKey = process.env[`${prefix}PUBLIC_KEY`];
12
- const privateKey = process.env[`${prefix}PRIVATE_KEY`];
13
- const agentId = process.env[`${prefix}AGENT_ID`];
14
- const agentSlug = process.env[`${prefix}AGENT_SLUG`];
15
- if (did && publicKey && privateKey) {
16
- logger.info('šŸ“¦ Loaded identity from environment variables');
17
- return {
18
- did,
19
- publicKey,
20
- privateKey,
21
- agentId: agentId || 'unknown',
22
- agentSlug: agentSlug || 'unknown',
23
- registeredAt: new Date().toISOString(),
24
- directories: 'verified'
25
- };
26
- }
27
- }
28
- catch (error) {
29
- logger.debug('No identity found in environment variables');
30
- }
31
- return null;
32
- }
33
- function generateEnvInstructions(identity, prefix = 'MCP_IDENTITY_') {
34
- return `
35
- # Add these to your Vercel environment variables:
36
- ${prefix}DID="${identity.did}"
37
- ${prefix}PUBLIC_KEY="${identity.publicKey}"
38
- ${prefix}PRIVATE_KEY="${identity.privateKey}"
39
- ${prefix}AGENT_ID="${identity.agentId}"
40
- ${prefix}AGENT_SLUG="${identity.agentSlug}"
41
- `;
42
- }
43
- function showVercelDeveloperInstructions(identity, claimUrl) {
44
- const logger = (0, logger_1.getLogger)();
45
- console.log('\n');
46
- console.log('='.repeat(60));
47
- console.log('šŸŽ‰ MCP-I IDENTITY CREATED SUCCESSFULLY! šŸŽ‰');
48
- console.log('='.repeat(60));
49
- console.log('\nšŸ“‹ Your Agent Details:\n');
50
- console.log(` DID: ${identity.did}`);
51
- console.log(` Agent ID: ${identity.agentId}`);
52
- console.log(` Profile: https://knowthat.ai/agents/${identity.agentSlug}`);
53
- if (claimUrl) {
54
- console.log('\nšŸŽÆ IMPORTANT: Claim your agent to manage it:');
55
- console.log(` ${claimUrl}`);
56
- console.log('\n This link lets you:');
57
- console.log(' - Edit your agent details');
58
- console.log(' - Add logos and descriptions');
59
- console.log(' - Manage directory listings');
60
- console.log(' - View analytics');
61
- }
62
- console.log('\n⚔ For Vercel Deployment:');
63
- console.log('\n1. Add these environment variables in Vercel Dashboard:');
64
- console.log(generateEnvInstructions(identity));
65
- console.log('2. Your identity will persist across deployments!');
66
- console.log('\n' + '='.repeat(60) + '\n');
67
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Auto-initialization for MCP Identity
3
- *
4
- * Just import this file to automatically enable MCP-I for any MCP server:
5
- *
6
- * ```typescript
7
- * import "@kya-os/mcp-i/auto";
8
- * ```
9
- *
10
- * That's it! Your MCP server now has identity.
11
- */
12
- export {};
13
- //# sourceMappingURL=auto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto.d.ts","sourceRoot":"","sources":["../../src/auto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
package/dist/esm/auto.js DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * Auto-initialization for MCP Identity
3
- *
4
- * Just import this file to automatically enable MCP-I for any MCP server:
5
- *
6
- * ```typescript
7
- * import "@kya-os/mcp-i/auto";
8
- * ```
9
- *
10
- * That's it! Your MCP server now has identity.
11
- */
12
- import { enableMCPIdentity } from './index.js';
13
- import { getLogger } from './logger.js';
14
- // Auto-initialize on import
15
- (async () => {
16
- try {
17
- await enableMCPIdentity();
18
- }
19
- catch (error) {
20
- const logger = getLogger();
21
- logger.error('[MCP-I] Failed to auto-initialize:', error);
22
- // More detailed error logging for debugging
23
- if (error.stack) {
24
- logger.debug('[MCP-I] Error stack:', error.stack);
25
- }
26
- // Don't throw the error - allow the server to continue running
27
- // even if MCP-I initialization fails
28
- }
29
- })();
30
- //# sourceMappingURL=auto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto.js","sourceRoot":"","sources":["../../src/auto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,4BAA4B;AAC5B,CAAC,KAAK,IAAI,EAAE;IACV,IAAI,CAAC;QACH,MAAM,iBAAiB,EAAE,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;QAE1D,4CAA4C;QAC5C,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QACpD,CAAC;QAED,+DAA+D;QAC/D,qCAAqC;IACvC,CAAC;AACH,CAAC,CAAC,EAAE,CAAC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * CLI Mode for MCP-I Package
3
- * @internal - For use by @kya-os/cli package only
4
- * @private
5
- *
6
- * This module provides a specialized interface for the KYA-OS CLI
7
- * with enhanced progress reporting and silent logging by default.
8
- */
9
- import { MCPIdentityOptions, MCPIdentityProgressCallback } from './types.js';
10
- import { MCPIdentity } from './index.js';
11
- /**
12
- * CLI-specific options that extend the base options
13
- * @internal
14
- */
15
- interface MCPIdentityCLIOptions extends Omit<MCPIdentityOptions, 'logLevel'> {
16
- /**
17
- * Log level - defaults to 'silent' for CLI usage
18
- */
19
- logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
20
- /**
21
- * Progress callback is strongly recommended for CLI usage
22
- */
23
- onProgress?: MCPIdentityProgressCallback;
24
- }
25
- /**
26
- * Enable MCP Identity with CLI-optimized defaults
27
- * @internal - For use by @kya-os/cli package only
28
- *
29
- * This function:
30
- * - Sets silent logging by default
31
- * - Provides structured progress events
32
- * - Returns additional metadata useful for CLI animations
33
- * - Optimizes for the best CLI experience
34
- *
35
- * @param options Configuration options
36
- * @returns MCPIdentity instance with additional CLI metadata
37
- */
38
- export declare function enableMCPIdentityCLI(options?: MCPIdentityCLIOptions): Promise<{
39
- identity: MCPIdentity;
40
- metadata: {
41
- isNewIdentity: boolean;
42
- did: string;
43
- claimUrl?: string;
44
- registryUrl: string;
45
- };
46
- }>;
47
- /**
48
- * Re-export types that CLI might need
49
- * @internal
50
- */
51
- export type { MCPIdentityProgressEvent, MCPIdentityProgressCallback } from './types.js';
52
- //# sourceMappingURL=cli-mode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli-mode.d.ts","sourceRoot":"","sources":["../../src/cli-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;GAGG;AACH,UAAU,qBAAsB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC;IAC1E;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAE1D;;OAEG;IACH,UAAU,CAAC,EAAE,2BAA2B,CAAC;CAC1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC;IACT,QAAQ,EAAE,WAAW,CAAC;IACtB,QAAQ,EAAE;QACR,aAAa,EAAE,OAAO,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC,CAyCD;AAED;;;GAGG;AACH,YAAY,EACV,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,YAAY,CAAC"}