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,292 @@
1
+ import { AuthorizationError, ValidationError } from './errors.js';
2
+ const CONTROL_KEYS = new Set(['_allow_list', '_allow_read']);
3
+ const KEY_PATTERN = /^[A-Za-z0-9_][A-Za-z0-9_-]{0,63}$/;
4
+ export function normalizeFilteringHeaderValue(value) {
5
+ if (value === undefined || value === null) {
6
+ return undefined;
7
+ }
8
+ const normalized = value.trim();
9
+ return normalized.length > 0 ? normalized : undefined;
10
+ }
11
+ export function parseFilteringHeader(headerValue) {
12
+ const normalizedHeader = normalizeFilteringHeaderValue(headerValue);
13
+ if (!normalizedHeader) {
14
+ return { filtering: Object.create(null), normalizedHeader: '' };
15
+ }
16
+ const maxValues = getFilterMaxValues();
17
+ const filtering = Object.create(null);
18
+ const parts = normalizedHeader.split(',');
19
+ for (const part of parts) {
20
+ const trimmed = part.trim();
21
+ if (!trimmed) {
22
+ continue;
23
+ }
24
+ const equalsIndex = trimmed.indexOf('=');
25
+ if (equalsIndex === -1) {
26
+ if (!CONTROL_KEYS.has(trimmed) || !KEY_PATTERN.test(trimmed)) {
27
+ throw new ValidationError('Invalid X-Mcp4-Params header. Expected comma-separated key=value pairs.');
28
+ }
29
+ filtering[trimmed] = filtering[trimmed] ?? [];
30
+ continue;
31
+ }
32
+ const key = trimmed.slice(0, equalsIndex).trim();
33
+ const rawValue = trimmed.slice(equalsIndex + 1).trim();
34
+ if (!key || !KEY_PATTERN.test(key)) {
35
+ throw new ValidationError('Invalid X-Mcp4-Params header. Expected comma-separated key=value pairs.');
36
+ }
37
+ if (CONTROL_KEYS.has(key)) {
38
+ throw new ValidationError('Invalid X-Mcp4-Params header. Expected comma-separated key=value pairs.');
39
+ }
40
+ if (!rawValue) {
41
+ continue;
42
+ }
43
+ let decodedValue;
44
+ try {
45
+ decodedValue = decodeURIComponent(rawValue);
46
+ }
47
+ catch {
48
+ throw new ValidationError('Invalid X-Mcp4-Params header. Expected comma-separated key=value pairs.');
49
+ }
50
+ const values = filtering[key] ?? [];
51
+ if (values.length >= maxValues) {
52
+ throw new ValidationError(`X-Mcp4-Params exceeds max values for key '${key}'. Max allowed is ${maxValues}.`);
53
+ }
54
+ values.push(decodedValue);
55
+ filtering[key] = values;
56
+ }
57
+ return { filtering, normalizedHeader };
58
+ }
59
+ export function isControlKey(key) {
60
+ return CONTROL_KEYS.has(key);
61
+ }
62
+ export function getFilterMaxValues() {
63
+ const raw = process.env.MCP4_FILTER_MAX_VALUES;
64
+ if (raw === undefined) {
65
+ return 10;
66
+ }
67
+ const parsed = parseInt(raw, 10);
68
+ if (Number.isNaN(parsed) || parsed <= 0) {
69
+ throw new ValidationError(`Invalid MCP4_FILTER_MAX_VALUES: expected positive integer, got '${raw}'.`);
70
+ }
71
+ return parsed;
72
+ }
73
+ function prepareFilteringContext(filtering, toolDef, args, parameterAliases, operation) {
74
+ const aliasToCanonical = buildAliasToCanonical(parameterAliases);
75
+ const toolParamGroups = buildToolParamGroups(toolDef, parameterAliases, aliasToCanonical);
76
+ const filterKeys = Object.keys(filtering).filter(key => !isControlKey(key));
77
+ validateFilterKeys(filterKeys, toolParamGroups, toolDef.parameters);
78
+ const allowedByCanonical = buildAllowedByCanonical(filterKeys, filtering, aliasToCanonical, toolParamGroups);
79
+ const applicableCanonicals = Array.from(allowedByCanonical.keys());
80
+ const operationCategory = resolveOperationCategory(operation, args['action']);
81
+ return {
82
+ aliasToCanonical,
83
+ toolParamGroups,
84
+ allowedByCanonical,
85
+ applicableCanonicals,
86
+ operationCategory,
87
+ hasAnyFilterParam: applicableCanonicals.some(canonical => {
88
+ const group = toolParamGroups.get(canonical);
89
+ return group ? getArgumentValue(args, group.names) !== undefined : false;
90
+ }),
91
+ permissions: {
92
+ allowList: Object.prototype.hasOwnProperty.call(filtering, '_allow_list'),
93
+ allowRead: Object.prototype.hasOwnProperty.call(filtering, '_allow_read')
94
+ },
95
+ action: typeof args['action'] === 'string' ? args['action'] : undefined
96
+ };
97
+ }
98
+ function buildAllowedByCanonical(filterKeys, filtering, aliasToCanonical, toolParamGroups) {
99
+ const allowedByCanonical = new Map();
100
+ for (const key of filterKeys) {
101
+ const canonical = aliasToCanonical.get(key) ?? key;
102
+ if (!toolParamGroups.has(canonical)) {
103
+ continue;
104
+ }
105
+ const values = filtering[key] ?? [];
106
+ if (values.length === 0) {
107
+ continue;
108
+ }
109
+ const existing = allowedByCanonical.get(canonical) ?? [];
110
+ existing.push(...values);
111
+ allowedByCanonical.set(canonical, dedupe(existing));
112
+ }
113
+ return allowedByCanonical;
114
+ }
115
+ function validateParameterValue(argValue, allowedValues, canonical) {
116
+ const allowedSet = new Set(allowedValues);
117
+ if (Array.isArray(argValue)) {
118
+ for (const item of argValue) {
119
+ if (!isPrimitiveValue(item)) {
120
+ throw new AuthorizationError(`Filter conflict for '${canonical}': expected one of [${allowedValues.join(', ')}], got '${formatValue(item)}'.`);
121
+ }
122
+ const stringValue = String(item);
123
+ if (!allowedSet.has(stringValue)) {
124
+ throw new AuthorizationError(`Filter conflict for '${canonical}': expected one of [${allowedValues.join(', ')}], got '${stringValue}'.`);
125
+ }
126
+ }
127
+ return;
128
+ }
129
+ if (typeof argValue === 'object' && argValue !== null) {
130
+ throw new AuthorizationError(`Filter conflict for '${canonical}': expected one of [${allowedValues.join(', ')}], got '${formatValue(argValue)}'.`);
131
+ }
132
+ const stringValue = String(argValue);
133
+ if (!allowedSet.has(stringValue)) {
134
+ throw new AuthorizationError(`Filter conflict for '${canonical}': expected one of [${allowedValues.join(', ')}], got '${stringValue}'.`);
135
+ }
136
+ }
137
+ function validateCanonicalParameter(ctx, canonical, args, toolDef) {
138
+ const allowedValues = ctx.allowedByCanonical.get(canonical) ?? [];
139
+ const group = ctx.toolParamGroups.get(canonical);
140
+ if (!group) {
141
+ return;
142
+ }
143
+ const paramDefinition = toolDef.parameters[canonical];
144
+ const argValue = getArgumentValue(args, group.names);
145
+ const { operationCategory, permissions, hasAnyFilterParam, action } = ctx;
146
+ const isList = operationCategory === 'list';
147
+ const isRead = operationCategory === 'read';
148
+ const isModify = operationCategory === 'modify';
149
+ if (argValue === undefined) {
150
+ if ((isList && permissions.allowList) || (isRead && permissions.allowRead)) {
151
+ return;
152
+ }
153
+ if (action && isRequiredForAction(paramDefinition, action)) {
154
+ throw new AuthorizationError(`Filter requires parameter '${canonical}' for tool '${toolDef.name}' action '${action}'.`);
155
+ }
156
+ if (isModify && hasAnyFilterParam) {
157
+ return;
158
+ }
159
+ if (isList || isRead || isModify) {
160
+ throw new AuthorizationError(`Filter requires parameter '${canonical}' for tool '${toolDef.name}'.`);
161
+ }
162
+ return;
163
+ }
164
+ // For list/read operations, allow _allow_list/_allow_read to relax value enforcement.
165
+ // This enables "read/list any" access while keeping modify operations constrained to the allow-set.
166
+ if ((isList && permissions.allowList) || (isRead && permissions.allowRead)) {
167
+ return;
168
+ }
169
+ validateParameterValue(argValue, allowedValues, canonical);
170
+ }
171
+ export function enforceFiltering(context) {
172
+ const { filtering, toolDef, args, parameterAliases, operation } = context;
173
+ const filterKeys = Object.keys(filtering).filter(key => !isControlKey(key));
174
+ if (filterKeys.length === 0) {
175
+ return;
176
+ }
177
+ const ctx = prepareFilteringContext(filtering, toolDef, args, parameterAliases ?? {}, operation);
178
+ if (ctx.applicableCanonicals.length === 0) {
179
+ return;
180
+ }
181
+ if (ctx.operationCategory === 'modify' && !ctx.hasAnyFilterParam) {
182
+ for (const canonical of ctx.applicableCanonicals) {
183
+ const paramDefinition = toolDef.parameters[canonical];
184
+ if (ctx.action && isRequiredForAction(paramDefinition, ctx.action)) {
185
+ throw new AuthorizationError(`Filter requires parameter '${canonical}' for tool '${toolDef.name}' action '${ctx.action}'.`);
186
+ }
187
+ }
188
+ throw new AuthorizationError(`Filter requires at least one of [${ctx.applicableCanonicals.join(', ')}] for tool '${toolDef.name}'.`);
189
+ }
190
+ for (const canonical of ctx.applicableCanonicals) {
191
+ validateCanonicalParameter(ctx, canonical, args, toolDef);
192
+ }
193
+ }
194
+ function buildAliasToCanonical(parameterAliases) {
195
+ const aliasToCanonical = new Map();
196
+ for (const [canonical, aliases] of Object.entries(parameterAliases)) {
197
+ for (const alias of aliases) {
198
+ if (!aliasToCanonical.has(alias)) {
199
+ aliasToCanonical.set(alias, canonical);
200
+ }
201
+ }
202
+ }
203
+ return aliasToCanonical;
204
+ }
205
+ function buildToolParamGroups(toolDef, parameterAliases, aliasToCanonical) {
206
+ const groups = new Map();
207
+ for (const paramName of Object.keys(toolDef.parameters)) {
208
+ const canonical = aliasToCanonical.get(paramName) ?? paramName;
209
+ const aliasNames = parameterAliases[canonical] ?? [];
210
+ const group = groups.get(canonical) ?? { names: [] };
211
+ group.names = dedupe([canonical, ...aliasNames, paramName, ...group.names]);
212
+ groups.set(canonical, group);
213
+ }
214
+ return groups;
215
+ }
216
+ function validateFilterKeys(filterKeys, toolParamGroups, parameters) {
217
+ const allowedKeys = new Set();
218
+ for (const [canonical, group] of toolParamGroups.entries()) {
219
+ allowedKeys.add(canonical);
220
+ for (const name of group.names) {
221
+ allowedKeys.add(name);
222
+ }
223
+ }
224
+ for (const key of Object.keys(parameters)) {
225
+ allowedKeys.add(key);
226
+ }
227
+ const unknownKeys = filterKeys.filter(key => !allowedKeys.has(key));
228
+ if (unknownKeys.length === 0) {
229
+ return;
230
+ }
231
+ const allowedList = Array.from(allowedKeys).sort().join(', ');
232
+ throw new ValidationError(`Unknown filter key '${unknownKeys[0]}'. Allowed keys: ${allowedList}`);
233
+ }
234
+ function isRequiredForAction(paramDefinition, action) {
235
+ if (!paramDefinition) {
236
+ return false;
237
+ }
238
+ if (paramDefinition.required) {
239
+ return true;
240
+ }
241
+ if (!paramDefinition.required_for || paramDefinition.required_for.length === 0) {
242
+ return false;
243
+ }
244
+ return paramDefinition.required_for.includes(action);
245
+ }
246
+ function getArgumentValue(args, names) {
247
+ for (const name of names) {
248
+ if (args[name] !== undefined) {
249
+ return args[name];
250
+ }
251
+ }
252
+ return undefined;
253
+ }
254
+ function resolveOperationCategory(operation, action) {
255
+ if (operation) {
256
+ const method = operation.method.toLowerCase();
257
+ if (method === 'get') {
258
+ const hasPathParams = operation.parameters.some(param => param.in === 'path');
259
+ return hasPathParams ? 'read' : 'list';
260
+ }
261
+ }
262
+ const actionValue = typeof action === 'string' ? action.toLowerCase() : '';
263
+ if (actionValue === 'list' || actionValue === 'search') {
264
+ return 'list';
265
+ }
266
+ if (actionValue === 'get' || actionValue === 'read') {
267
+ return 'read';
268
+ }
269
+ return 'modify';
270
+ }
271
+ function dedupe(values) {
272
+ return Array.from(new Set(values));
273
+ }
274
+ function isPrimitiveValue(value) {
275
+ return ['string', 'number', 'boolean'].includes(typeof value);
276
+ }
277
+ function formatValue(value) {
278
+ if (value === undefined) {
279
+ return 'undefined';
280
+ }
281
+ if (value === null) {
282
+ return 'null';
283
+ }
284
+ if (Array.isArray(value)) {
285
+ return 'array';
286
+ }
287
+ if (typeof value === 'object') {
288
+ return 'object';
289
+ }
290
+ return String(value);
291
+ }
292
+ //# sourceMappingURL=filtering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filtering.js","sourceRoot":"","sources":["../../src/filtering.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGlE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;AAC7D,MAAM,WAAW,GAAG,mCAAmC,CAAC;AASxD,MAAM,UAAU,6BAA6B,CAAC,KAAc;IAC1D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,WAAmB;IACtD,MAAM,gBAAgB,GAAG,6B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