mcp4openapi 0.2.8 → 0.3.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.
Files changed (358) hide show
  1. package/README.md +143 -63
  2. package/dist/scripts/validate-profile.js +3 -3
  3. package/dist/scripts/validate-profile.js.map +1 -1
  4. package/dist/src/argument-normalizer.d.ts +5 -0
  5. package/dist/src/argument-normalizer.d.ts.map +1 -0
  6. package/dist/src/argument-normalizer.js +61 -0
  7. package/dist/src/argument-normalizer.js.map +1 -0
  8. package/dist/src/auth/oauth-provider.d.ts +131 -0
  9. package/dist/src/auth/oauth-provider.d.ts.map +1 -0
  10. package/dist/src/auth/oauth-provider.js +839 -0
  11. package/dist/src/auth/oauth-provider.js.map +1 -0
  12. package/dist/src/cli-config.d.ts +9 -0
  13. package/dist/src/cli-config.d.ts.map +1 -0
  14. package/dist/src/cli-config.js +111 -0
  15. package/dist/src/cli-config.js.map +1 -0
  16. package/dist/src/core/cli-config.d.ts +9 -0
  17. package/dist/src/core/cli-config.d.ts.map +1 -0
  18. package/dist/src/core/cli-config.js +125 -0
  19. package/dist/src/core/cli-config.js.map +1 -0
  20. package/dist/src/core/constants.d.ts +86 -0
  21. package/dist/src/core/constants.d.ts.map +1 -0
  22. package/dist/src/core/constants.js +86 -0
  23. package/dist/src/core/constants.js.map +1 -0
  24. package/dist/src/core/errors.d.ts +59 -0
  25. package/dist/src/core/errors.d.ts.map +1 -0
  26. package/dist/src/core/errors.js +119 -0
  27. package/dist/src/core/errors.js.map +1 -0
  28. package/dist/src/core/filtering.d.ts +19 -0
  29. package/dist/src/core/filtering.d.ts.map +1 -0
  30. package/dist/src/core/filtering.js +292 -0
  31. package/dist/src/core/filtering.js.map +1 -0
  32. package/dist/src/core/index.d.ts +26 -0
  33. package/dist/src/core/index.d.ts.map +1 -0
  34. package/dist/src/core/index.js +276 -0
  35. package/dist/src/core/index.js.map +1 -0
  36. package/dist/src/core/lib.d.ts +8 -0
  37. package/dist/src/core/lib.d.ts.map +1 -0
  38. package/dist/src/core/lib.js +7 -0
  39. package/dist/src/core/lib.js.map +1 -0
  40. package/dist/src/core/logger.d.ts +59 -0
  41. package/dist/src/core/logger.d.ts.map +1 -0
  42. package/dist/src/core/logger.js +197 -0
  43. package/dist/src/core/logger.js.map +1 -0
  44. package/dist/src/core/metrics.d.ts +97 -0
  45. package/dist/src/core/metrics.d.ts.map +1 -0
  46. package/dist/src/core/metrics.js +273 -0
  47. package/dist/src/core/metrics.js.map +1 -0
  48. package/dist/src/core/naming-warnings.d.ts +23 -0
  49. package/dist/src/core/naming-warnings.d.ts.map +1 -0
  50. package/dist/src/core/naming-warnings.js +83 -0
  51. package/dist/src/core/naming-warnings.js.map +1 -0
  52. package/dist/src/core/naming.d.ts +58 -0
  53. package/dist/src/core/naming.d.ts.map +1 -0
  54. package/dist/src/core/naming.js +510 -0
  55. package/dist/src/core/naming.js.map +1 -0
  56. package/dist/src/errors.d.ts +6 -0
  57. package/dist/src/errors.d.ts.map +1 -1
  58. package/dist/src/errors.js +15 -6
  59. package/dist/src/errors.js.map +1 -1
  60. package/dist/src/filtering.d.ts +19 -0
  61. package/dist/src/filtering.d.ts.map +1 -0
  62. package/dist/src/filtering.js +292 -0
  63. package/dist/src/filtering.js.map +1 -0
  64. package/dist/src/generated-schemas.d.ts +290 -79
  65. package/dist/src/generated-schemas.d.ts.map +1 -1
  66. package/dist/src/generated-schemas.js +17 -2
  67. package/dist/src/generated-schemas.js.map +1 -1
  68. package/dist/src/http-transport-config.d.ts +6 -0
  69. package/dist/src/http-transport-config.d.ts.map +1 -0
  70. package/dist/src/http-transport-config.js +47 -0
  71. package/dist/src/http-transport-config.js.map +1 -0
  72. package/dist/src/http-transport.d.ts +63 -13
  73. package/dist/src/http-transport.d.ts.map +1 -1
  74. package/dist/src/http-transport.js +1045 -482
  75. package/dist/src/http-transport.js.map +1 -1
  76. package/dist/src/index.d.ts +1 -6
  77. package/dist/src/index.d.ts.map +1 -1
  78. package/dist/src/index.js +1 -170
  79. package/dist/src/index.js.map +1 -1
  80. package/dist/src/interceptors.d.ts +1 -0
  81. package/dist/src/interceptors.d.ts.map +1 -1
  82. package/dist/src/interceptors.js +73 -63
  83. package/dist/src/interceptors.js.map +1 -1
  84. package/dist/src/lib.d.ts +1 -7
  85. package/dist/src/lib.d.ts.map +1 -1
  86. package/dist/src/lib.js +1 -6
  87. package/dist/src/lib.js.map +1 -1
  88. package/dist/src/logger.d.ts +5 -0
  89. package/dist/src/logger.d.ts.map +1 -1
  90. package/dist/src/logger.js +9 -1
  91. package/dist/src/logger.js.map +1 -1
  92. package/dist/src/mcp/mcp-server-manager.d.ts +20 -0
  93. package/dist/src/mcp/mcp-server-manager.d.ts.map +1 -0
  94. package/dist/src/mcp/mcp-server-manager.js +38 -0
  95. package/dist/src/mcp/mcp-server-manager.js.map +1 -0
  96. package/dist/src/mcp/mcp-server.d.ts +205 -0
  97. package/dist/src/mcp/mcp-server.d.ts.map +1 -0
  98. package/dist/src/mcp/mcp-server.js +1473 -0
  99. package/dist/src/mcp/mcp-server.js.map +1 -0
  100. package/dist/src/mcp-server-manager.d.ts +20 -0
  101. package/dist/src/mcp-server-manager.d.ts.map +1 -0
  102. package/dist/src/mcp-server-manager.js +38 -0
  103. package/dist/src/mcp-server-manager.js.map +1 -0
  104. package/dist/src/mcp-server.d.ts +28 -0
  105. package/dist/src/mcp-server.d.ts.map +1 -1
  106. package/dist/src/mcp-server.js +406 -109
  107. package/dist/src/mcp-server.js.map +1 -1
  108. package/dist/src/metrics.d.ts +11 -0
  109. package/dist/src/metrics.d.ts.map +1 -1
  110. package/dist/src/metrics.js +61 -0
  111. package/dist/src/metrics.js.map +1 -1
  112. package/dist/src/oauth-provider.d.ts +5 -0
  113. package/dist/src/oauth-provider.d.ts.map +1 -1
  114. package/dist/src/oauth-provider.js +29 -1
  115. package/dist/src/oauth-provider.js.map +1 -1
  116. package/dist/src/openapi/openapi-parser.d.ts +70 -0
  117. package/dist/src/openapi/openapi-parser.d.ts.map +1 -0
  118. package/dist/src/openapi/openapi-parser.js +458 -0
  119. package/dist/src/openapi/openapi-parser.js.map +1 -0
  120. package/dist/src/profile/profile-loader.d.ts +78 -0
  121. package/dist/src/profile/profile-loader.d.ts.map +1 -0
  122. package/dist/src/profile/profile-loader.js +490 -0
  123. package/dist/src/profile/profile-loader.js.map +1 -0
  124. package/dist/src/profile/profile-registry.d.ts +19 -0
  125. package/dist/src/profile/profile-registry.d.ts.map +1 -0
  126. package/dist/src/profile/profile-registry.js +43 -0
  127. package/dist/src/profile/profile-registry.js.map +1 -0
  128. package/dist/src/profile/profile-resolver.d.ts +41 -0
  129. package/dist/src/profile/profile-resolver.d.ts.map +1 -0
  130. package/dist/src/profile/profile-resolver.js +324 -0
  131. package/dist/src/profile/profile-resolver.js.map +1 -0
  132. package/dist/src/profile/startup-profile.d.ts +17 -0
  133. package/dist/src/profile/startup-profile.d.ts.map +1 -0
  134. package/dist/src/profile/startup-profile.js +30 -0
  135. package/dist/src/profile/startup-profile.js.map +1 -0
  136. package/dist/src/profile/startup-validation.d.ts +11 -0
  137. package/dist/src/profile/startup-validation.d.ts.map +1 -0
  138. package/dist/src/profile/startup-validation.js +21 -0
  139. package/dist/src/profile/startup-validation.js.map +1 -0
  140. package/dist/src/profile-loader.d.ts +1 -0
  141. package/dist/src/profile-loader.d.ts.map +1 -1
  142. package/dist/src/profile-loader.js +14 -3
  143. package/dist/src/profile-loader.js.map +1 -1
  144. package/dist/src/profile-registry.d.ts +18 -0
  145. package/dist/src/profile-registry.d.ts.map +1 -0
  146. package/dist/src/profile-registry.js +26 -0
  147. package/dist/src/profile-registry.js.map +1 -0
  148. package/dist/src/profile-resolver.d.ts +19 -0
  149. package/dist/src/profile-resolver.d.ts.map +1 -0
  150. package/dist/src/profile-resolver.js +167 -0
  151. package/dist/src/profile-resolver.js.map +1 -0
  152. package/dist/src/proxy-executor.d.ts.map +1 -1
  153. package/dist/src/proxy-executor.js +7 -0
  154. package/dist/src/proxy-executor.js.map +1 -1
  155. package/dist/src/startup-profile.d.ts +17 -0
  156. package/dist/src/startup-profile.d.ts.map +1 -0
  157. package/dist/src/startup-profile.js +30 -0
  158. package/dist/src/startup-profile.js.map +1 -0
  159. package/dist/src/startup-validation.d.ts +11 -0
  160. package/dist/src/startup-validation.d.ts.map +1 -0
  161. package/dist/src/startup-validation.js +21 -0
  162. package/dist/src/startup-validation.js.map +1 -0
  163. package/dist/src/testing/dynamic-mock-server.d.ts +24 -0
  164. package/dist/src/testing/dynamic-mock-server.d.ts.map +1 -0
  165. package/dist/src/testing/dynamic-mock-server.js +138 -0
  166. package/dist/src/testing/dynamic-mock-server.js.map +1 -0
  167. package/dist/src/testing/request-assertions.d.ts +5 -0
  168. package/dist/src/testing/request-assertions.d.ts.map +1 -0
  169. package/dist/src/testing/request-assertions.js +165 -0
  170. package/dist/src/testing/request-assertions.js.map +1 -0
  171. package/dist/src/testing/template-utils.d.ts +10 -0
  172. package/dist/src/testing/template-utils.d.ts.map +1 -0
  173. package/dist/src/testing/template-utils.js +72 -0
  174. package/dist/src/testing/template-utils.js.map +1 -0
  175. package/dist/src/testing/test-http-utils.d.ts +1 -1
  176. package/dist/src/testing/test-http-utils.d.ts.map +1 -1
  177. package/dist/src/testing/test-http-utils.js +1 -1
  178. package/dist/src/testing/test-http-utils.js.map +1 -1
  179. package/dist/src/testing/test-loader.d.ts +6 -0
  180. package/dist/src/testing/test-loader.d.ts.map +1 -0
  181. package/dist/src/testing/test-loader.js +212 -0
  182. package/dist/src/testing/test-loader.js.map +1 -0
  183. package/dist/src/testing/test-schema.d.ts +1270 -0
  184. package/dist/src/testing/test-schema.d.ts.map +1 -0
  185. package/dist/src/testing/test-schema.js +76 -0
  186. package/dist/src/testing/test-schema.js.map +1 -0
  187. package/dist/src/tool-filter/compat.d.ts +49 -0
  188. package/dist/src/tool-filter/compat.d.ts.map +1 -0
  189. package/dist/src/tool-filter/compat.js +72 -0
  190. package/dist/src/tool-filter/compat.js.map +1 -0
  191. package/dist/src/tool-filter/config/env-config-parser.d.ts +38 -0
  192. package/dist/src/tool-filter/config/env-config-parser.d.ts.map +1 -0
  193. package/dist/src/tool-filter/config/env-config-parser.js +103 -0
  194. package/dist/src/tool-filter/config/env-config-parser.js.map +1 -0
  195. package/dist/src/tool-filter/config/header-config-parser.d.ts +37 -0
  196. package/dist/src/tool-filter/config/header-config-parser.d.ts.map +1 -0
  197. package/dist/src/tool-filter/config/header-config-parser.js +118 -0
  198. package/dist/src/tool-filter/config/header-config-parser.js.map +1 -0
  199. package/dist/src/tool-filter/errors.d.ts +18 -0
  200. package/dist/src/tool-filter/errors.d.ts.map +1 -0
  201. package/dist/src/tool-filter/errors.js +21 -0
  202. package/dist/src/tool-filter/errors.js.map +1 -0
  203. package/dist/src/tool-filter/filter/filter-engine.d.ts +45 -0
  204. package/dist/src/tool-filter/filter/filter-engine.d.ts.map +1 -0
  205. package/dist/src/tool-filter/filter/filter-engine.js +94 -0
  206. package/dist/src/tool-filter/filter/filter-engine.js.map +1 -0
  207. package/dist/src/tool-filter/filter/filter-rules.d.ts +44 -0
  208. package/dist/src/tool-filter/filter/filter-rules.d.ts.map +1 -0
  209. package/dist/src/tool-filter/filter/filter-rules.js +72 -0
  210. package/dist/src/tool-filter/filter/filter-rules.js.map +1 -0
  211. package/dist/src/tool-filter/filter/global-tool-filter.d.ts +40 -0
  212. package/dist/src/tool-filter/filter/global-tool-filter.d.ts.map +1 -0
  213. package/dist/src/tool-filter/filter/global-tool-filter.js +92 -0
  214. package/dist/src/tool-filter/filter/global-tool-filter.js.map +1 -0
  215. package/dist/src/tool-filter/filter/session-tool-filter.d.ts +29 -0
  216. package/dist/src/tool-filter/filter/session-tool-filter.d.ts.map +1 -0
  217. package/dist/src/tool-filter/filter/session-tool-filter.js +69 -0
  218. package/dist/src/tool-filter/filter/session-tool-filter.js.map +1 -0
  219. package/dist/src/tool-filter/index.d.ts +25 -0
  220. package/dist/src/tool-filter/index.d.ts.map +1 -0
  221. package/dist/src/tool-filter/index.js +30 -0
  222. package/dist/src/tool-filter/index.js.map +1 -0
  223. package/dist/src/tool-filter/integration/tool-filter-service.d.ts +44 -0
  224. package/dist/src/tool-filter/integration/tool-filter-service.d.ts.map +1 -0
  225. package/dist/src/tool-filter/integration/tool-filter-service.js +68 -0
  226. package/dist/src/tool-filter/integration/tool-filter-service.js.map +1 -0
  227. package/dist/src/tool-filter/operation/operation-classifier.d.ts +20 -0
  228. package/dist/src/tool-filter/operation/operation-classifier.d.ts.map +1 -0
  229. package/dist/src/tool-filter/operation/operation-classifier.js +26 -0
  230. package/dist/src/tool-filter/operation/operation-classifier.js.map +1 -0
  231. package/dist/src/tool-filter/operation/operation-detector.d.ts +30 -0
  232. package/dist/src/tool-filter/operation/operation-detector.d.ts.map +1 -0
  233. package/dist/src/tool-filter/operation/operation-detector.js +96 -0
  234. package/dist/src/tool-filter/operation/operation-detector.js.map +1 -0
  235. package/dist/src/tool-filter/operation/operation-resolver.d.ts +22 -0
  236. package/dist/src/tool-filter/operation/operation-resolver.d.ts.map +1 -0
  237. package/dist/src/tool-filter/operation/operation-resolver.js +32 -0
  238. package/dist/src/tool-filter/operation/operation-resolver.js.map +1 -0
  239. package/dist/src/tool-filter/regex/regex-compiler.d.ts +22 -0
  240. package/dist/src/tool-filter/regex/regex-compiler.d.ts.map +1 -0
  241. package/dist/src/tool-filter/regex/regex-compiler.js +56 -0
  242. package/dist/src/tool-filter/regex/regex-compiler.js.map +1 -0
  243. package/dist/src/tool-filter/regex/regex-validator.d.ts +24 -0
  244. package/dist/src/tool-filter/regex/regex-validator.d.ts.map +1 -0
  245. package/dist/src/tool-filter/regex/regex-validator.js +58 -0
  246. package/dist/src/tool-filter/regex/regex-validator.js.map +1 -0
  247. package/dist/src/tool-filter/types.d.ts +92 -0
  248. package/dist/src/tool-filter/types.d.ts.map +1 -0
  249. package/dist/src/tool-filter/types.js +5 -0
  250. package/dist/src/tool-filter/types.js.map +1 -0
  251. package/dist/src/tool-filter/utils.d.ts +11 -0
  252. package/dist/src/tool-filter/utils.d.ts.map +1 -0
  253. package/dist/src/tool-filter/utils.js +13 -0
  254. package/dist/src/tool-filter/utils.js.map +1 -0
  255. package/dist/src/tool-filter.d.ts +65 -0
  256. package/dist/src/tool-filter.d.ts.map +1 -0
  257. package/dist/src/tool-filter.js +471 -0
  258. package/dist/src/tool-filter.js.map +1 -0
  259. package/dist/src/tool-generator.d.ts +1 -0
  260. package/dist/src/tool-generator.d.ts.map +1 -1
  261. package/dist/src/tool-generator.js +15 -6
  262. package/dist/src/tool-generator.js.map +1 -1
  263. package/dist/src/tooling/composite-executor.d.ts +77 -0
  264. package/dist/src/tooling/composite-executor.d.ts.map +1 -0
  265. package/dist/src/tooling/composite-executor.js +198 -0
  266. package/dist/src/tooling/composite-executor.js.map +1 -0
  267. package/dist/src/tooling/dag-executor.d.ts +49 -0
  268. package/dist/src/tooling/dag-executor.d.ts.map +1 -0
  269. package/dist/src/tooling/dag-executor.js +138 -0
  270. package/dist/src/tooling/dag-executor.js.map +1 -0
  271. package/dist/src/tooling/proxy-executor.d.ts +86 -0
  272. package/dist/src/tooling/proxy-executor.d.ts.map +1 -0
  273. package/dist/src/tooling/proxy-executor.js +501 -0
  274. package/dist/src/tooling/proxy-executor.js.map +1 -0
  275. package/dist/src/tooling/tool-generator.d.ts +67 -0
  276. package/dist/src/tooling/tool-generator.d.ts.map +1 -0
  277. package/dist/src/tooling/tool-generator.js +222 -0
  278. package/dist/src/tooling/tool-generator.js.map +1 -0
  279. package/dist/src/transport/http-client-factory.d.ts +65 -0
  280. package/dist/src/transport/http-client-factory.d.ts.map +1 -0
  281. package/dist/src/transport/http-client-factory.js +143 -0
  282. package/dist/src/transport/http-client-factory.js.map +1 -0
  283. package/dist/src/transport/http-transport-config.d.ts +6 -0
  284. package/dist/src/transport/http-transport-config.d.ts.map +1 -0
  285. package/dist/src/transport/http-transport-config.js +63 -0
  286. package/dist/src/transport/http-transport-config.js.map +1 -0
  287. package/dist/src/transport/http-transport.d.ts +329 -0
  288. package/dist/src/transport/http-transport.d.ts.map +1 -0
  289. package/dist/src/transport/http-transport.js +2584 -0
  290. package/dist/src/transport/http-transport.js.map +1 -0
  291. package/dist/src/transport/interceptors.d.ts +119 -0
  292. package/dist/src/transport/interceptors.d.ts.map +1 -0
  293. package/dist/src/transport/interceptors.js +413 -0
  294. package/dist/src/transport/interceptors.js.map +1 -0
  295. package/dist/src/transport/profile-index.d.ts +84 -0
  296. package/dist/src/transport/profile-index.d.ts.map +1 -0
  297. package/dist/src/transport/profile-index.js +405 -0
  298. package/dist/src/transport/profile-index.js.map +1 -0
  299. package/dist/src/types/http-transport.d.ts +26 -0
  300. package/dist/src/types/http-transport.d.ts.map +1 -1
  301. package/dist/src/types/openapi.d.ts +3 -0
  302. package/dist/src/types/openapi.d.ts.map +1 -1
  303. package/dist/src/types/profile.d.ts +16 -1
  304. package/dist/src/types/profile.d.ts.map +1 -1
  305. package/dist/src/validation/argument-normalizer.d.ts +6 -0
  306. package/dist/src/validation/argument-normalizer.d.ts.map +1 -0
  307. package/dist/src/validation/argument-normalizer.js +70 -0
  308. package/dist/src/validation/argument-normalizer.js.map +1 -0
  309. package/dist/src/validation/jsonrpc-validator.d.ts +27 -0
  310. package/dist/src/validation/jsonrpc-validator.d.ts.map +1 -0
  311. package/dist/src/validation/jsonrpc-validator.js +58 -0
  312. package/dist/src/validation/jsonrpc-validator.js.map +1 -0
  313. package/dist/src/validation/schema-validator.d.ts +30 -0
  314. package/dist/src/validation/schema-validator.d.ts.map +1 -0
  315. package/dist/src/validation/schema-validator.js +128 -0
  316. package/dist/src/validation/schema-validator.js.map +1 -0
  317. package/dist/src/validation/validation-utils.d.ts +49 -0
  318. package/dist/src/validation/validation-utils.d.ts.map +1 -0
  319. package/dist/src/validation/validation-utils.js +139 -0
  320. package/dist/src/validation/validation-utils.js.map +1 -0
  321. package/html/profile-index.html +386 -0
  322. package/package.json +10 -3
  323. package/profile-schema.json +77 -3
  324. package/profiles/gitlab/developer-profile-oauth.json +1520 -0
  325. package/profiles/gitlab/developer-profile-oauth.test.json +3432 -0
  326. package/profiles/gitlab/developer-profile.json +1508 -0
  327. package/profiles/gitlab/developer-profile.test.json +3432 -0
  328. package/profiles/gitlab/openapi.yaml +6891 -0
  329. package/profiles/n8n/openapi.yaml +2441 -0
  330. package/profiles/n8n/profile-optimized.json +965 -0
  331. package/profiles/n8n/profile-optimized.test.json +1078 -0
  332. package/profiles/n8n/profile.json +1033 -0
  333. package/profiles/n8n/profile.test.json +983 -0
  334. package/profiles/n8n-nodes/openapi.yaml +24 -0
  335. package/profiles/n8n-nodes/profile-nodes.json +44 -0
  336. package/profiles/n8n-nodes/profile-nodes.test.json +91 -0
  337. package/profiles/semgrep/openapi.yaml +4706 -0
  338. package/profiles/semgrep/profile.json +692 -0
  339. package/profiles/semgrep/profile.test.json +471 -0
  340. package/profiles/youtrack/openapi.json +16976 -0
  341. package/profiles/youtrack/profile.json +608 -0
  342. package/profiles/youtrack/profile.test.json +1926 -0
  343. package/dist/src/testing/fixtures.d.ts +0 -684
  344. package/dist/src/testing/fixtures.d.ts.map +0 -1
  345. package/dist/src/testing/fixtures.js +0 -528
  346. package/dist/src/testing/fixtures.js.map +0 -1
  347. package/dist/src/testing/mock-gitlab-server.d.ts +0 -43
  348. package/dist/src/testing/mock-gitlab-server.d.ts.map +0 -1
  349. package/dist/src/testing/mock-gitlab-server.js +0 -1026
  350. package/dist/src/testing/mock-gitlab-server.js.map +0 -1
  351. package/dist/src/testing/mock-semgrep-server.d.ts +0 -32
  352. package/dist/src/testing/mock-semgrep-server.d.ts.map +0 -1
  353. package/dist/src/testing/mock-semgrep-server.js +0 -213
  354. package/dist/src/testing/mock-semgrep-server.js.map +0 -1
  355. package/dist/src/testing/mock-youtrack-server.d.ts +0 -11
  356. package/dist/src/testing/mock-youtrack-server.d.ts.map +0 -1
  357. package/dist/src/testing/mock-youtrack-server.js +0 -152
  358. package/dist/src/testing/mock-youtrack-server.js.map +0 -1
@@ -0,0 +1,222 @@
1
+ /**
2
+ * MCP tool generator from profile definitions
3
+ *
4
+ * Why: Translates profile config into MCP SDK tool definitions. Handles both
5
+ * simple (single operation) and composite (multi-step) tools.
6
+ */
7
+ import { ValidationError } from '../core/errors.js';
8
+ export class ToolGenerator {
9
+ constructor(parser) {
10
+ this.parser = parser;
11
+ }
12
+ /**
13
+ * Generate MCP tool from profile definition
14
+ */
15
+ generateTool(toolDef) {
16
+ const inputSchema = this.generateInputSchema(toolDef);
17
+ return {
18
+ name: toolDef.name,
19
+ description: toolDef.description,
20
+ inputSchema,
21
+ };
22
+ }
23
+ /**
24
+ * Generate JSON Schema for tool parameters
25
+ *
26
+ * Why JSON Schema: MCP SDK expects JSON Schema for parameter validation.
27
+ * LLM uses schema to understand what parameters are needed.
28
+ */
29
+ generateInputSchema(toolDef) {
30
+ const properties = {};
31
+ const required = [];
32
+ for (const [name, param] of Object.entries(toolDef.parameters)) {
33
+ properties[name] = this.parameterToJsonSchema(param);
34
+ // Add to required if unconditionally required
35
+ if (param.required) {
36
+ required.push(name);
37
+ }
38
+ // Add conditional requirement hints in description
39
+ if (param.required_for && param.required_for.length > 0) {
40
+ const existing = properties[name].description || '';
41
+ properties[name].description = existing +
42
+ ` Required when action is: ${param.required_for.join(', ')}.`;
43
+ }
44
+ }
45
+ return {
46
+ type: 'object',
47
+ properties,
48
+ required: required.length > 0 ? required : undefined,
49
+ };
50
+ }
51
+ /**
52
+ * Convert parameter definition to JSON Schema
53
+ */
54
+ parameterToJsonSchema(param) {
55
+ if (Array.isArray(param.type)) {
56
+ const oneOf = param.type.map(type => this.parameterTypeToSchema(type, param));
57
+ return {
58
+ description: param.description,
59
+ oneOf,
60
+ };
61
+ }
62
+ const schema = this.parameterTypeToSchema(param.type, param);
63
+ schema.description = param.description;
64
+ return schema;
65
+ }
66
+ parameterTypeToSchema(type, param) {
67
+ const schema = { type };
68
+ if (param.enum) {
69
+ schema.enum = param.enum;
70
+ }
71
+ if (param.default !== undefined) {
72
+ schema.default = param.default;
73
+ }
74
+ if (type === 'string') {
75
+ if (param.minLength !== undefined) {
76
+ schema.minLength = param.minLength;
77
+ }
78
+ if (param.maxLength !== undefined) {
79
+ schema.maxLength = param.maxLength;
80
+ }
81
+ if (param.pattern !== undefined) {
82
+ schema.pattern = param.pattern;
83
+ }
84
+ }
85
+ if (type === 'array' && param.items) {
86
+ schema.items = { type: param.items.type };
87
+ }
88
+ if (type === 'object') {
89
+ // Always include properties for object type (empty {} = free-form object)
90
+ schema.properties = param.properties || {};
91
+ }
92
+ return schema;
93
+ }
94
+ /**
95
+ * Validate tool arguments against parameter definitions
96
+ *
97
+ * Why manual validation: Checks conditional requirements (required_for)
98
+ * which JSON Schema can't express directly.
99
+ */
100
+ validateArguments(toolDef, args) {
101
+ for (const [name, param] of Object.entries(toolDef.parameters)) {
102
+ const value = args[name];
103
+ // Check unconditional required
104
+ if (param.required && value === undefined) {
105
+ throw new ValidationError(`Missing required parameter: ${name}`);
106
+ }
107
+ // Check conditional required
108
+ if (param.required_for && param.required_for.length > 0) {
109
+ const action = args['action'];
110
+ if (action && param.required_for.includes(action) && value === undefined) {
111
+ throw new ValidationError(`Parameter '${name}' is required for action '${action}'`);
112
+ }
113
+ }
114
+ // Validate enum
115
+ if (value !== undefined && param.enum && !param.enum.includes(String(value))) {
116
+ throw new ValidationError(`Invalid value for ${name}. Must be one of: ${param.enum.join(', ')}`);
117
+ }
118
+ // Validate string constraints
119
+ if (value !== undefined && typeof value === 'string') {
120
+ if (param.minLength !== undefined && value.length < param.minLength) {
121
+ throw new ValidationError(`Invalid value for ${name}. Length must be at least ${param.minLength}`);
122
+ }
123
+ if (param.maxLength !== undefined && value.length > param.maxLength) {
124
+ throw new ValidationError(`Invalid value for ${name}. Length must be at most ${param.maxLength}`);
125
+ }
126
+ if (param.pattern !== undefined) {
127
+ let regex;
128
+ try {
129
+ regex = new RegExp(param.pattern);
130
+ }
131
+ catch (error) {
132
+ const reason = error instanceof Error ? error.message : String(error);
133
+ throw new ValidationError(`Invalid pattern for ${name}.`, { paramName: name, pattern: param.pattern, reason });
134
+ }
135
+ if (!regex.test(value)) {
136
+ throw new ValidationError(`Invalid value for ${name}. Must match pattern: ${param.pattern}`, { paramName: name, pattern: param.pattern });
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }
142
+ /**
143
+ * Get operation definition (string or ProxyDownloadOperation) for action
144
+ *
145
+ * Why: Tools can have string operationIds OR proxy_download configs.
146
+ * This returns the raw definition before extracting operationId.
147
+ */
148
+ getOperationDefinition(toolDef, args) {
149
+ if (!toolDef.operations)
150
+ return undefined;
151
+ const action = args['action'];
152
+ if (!action) {
153
+ // If single operation, use it directly
154
+ const operations = Object.values(toolDef.operations);
155
+ return operations.length === 1 ? operations[0] : undefined;
156
+ }
157
+ // For resource_type discrimination (e.g., project vs group)
158
+ const resourceType = args['resource_type'];
159
+ if (resourceType) {
160
+ // Try resource-specific operation first
161
+ const key = `${action}_${resourceType}`;
162
+ if (toolDef.operations[key]) {
163
+ return toolDef.operations[key];
164
+ }
165
+ }
166
+ return toolDef.operations[action];
167
+ }
168
+ /**
169
+ * Map tool action to OpenAPI operation ID
170
+ *
171
+ * Why: Single tool with 'action' parameter maps to multiple operations.
172
+ * Example: manage_badges + action=create => postApiV4ProjectsIdBadges
173
+ *
174
+ * Note: Returns undefined for ProxyDownloadOperation (not a direct operationId)
175
+ */
176
+ mapActionToOperation(toolDef, args) {
177
+ const op = this.getOperationDefinition(toolDef, args);
178
+ return typeof op === 'string' ? op : undefined;
179
+ }
180
+ /**
181
+ * Check if operation requires multipart/form-data
182
+ *
183
+ * Why: Some operations (file uploads) need FormData instead of JSON body.
184
+ * Detected from OpenAPI requestBody.content['multipart/form-data'].
185
+ */
186
+ isMultipartOperation(operationId) {
187
+ const operation = this.parser.getOperation(operationId);
188
+ if (!operation?.requestBody?.content)
189
+ return false;
190
+ return 'multipart/form-data' in operation.requestBody.content;
191
+ }
192
+ /**
193
+ * Build FormData body for file upload
194
+ *
195
+ * @param args Tool arguments including base64Content or filePath
196
+ * @param fileFieldName Field name in FormData (default: 'files[0]')
197
+ */
198
+ buildFormDataBody(args, fileFieldName = 'files[0]') {
199
+ const formData = new FormData();
200
+ const base64Content = args['base64Content'];
201
+ const fileName = args['fileName'] || 'upload';
202
+ const mimeType = args['mimeType'] || 'application/octet-stream';
203
+ if (base64Content) {
204
+ // Convert base64 to Blob
205
+ let binaryString;
206
+ try {
207
+ binaryString = atob(base64Content);
208
+ }
209
+ catch (error) {
210
+ throw new ValidationError('Invalid base64 content');
211
+ }
212
+ const bytes = new Uint8Array(binaryString.length);
213
+ for (let i = 0; i < binaryString.length; i++) {
214
+ bytes[i] = binaryString.charCodeAt(i);
215
+ }
216
+ const blob = new Blob([bytes], { type: mimeType });
217
+ formData.append(fileFieldName, blob, fileName);
218
+ }
219
+ return formData;
220
+ }
221
+ }
222
+ //# sourceMappingURL=tool-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-generator.js","sourceRoot":"","sources":["../../../src/tooling/tool-generator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,OAAO,aAAa;IACxB,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAE7C;;OAEG;IACH,YAAY,CAAC,OAAuB;QAClC,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAEtD,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,WAAW;SACZ,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACK,mBAAmB,CAAC,OAAuB;QACjD,MAAM,UAAU,GAA4C,EAAE,CAAC;QAC/D,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,O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AG,IAAI,CAAC,eAAe,CAAuB,CAAC;QAClE,MAAM,QAAQ,GAAI,IAAI,CAAC,UAAU,CAAY,IAAI,QAAQ,CAAC;QAC1D,MAAM,QAAQ,GAAI,IAAI,CAAC,UAAU,CAAY,IAAI,0BAA0B,CAAC;QAE5E,IAAI,aAAa,EAAE,CAAC;YAClB,yBAAyB;YACzB,IAAI,YAAoB,CAAC;YACzB,IAAI,CAAC;gBACH,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;YACrC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,eAAe,CAAC,wBAAwB,CAAC,CAAC;YACtD,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC7C,KAAK,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACxC,CAAC;YACD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;YACnD,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * HTTP Client Factory - unified HTTP client management
3
+ *
4
+ * Why: Eliminates code duplication in HTTP client creation and management
5
+ * Provides consistent client lifecycle, auth handling, and caching
6
+ */
7
+ import { HttpClient } from './interceptors.js';
8
+ import type { MetricsCollector } from '../core/metrics.js';
9
+ import type { Profile } from '../types/profile.js';
10
+ export interface HttpClientConfig {
11
+ profile: Profile;
12
+ baseUrl: string;
13
+ sessionToken?: string;
14
+ }
15
+ /**
16
+ * Factory for creating and managing HTTP clients
17
+ * Handles both global and session-specific clients
18
+ */
19
+ export declare class HttpClientFactory {
20
+ private globalClient?;
21
+ private sessionClients;
22
+ private metrics;
23
+ /**
24
+ * Create global HTTP client (for stdio transport)
25
+ */
26
+ createGlobalClient(config: HttpClientConfig): HttpClient;
27
+ /**
28
+ * Get or create session-specific HTTP client
29
+ */
30
+ getOrCreateSessionClient(sessionId: string, config: HttpClientConfig): HttpClient;
31
+ /**
32
+ * Get global client (throws if not initialized)
33
+ */
34
+ getGlobalClient(): HttpClient;
35
+ /**
36
+ * Get session client (throws if not exists)
37
+ */
38
+ getSessionClient(sessionId: string): HttpClient;
39
+ /**
40
+ * Cleanup session client
41
+ */
42
+ cleanupSessionClient(sessionId: string): boolean;
43
+ /**
44
+ * Check if global client exists
45
+ */
46
+ hasGlobalClient(): boolean;
47
+ /**
48
+ * Check if session client exists
49
+ */
50
+ hasSessionClient(sessionId: string): boolean;
51
+ setMetricsCollector(metrics: MetricsCollector | null): void;
52
+ /**
53
+ * Get auth token for client creation
54
+ */
55
+ private getAuthToken;
56
+ /**
57
+ * Create interceptor chain for client
58
+ */
59
+ private createInterceptorChain;
60
+ /**
61
+ * Validate client configuration
62
+ */
63
+ validateClientConfig(config: HttpClientConfig): void;
64
+ }
65
+ //# sourceMappingURL=http-client-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client-factory.d.ts","sourceRoot":"","sources":["../../../src/transport/http-client-factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAa;IAClC,OAAO,CAAC,cAAc,CAAiC;IACvD,OAAO,CAAC,OAAO,CAAiC;IAEhD;;OAEG;IACH,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU;IAOxD;;OAEG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,UAAU;IAsBjF;;OAEG;IACH,eAAe,IAAI,UAAU;IAO7B;;OAEG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU;IAQ/C;;OAEG;IACH,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIhD;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;OAEG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAI5C,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI;IAU3D;;OAEG;IACH,OAAO,CAAC,YAAY;IAuBpB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAK9B;;OAEG;IACH,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;CAsBrD"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * HTTP Client Factory - unified HTTP client management
3
+ *
4
+ * Why: Eliminates code duplication in HTTP client creation and management
5
+ * Provides consistent client lifecycle, auth handling, and caching
6
+ */
7
+ import { InterceptorChain, HttpClient } from './interceptors.js';
8
+ import { ConfigurationError, AuthenticationError } from '../core/errors.js';
9
+ /**
10
+ * Factory for creating and managing HTTP clients
11
+ * Handles both global and session-specific clients
12
+ */
13
+ export class HttpClientFactory {
14
+ constructor() {
15
+ this.sessionClients = new Map();
16
+ this.metrics = null;
17
+ }
18
+ /**
19
+ * Create global HTTP client (for stdio transport)
20
+ */
21
+ createGlobalClient(config) {
22
+ const interceptors = this.createInterceptorChain(config);
23
+ const client = new HttpClient(config.baseUrl, interceptors, this.metrics);
24
+ this.globalClient = client;
25
+ return client;
26
+ }
27
+ /**
28
+ * Get or create session-specific HTTP client
29
+ */
30
+ getOrCreateSessionClient(sessionId, config) {
31
+ // Check cache first
32
+ let client = this.sessionClients.get(sessionId);
33
+ if (client) {
34
+ return client;
35
+ }
36
+ // Create new client for session
37
+ const interceptors = this.createInterceptorChain(config);
38
+ const newClient = new HttpClient(config.baseUrl, interceptors, this.metrics);
39
+ // Double-check for race condition
40
+ const existingClient = this.sessionClients.get(sessionId);
41
+ if (existingClient) {
42
+ return existingClient;
43
+ }
44
+ // Cache and return
45
+ this.sessionClients.set(sessionId, newClient);
46
+ return newClient;
47
+ }
48
+ /**
49
+ * Get global client (throws if not initialized)
50
+ */
51
+ getGlobalClient() {
52
+ if (!this.globalClient) {
53
+ throw new ConfigurationError('Global HTTP client not initialized');
54
+ }
55
+ return this.globalClient;
56
+ }
57
+ /**
58
+ * Get session client (throws if not exists)
59
+ */
60
+ getSessionClient(sessionId) {
61
+ const client = this.sessionClients.get(sessionId);
62
+ if (!client) {
63
+ throw new ConfigurationError(`Session HTTP client not found for session: ${sessionId}`);
64
+ }
65
+ return client;
66
+ }
67
+ /**
68
+ * Cleanup session client
69
+ */
70
+ cleanupSessionClient(sessionId) {
71
+ return this.sessionClients.delete(sessionId);
72
+ }
73
+ /**
74
+ * Check if global client exists
75
+ */
76
+ hasGlobalClient() {
77
+ return !!this.globalClient;
78
+ }
79
+ /**
80
+ * Check if session client exists
81
+ */
82
+ hasSessionClient(sessionId) {
83
+ return this.sessionClients.has(sessionId);
84
+ }
85
+ setMetricsCollector(metrics) {
86
+ this.metrics = metrics;
87
+ if (this.globalClient) {
88
+ this.globalClient.setMetricsCollector(metrics);
89
+ }
90
+ for (const client of this.sessionClients.values()) {
91
+ client.setMetricsCollector(metrics);
92
+ }
93
+ }
94
+ /**
95
+ * Get auth token for client creation
96
+ */
97
+ getAuthToken(config) {
98
+ // Priority: session token > environment token
99
+ if (config.sessionToken) {
100
+ return config.sessionToken;
101
+ }
102
+ const authConfigRaw = config.profile.interceptors?.auth;
103
+ if (!authConfigRaw) {
104
+ return undefined;
105
+ }
106
+ // Handle multi-auth: get primary non-OAuth config
107
+ const authConfigs = Array.isArray(authConfigRaw) ? authConfigRaw : [authConfigRaw];
108
+ const sortedConfigs = authConfigs.sort((a, b) => (a.priority || 0) - (b.priority || 0));
109
+ const authConfig = sortedConfigs.find(c => c.type !== 'oauth');
110
+ if (authConfig && authConfig.value_from_env) {
111
+ return process.env[authConfig.value_from_env];
112
+ }
113
+ return undefined;
114
+ }
115
+ /**
116
+ * Create interceptor chain for client
117
+ */
118
+ createInterceptorChain(config) {
119
+ const token = this.getAuthToken(config);
120
+ return new InterceptorChain(config.profile.interceptors || {}, token);
121
+ }
122
+ /**
123
+ * Validate client configuration
124
+ */
125
+ validateClientConfig(config) {
126
+ if (!config.baseUrl) {
127
+ throw new ConfigurationError('Base URL is required for HTTP client');
128
+ }
129
+ if (!config.profile) {
130
+ throw new ConfigurationError('Profile is required for HTTP client');
131
+ }
132
+ // Check if we have any auth token available
133
+ const hasToken = this.getAuthToken(config);
134
+ if (!hasToken && config.profile.interceptors?.auth) {
135
+ const authConfigRaw = config.profile.interceptors.auth;
136
+ const authConfigs = Array.isArray(authConfigRaw) ? authConfigRaw : [authConfigRaw];
137
+ const nonOAuthConfig = authConfigs.find(c => c.type !== 'oauth');
138
+ const envVar = nonOAuthConfig?.value_from_env || 'MCP4_API_TOKEN';
139
+ throw new AuthenticationError(`No auth token available. Expected token in Authorization header or ${envVar} env var`, { envVar });
140
+ }
141
+ }
142
+ }
143
+ //# sourceMappingURL=http-client-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client-factory.js","sourceRoot":"","sources":["../../../src/transport/http-client-factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG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,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC;YACnD,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC;YACvD,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;YACnF,MAAM,cAAc,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;YACjE,MAAM,MAAM,GAAG,cAAc,EAAE,cAAc,IAAI,gBAAgB,CAAC;YAClE,MAAM,IAAI,mBAAmB,CAC3B,sEAAsE,MAAM,UAAU,EACtF,EAAE,MAAM,EAAE,CACX,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Build base HTTP transport configuration from environment variables.
3
+ */
4
+ import type { HttpTransportConfig } from '../types/http-transport.js';
5
+ export declare function buildHttpTransportBaseConfig(host: string, port: number): HttpTransportConfig;
6
+ //# sourceMappingURL=http-transport-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-transport-config.d.ts","sourceRoot":"","sources":["../../../src/transport/http-transport-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAatE,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,mBAAmB,CA8C5F"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Build base HTTP transport configuration from environment variables.
3
+ */
4
+ import { TIMEOUTS } from '../core/constants.js';
5
+ import { ConfigurationError } from '../core/errors.js';
6
+ function parseTrustProxy(value) {
7
+ const normalized = value.trim().toLowerCase();
8
+ if (normalized === 'true')
9
+ return true;
10
+ if (normalized === 'false')
11
+ return false;
12
+ const numeric = Number.parseInt(value, 10);
13
+ if (!Number.isNaN(numeric) && String(numeric) === value.trim()) {
14
+ return numeric;
15
+ }
16
+ return value;
17
+ }
18
+ export function buildHttpTransportBaseConfig(host, port) {
19
+ return {
20
+ host,
21
+ port,
22
+ sessionTimeoutMs: parseInt(process.env.MCP4_SESSION_TIMEOUT_MS || String(TIMEOUTS.SESSION_TIMEOUT_MS), 10),
23
+ heartbeatEnabled: process.env.MCP4_HEARTBEAT_ENABLED === 'true',
24
+ heartbeatIntervalMs: parseInt(process.env.MCP4_HEARTBEAT_INTERVAL_MS || String(TIMEOUTS.HEARTBEAT_INTERVAL_MS), 10),
25
+ metricsEnabled: process.env.MCP4_METRICS_ENABLED === 'true',
26
+ metricsPath: process.env.MCP4_METRICS_PATH || '/metrics',
27
+ profileIndexEnabled: process.env.MCP4_HTTP_PROFILE_INDEX === 'true',
28
+ allowedOrigins: process.env.MCP4_ALLOWED_ORIGINS
29
+ ? process.env.MCP4_ALLOWED_ORIGINS.split(',').map(o => o.trim())
30
+ : undefined,
31
+ rateLimitEnabled: process.env.MCP4_HTTP_RATE_LIMIT_ENABLED !== 'false', // default: true
32
+ rateLimitWindowMs: parseInt(process.env.MCP4_HTTP_RATE_LIMIT_WINDOW_MS || String(TIMEOUTS.RATE_LIMIT_WINDOW_MS), 10),
33
+ rateLimitMaxRequests: parseInt(process.env.MCP4_HTTP_RATE_LIMIT_MAX_REQUESTS || '100', 10),
34
+ rateLimitMetricsMax: parseInt(process.env.MCP4_HTTP_RATE_LIMIT_METRICS_MAX || '10', 10),
35
+ maxTokenLength: process.env.MCP4_TOKEN_MAX_LENGTH
36
+ ? parseInt(process.env.MCP4_TOKEN_MAX_LENGTH, 10)
37
+ : undefined,
38
+ trustProxy: process.env.MCP4_TRUST_PROXY
39
+ ? parseTrustProxy(process.env.MCP4_TRUST_PROXY)
40
+ : undefined,
41
+ sslCertFile: process.env.MCP4_SSL_CERT_FILE,
42
+ sslKeyFile: process.env.MCP4_SSL_KEY_FILE,
43
+ oauthSessionTimeoutMs: (() => {
44
+ if (process.env.MCP4_OAUTH_SESSION_TIMEOUT_MS === undefined)
45
+ return undefined;
46
+ const parsed = parseInt(process.env.MCP4_OAUTH_SESSION_TIMEOUT_MS, 10);
47
+ if (Number.isNaN(parsed)) {
48
+ throw new ConfigurationError(`Invalid MCP4_OAUTH_SESSION_TIMEOUT_MS: expected integer milliseconds, got '${process.env.MCP4_OAUTH_SESSION_TIMEOUT_MS}'`);
49
+ }
50
+ return parsed;
51
+ })(),
52
+ oauthRefreshThresholdMs: (() => {
53
+ if (process.env.MCP4_OAUTH_REFRESH_THRESHOLD_MS === undefined)
54
+ return undefined;
55
+ const parsed = parseInt(process.env.MCP4_OAUTH_REFRESH_THRESHOLD_MS, 10);
56
+ if (Number.isNaN(parsed)) {
57
+ throw new ConfigurationError(`Invalid MCP4_OAUTH_REFRESH_THRESHOLD_MS: expected integer milliseconds, got '${process.env.MCP4_OAUTH_REFRESH_THRESHOLD_MS}'`);
58
+ }
59
+ return parsed;
60
+ })(),
61
+ };
62
+ }
63
+ //# sourceMappingURL=http-transport-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-transport-config.js","sourceRoot":"","sources":["../../../src/transport/http-transport-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,SAAS,eAAe,CAAC,KAAa;IACpC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAI,UAAU,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,UAAU,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IACzC,MAAM,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