@redocly/realm 0.137.0-next.9 → 0.138.0-next.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 (207) hide show
  1. package/CHANGELOG.md +248 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/cli/build/index.js +1 -1
  4. package/dist/cli/eject/themeOperations.js +1 -1
  5. package/dist/cli/generate/generate-tag.js +1 -1
  6. package/dist/cli/generate/generate.js +1 -1
  7. package/dist/client/app/Sidebar/useActions.js +1 -1
  8. package/dist/client/app/Sidebar/useSidebarItems.js +1 -1
  9. package/dist/client/app/hooks/catalog/useCatalog.d.ts +1 -2
  10. package/dist/client/app/hooks/catalog/useCatalogClassic.js +1 -1
  11. package/dist/client/app/hooks/catalog/useCatalogFilter.js +1 -1
  12. package/dist/client/app/l10n/hooks/useL10n.js +1 -1
  13. package/dist/client/app/l10n/index.js +1 -1
  14. package/dist/client/app/search/sse-parser.d.ts +5 -2
  15. package/dist/client/app/search/sse-parser.js +2 -2
  16. package/dist/client/app/search/useFacets.js +1 -1
  17. package/dist/client/app/seo/SeoTags.js +1 -1
  18. package/dist/client/app/utils/loadAndNavigate.js +1 -1
  19. package/dist/client/constants/ai-search.d.ts +8 -0
  20. package/dist/client/constants/ai-search.js +1 -1
  21. package/dist/constants/l10n/langs/ar.js +1 -1
  22. package/dist/constants/l10n/langs/de.js +1 -1
  23. package/dist/constants/l10n/langs/en.js +1 -1
  24. package/dist/constants/l10n/langs/es.js +1 -1
  25. package/dist/constants/l10n/langs/fr.js +1 -1
  26. package/dist/constants/l10n/langs/hi.js +1 -1
  27. package/dist/constants/l10n/langs/it.js +1 -1
  28. package/dist/constants/l10n/langs/ja.js +1 -1
  29. package/dist/constants/l10n/langs/ko.js +1 -1
  30. package/dist/constants/l10n/langs/pl.js +1 -1
  31. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  32. package/dist/constants/l10n/langs/pt.js +1 -1
  33. package/dist/constants/l10n/langs/ru.js +1 -1
  34. package/dist/constants/l10n/langs/uk.js +1 -1
  35. package/dist/constants/l10n/langs/zh.js +1 -1
  36. package/dist/markdoc/helpers/guards/is-example-node.d.ts +2 -1
  37. package/dist/markdoc/helpers/guards/is-example-node.js +1 -1
  38. package/dist/markdoc/nodes/fence/index.js +1 -1
  39. package/dist/server/config/env-config.d.ts +2 -0
  40. package/dist/server/config/env-schema.d.ts +5 -0
  41. package/dist/server/config/env-schemas/feature-flags.d.ts +4 -0
  42. package/dist/server/config/env-schemas/feature-flags.js +1 -1
  43. package/dist/server/constants/entitlements.d.ts +1 -2
  44. package/dist/server/constants/plugins/search.js +1 -1
  45. package/dist/server/esbuild/esbuild-logger.d.ts +2 -2
  46. package/dist/server/esbuild/esbuild-logger.js +3 -3
  47. package/dist/server/esbuild/plugins/styled-components-ssr.js +1 -1
  48. package/dist/server/esbuild/plugins/themes-resolver.js +2 -2
  49. package/dist/server/fs/cache.js +1 -1
  50. package/dist/server/fs/fs.js +1 -1
  51. package/dist/server/fs/utils/remove-l10n-prefix.js +1 -1
  52. package/dist/server/persistence/file-hashes/repositories/file-hashes-repository.d.ts +1 -2
  53. package/dist/server/persistence/file-hashes/services/file-hashes-service.d.ts +1 -2
  54. package/dist/server/plugins/analytics/rudderstack/browser-hooks.js +1 -1
  55. package/dist/server/plugins/analytics/segment/browser-hooks.js +1 -1
  56. package/dist/server/plugins/analytics/segment/build-script.js +3 -3
  57. package/dist/server/plugins/api-docs/loader.d.ts +2 -3
  58. package/dist/server/plugins/api-docs/options.d.ts +1 -1
  59. package/dist/server/plugins/api-docs/options.js +1 -1
  60. package/dist/server/plugins/api-docs/search/create-indexer.d.ts +5 -0
  61. package/dist/server/plugins/api-docs/search/create-indexer.js +1 -0
  62. package/dist/server/plugins/api-docs/search/get-ai-search-documents.d.ts +2 -2
  63. package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +41 -41
  64. package/dist/server/plugins/api-docs/search/search-resolver.js +1 -1
  65. package/dist/server/plugins/api-docs/utils/decorators.js +1 -1
  66. package/dist/server/plugins/api-functions/index.js +1 -1
  67. package/dist/server/plugins/catalog-entities/database/repositories/common/revision-repository.js +1 -1
  68. package/dist/server/plugins/catalog-entities/database/repositories/common/version-repository.js +1 -1
  69. package/dist/server/plugins/catalog-entities/database/repositories/entities/entities-write-repository.js +1 -1
  70. package/dist/server/plugins/catalog-entities/database/repositories/utils/normalize-revision-flags.js +1 -1
  71. package/dist/server/plugins/catalog-entities/types/extractors.d.ts +1 -2
  72. package/dist/server/plugins/catalog-entities/utils/openapi-component-content-extractor.d.ts +1 -2
  73. package/dist/server/plugins/catalog-entities/utils/openapi-schema-resolver.d.ts +1 -2
  74. package/dist/server/plugins/config-parser/format-error.js +4 -4
  75. package/dist/server/plugins/config-parser/loaders/content-slugs-loader.js +1 -1
  76. package/dist/server/plugins/config-parser/loaders/versions-config-loader.js +1 -1
  77. package/dist/server/plugins/dev-onboarding/template/components/EditAppDescriptionDialog.js +1 -1
  78. package/dist/server/plugins/dev-onboarding/template/components/EditAppDialog.js +1 -1
  79. package/dist/server/plugins/dev-onboarding/template/components/EditCallbackUrlDialog.js +1 -1
  80. package/dist/server/plugins/l10n/index.js +1 -1
  81. package/dist/server/plugins/lifecycle.js +2 -2
  82. package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.js +1 -1
  83. package/dist/server/plugins/markdown/attribute-resolvers/resolve-svg-content.js +1 -1
  84. package/dist/server/plugins/markdown/compiler.js +1 -1
  85. package/dist/server/plugins/markdown/errors.js +1 -1
  86. package/dist/server/plugins/markdown/is-partial.js +1 -1
  87. package/dist/server/plugins/markdown/markdoc/reparse-example-fences.d.ts +7 -0
  88. package/dist/server/plugins/markdown/markdoc/reparse-example-fences.js +1 -0
  89. package/dist/server/plugins/markdown/markdoc/resolve-raw-partials.js +1 -1
  90. package/dist/server/plugins/markdown/runtime-transform.js +1 -1
  91. package/dist/server/plugins/markdown/search/to-markdown.js +20 -20
  92. package/dist/server/plugins/mcp/codemode/capabilities/fetch/index.js +5 -4
  93. package/dist/server/plugins/mcp/codemode/capabilities/types.d.ts +5 -2
  94. package/dist/server/plugins/mcp/codemode/capabilities/utils.js +4 -4
  95. package/dist/server/plugins/mcp/codemode/code-execution-audit.js +1 -1
  96. package/dist/server/plugins/mcp/codemode/code-execution-telemetry.d.ts +7 -2
  97. package/dist/server/plugins/mcp/codemode/code-execution-telemetry.js +1 -1
  98. package/dist/server/plugins/mcp/codemode/invoke-tool.js +1 -1
  99. package/dist/server/plugins/mcp/codemode/prompts.d.ts +1 -1
  100. package/dist/server/plugins/mcp/codemode/prompts.js +7 -6
  101. package/dist/server/plugins/mcp/codemode/sandbox/create-sandbox-setup.d.ts +2 -2
  102. package/dist/server/plugins/mcp/codemode/sandbox/create-sandbox-setup.js +1 -11
  103. package/dist/server/plugins/mcp/codemode/sandbox/polyfills/console.d.ts +2 -0
  104. package/dist/server/plugins/mcp/codemode/sandbox/polyfills/console.js +7 -0
  105. package/dist/server/plugins/mcp/codemode/sandbox/polyfills/index.d.ts +1 -0
  106. package/dist/server/plugins/mcp/codemode/sandbox/polyfills/index.js +2 -2
  107. package/dist/server/plugins/mcp/codemode/sandbox/tool-input-validator.d.ts +5 -0
  108. package/dist/server/plugins/mcp/codemode/sandbox/tool-input-validator.js +1 -0
  109. package/dist/server/plugins/mcp/codemode/sandbox/unknown-tool-hint.d.ts +12 -0
  110. package/dist/server/plugins/mcp/codemode/sandbox/unknown-tool-hint.js +2 -0
  111. package/dist/server/plugins/mcp/codemode/tools/describe-tools.js +3 -1
  112. package/dist/server/plugins/mcp/codemode/tools/execute.js +1 -1
  113. package/dist/server/plugins/mcp/codemode/tools/manage-credentials.d.ts +2 -2
  114. package/dist/server/plugins/mcp/codemode/tools/manage-credentials.js +2 -2
  115. package/dist/server/plugins/mcp/codemode/tools/tool-errors.d.ts +4 -0
  116. package/dist/server/plugins/mcp/codemode/tools/tool-errors.js +1 -1
  117. package/dist/server/plugins/mcp/constants.d.ts +1 -0
  118. package/dist/server/plugins/mcp/constants.js +1 -1
  119. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.d.ts +1 -0
  120. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.js +1 -1
  121. package/dist/server/plugins/mcp/docs-mcp/tools/core/create-anonymous-session.js +1 -1
  122. package/dist/server/plugins/mcp/docs-mcp/tools/core/search.js +2 -2
  123. package/dist/server/plugins/mcp/docs-mcp/tools/core/submit-feedback.d.ts +7 -0
  124. package/dist/server/plugins/mcp/docs-mcp/tools/core/submit-feedback.js +3 -0
  125. package/dist/server/plugins/mcp/docs-mcp/tools/core/types.d.ts +8 -2
  126. package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-type.js +5 -5
  127. package/dist/server/plugins/mcp/docs-mcp/tools/graphql/types.d.ts +2 -1
  128. package/dist/server/plugins/mcp/docs-mcp/tools/index.d.ts +1 -0
  129. package/dist/server/plugins/mcp/docs-mcp/tools/index.js +1 -1
  130. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoint-info.js +1 -1
  131. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoints.js +1 -1
  132. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-full-api-description.js +1 -1
  133. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-security-schemes.js +1 -1
  134. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/list-apis.js +1 -1
  135. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/load-api-description.d.ts +17 -3
  136. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/load-api-description.js +1 -1
  137. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/types.d.ts +6 -2
  138. package/dist/server/plugins/mcp/docs-mcp/utils/api-name-matching.d.ts +6 -1
  139. package/dist/server/plugins/mcp/docs-mcp/utils/api-name-matching.js +1 -1
  140. package/dist/server/plugins/mcp/docs-mcp/utils/api-titles.d.ts +14 -0
  141. package/dist/server/plugins/mcp/docs-mcp/utils/api-titles.js +1 -0
  142. package/dist/server/plugins/mcp/gateway-mcp/elicitation.d.ts +11 -0
  143. package/dist/server/plugins/mcp/gateway-mcp/elicitation.js +5 -5
  144. package/dist/server/plugins/mcp/gateway-mcp/fetch/ssrf-guard.js +1 -1
  145. package/dist/server/plugins/mcp/gateway-mcp/fetch/url-placeholders.d.ts +5 -0
  146. package/dist/server/plugins/mcp/gateway-mcp/fetch/url-placeholders.js +1 -0
  147. package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
  148. package/dist/server/plugins/mcp/index.js +1 -1
  149. package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
  150. package/dist/server/plugins/mcp/servers/mcp-server.js +3 -3
  151. package/dist/server/plugins/mcp/types.d.ts +1 -0
  152. package/dist/server/plugins/mcp/utils/available-sandbox-tools.js +1 -1
  153. package/dist/server/plugins/mcp/workers/execute-mcp-tool.js +1 -1
  154. package/dist/server/plugins/nav-utils.js +1 -1
  155. package/dist/server/plugins/search/ai-indexer/prepare-semantic-documents.js +1 -1
  156. package/dist/server/plugins/search/engines/flexsearch/index.js +1 -1
  157. package/dist/server/plugins/search/engines/flexsearch/search-index.d.ts +8 -4
  158. package/dist/server/plugins/search/engines/flexsearch/search-index.js +1 -1
  159. package/dist/server/plugins/search/llmstxt/create-llms-txt-generator.js +1 -1
  160. package/dist/server/plugins/search/llmstxt/index.d.ts +3 -1
  161. package/dist/server/plugins/search/llmstxt/index.js +9 -9
  162. package/dist/server/plugins/search/llmstxt/is-included-in-llms-txt.d.ts +1 -2
  163. package/dist/server/sandbox/constants/host-functions.d.ts +3 -0
  164. package/dist/server/sandbox/constants/host-functions.js +1 -1
  165. package/dist/server/sandbox/constants/sandbox.d.ts +10 -0
  166. package/dist/server/sandbox/constants/sandbox.js +1 -1
  167. package/dist/server/sandbox/sandbox.js +3 -3
  168. package/dist/server/sandbox/types.d.ts +12 -0
  169. package/dist/server/sandbox/utils/execution-budget.js +1 -1
  170. package/dist/server/sandbox/utils/read-result.d.ts +8 -0
  171. package/dist/server/sandbox/utils/read-result.js +1 -0
  172. package/dist/server/sandbox/utils/return-last-expression.d.ts +6 -0
  173. package/dist/server/sandbox/utils/return-last-expression.js +1 -0
  174. package/dist/server/sandbox/utils/returns-from-top-level.d.ts +1 -2
  175. package/dist/server/sandbox/utils/returns-from-top-level.js +1 -1
  176. package/dist/server/sandbox/utils/setup-host-functions.d.ts +1 -0
  177. package/dist/server/sandbox/utils/setup-host-functions.js +3 -3
  178. package/dist/server/ssr/index.js +1 -1
  179. package/dist/server/ssr/render.js +1 -1
  180. package/dist/server/store.d.ts +1 -1
  181. package/dist/server/store.js +1 -1
  182. package/dist/server/tools/notifiers/helpers/privacy/remove-pii.js +1 -1
  183. package/dist/server/types/plugins/common.d.ts +1 -2
  184. package/dist/server/types/plugins/search.d.ts +7 -2
  185. package/dist/server/utils/globs.d.ts +4 -0
  186. package/dist/server/utils/globs.js +1 -1
  187. package/dist/server/utils/rbac.js +1 -1
  188. package/dist/server/utils/search/highlight-text-for-search.js +1 -1
  189. package/dist/server/web-server/middleware/ensureSearchData.js +1 -1
  190. package/dist/server/web-server/routes/catalog/helpers/create-entity-update-schema.d.ts +1 -1
  191. package/dist/server/web-server/routes/catalog/helpers/create-entity-update-schema.js +1 -1
  192. package/dist/server/web-server/routes/dynamic-route.js +1 -1
  193. package/dist/server/web-server/routes/feedback.d.ts +3 -1
  194. package/dist/server/web-server/routes/feedback.js +1 -1
  195. package/dist/server/web-server/routes/mcp-routes/mcp-oauth.js +1 -1
  196. package/dist/server/web-server/routes/mcp-routes/mcp-server-card.js +1 -1
  197. package/dist/server/web-server/routes/otel/otel.js +1 -1
  198. package/dist/server/web-server/utils/legacy-openapi-redirects.js +1 -1
  199. package/dist/types/global-data.d.ts +1 -2
  200. package/dist/utils/slugger.js +1 -1
  201. package/dist/utils/url/sanitize-redirect-pathname.js +1 -1
  202. package/dist/{server/plugins/catalog-entities/utils/version-compare.d.ts → utils/version/compare-versions.d.ts} +1 -16
  203. package/dist/utils/version/compare-versions.js +1 -0
  204. package/package.json +11 -10
  205. package/dist/server/plugins/api-docs/search/search-indexer.d.ts +0 -9
  206. package/dist/server/plugins/api-docs/search/search-indexer.js +0 -1
  207. package/dist/server/plugins/catalog-entities/utils/version-compare.js +0 -1
@@ -1 +1 @@
1
- import{executeMcpTool as c}from"../workers/execute-mcp-tool.js";async function a(t,r,o,u){const e=await c({toolName:t,args:r,context:o,extra:u});if(e.isError)throw new Error(n(e));return e.structuredContent!==void 0?e.structuredContent:i(n(e))}function n(t){return t.content.filter(r=>r.type==="text").map(r=>r.text).join("")}function i(t){try{return JSON.parse(t)}catch{return t}}export{a as invokeTool};
1
+ import{executeMcpTool as i}from"../workers/execute-mcp-tool.js";import{ToolResultError as c}from"./tools/tool-errors.js";async function p(t,r,o,u){const e=await i({toolName:t,args:r,context:o,extra:u});if(e.isError)throw new c(n(e));return e.structuredContent!==void 0?e.structuredContent:s(n(e))}function n(t){return t.content.filter(r=>r.type==="text").map(r=>r.text).join("")}function s(t){try{return JSON.parse(t)}catch{return t}}export{p as invokeTool};
@@ -4,6 +4,6 @@ export declare const EXECUTE_ARGS_NOTE = "Both `execute` arguments are required:
4
4
  export declare function buildExecuteDescription(hasFetch: boolean, toolList?: ToolListEntry[]): string;
5
5
  export declare const DESCRIBE_TOOLS_DESCRIPTION: string;
6
6
  export declare function buildCodeModeInstructions(hasFetch: boolean, toolList?: ToolListEntry[]): string;
7
- export declare const PLAIN_EXECUTE_EXAMPLE: string;
7
+ export declare function buildExecuteExample(toolNames: string[]): string;
8
8
  export declare const USAGE_NOTES: string;
9
9
  //# sourceMappingURL=prompts.d.ts.map
@@ -1,7 +1,8 @@
1
- import{buildToolList as i}from"./build-tool-list.js";const l=2048,c="Both `execute` arguments are required: `code` (the JavaScript to run; return a value to receive it) and `description` (a short human-readable summary of what the code does).",n="Available tools (exact signatures come from `describe-tools`):";function a(e,t){if(t.length===0)return e;const o=l-e.length-n.length-3,s=i(t,o);return s?[e,"",n,s].join(`
1
+ import{buildToolList as i}from"./build-tool-list.js";const r=2048,d="Both `execute` arguments are required: `code` (the JavaScript to run; return a value to receive it) and `description` (a short human-readable summary of what the code does).",n="Available tools (exact signatures come from `describe-tools`):";function a(e,t){if(t.length===0)return e;const o=r-e.length-n.length-3,s=i(t,o);return s?[e,"",n,s].join(`
2
2
  `):e}function h(e,t=[]){const o=["Run JavaScript in a sandbox against the documentation tools on the global `tools` object.",e?"The extra globals are `tools`, `fetch`, `URL`, `URLSearchParams`, and `FormData` - there is no `console`, `setTimeout`, `require`, or Node.js API; all other I/O goes through `tools`.":"The only extra global is `tools` - there is no `fetch`, `console`, `setTimeout`, `require`, or Node.js API; all I/O goes through `tools`.","","Workflow - minimize round-trips; one `describe-tools` call plus one `execute` call covers most requests:","1. Analyze the request and decide which sandbox tools it needs.","2. Call `describe-tools` with those names to get their exact TypeScript signatures - inputs, result shapes, and a worked example. NEVER call `execute` with guessed method names, parameter names, enum values, or result field names: read fields off the declared return types, not from assumptions.","3. Batch everything into a SINGLE script: chain tool calls, pass one call's output into the next, process results in plain JavaScript, and `return` only what the request needs."].join(`
3
- `);return a(o,t)}const d=["Get the exact TypeScript signatures of the sandbox tools available to `execute`.","Analyze the user request first, then pass `tools` with only the tool names the request needs (every name is listed in this input schema / description); omit `tools` only when you cannot tell which tools apply.","Always call this before your first `execute` and never guess signatures. Request every tool the task may need in ONE call instead of calling this repeatedly."].join(`
4
- `);function u(e,t=[]){const o=["This server exposes documentation tools (API discovery, endpoint details, security schemes, full-text search) through two tools:","- `describe-tools` returns the exact TypeScript signatures of the sandbox tools.","- `execute` runs JavaScript that calls those tools on the global `tools` object.","Workflow: analyze the request, call `describe-tools` once with only the tool names it needs, then batch everything into a single `execute` script. Minimize round-trips and never guess tool signatures.",...e?["The sandbox also has a global `fetch` that can call the documented APIs (allow-listed hosts only). Include `fetch` in your `describe-tools` call to get its contract and the list of callable APIs."]:[]].join(`
5
- `);return a(o,t)}const p=["Example - list the write endpoints of an API:","","```ts","const { items } = await tools.listApis({ filter: 'billing' });","const [api] = items;",`if (!api) return { error: 'no API matches "billing"' };`,"const { endpoints } = await tools.getEndpoints({ name: api.name });","const writes = endpoints.filter((e) => e.method !== 'GET');","return { api: api.name, writes: writes.map((e) => `${e.method} ${e.path}`) };","```"].join(`
6
- `),m=["Types named `OpenApi\u2026` are the standard OpenAPI Specification objects.","Payload samples live on a media type object (`requestBody.content[mediaType]`, `responses[code].content[mediaType]`): `.example` holds a single value, `.examples[name].value` a named map, and some descriptions only set `.schema.example`. Read each before concluding a sample is absent."].join(`
7
- `);export{d as DESCRIBE_TOOLS_DESCRIPTION,l as DESCRIPTION_CHAR_LIMIT,c as EXECUTE_ARGS_NOTE,p as PLAIN_EXECUTE_EXAMPLE,m as USAGE_NOTES,u as buildCodeModeInstructions,h as buildExecuteDescription};
3
+ `);return a(o,t)}const p=["Get the exact TypeScript signatures of the sandbox tools available to `execute`.","Analyze the user request first, then pass `tools` with only the tool names the request needs (every name is listed in this input schema / description); omit `tools` only when you cannot tell which tools apply.","Always call this before your first `execute` and never guess signatures. Request every tool the task may need in ONE call instead of calling this repeatedly."].join(`
4
+ `);function m(e,t=[]){const o=["This server exposes documentation tools (API discovery, endpoint details, security schemes, full-text search) through `describe-tools` and `execute`:","- `describe-tools` returns the exact TypeScript signatures of the sandbox tools.","- `execute` runs JavaScript that calls those tools on the global `tools` object.","Workflow: analyze the request, call `describe-tools` once with only the tool names it needs, then batch everything into a single `execute` script. Minimize round-trips and never guess tool signatures.",...e?["The sandbox also has a global `fetch` that can call the documented APIs (allow-listed hosts only). Include `fetch` in your `describe-tools` call to get its contract and the list of callable APIs."]:[]].join(`
5
+ `);return a(o,t)}const l=["listApis","getEndpoints"],c=["Example - list the write endpoints of an API:","","```ts","const { items } = await tools.listApis({ filter: 'billing' });","const [api] = items;",`if (!api) return { error: 'no API matches "billing"' };`,"const { endpoints } = await tools.getEndpoints({ name: api.name });","const writes = endpoints.filter((e) => e.method !== 'GET');","return { api: api.name, writes: writes.map((e) => `${e.method} ${e.path}`) };","```"].join(`
6
+ `);function g(e){if(l.every(o=>e.includes(o)))return c;const[t]=e;return t?[`Example - call \`${t}\` and return what the request needs:`,"","```ts",`const result = await tools.${t}({ /* the input its signature above declares */ });`,"return result;","```"].join(`
7
+ `):""}const b=["Types named `OpenApi\u2026` are the standard OpenAPI Specification objects.","Payload samples live on a media type object (`requestBody.content[mediaType]`, `responses[code].content[mediaType]`): `.example` holds a single value, `.examples[name].value` a named map, and some descriptions only set `.schema.example`. Read each before concluding a sample is absent."].join(`
8
+ `);export{p as DESCRIBE_TOOLS_DESCRIPTION,r as DESCRIPTION_CHAR_LIMIT,d as EXECUTE_ARGS_NOTE,b as USAGE_NOTES,m as buildCodeModeInstructions,h as buildExecuteDescription,g as buildExecuteExample};
@@ -3,8 +3,8 @@ import type { SandboxFetch, SandboxTool } from '../types.js';
3
3
  /**
4
4
  * Builds the `setupContext` that shapes the shared sandbox (`~/server/sandbox`) for code
5
5
  * mode: the given tools — and, when provided, host fetch — become host-function rails, each
6
- * capped and bound by the run's budget, and the prelude installs the code-mode guest surface
7
- * over them.
6
+ * capped and bound by the run's budget, and the fetch prelude installs the guest `fetch`
7
+ * surface over its rail.
8
8
  */
9
9
  export declare function createSandboxSetup(tools: Record<string, SandboxTool>, hostFetch?: SandboxFetch): SetupSandboxContext;
10
10
  //# sourceMappingURL=create-sandbox-setup.d.ts.map
@@ -1,11 +1 @@
1
- import{setupHostFunctions as a}from"../../../../sandbox/utils/setup-host-functions.js";import{evalGuestCode as p}from"../../../../sandbox/utils/eval-guest-code.js";import{SANDBOX_FETCH_SETUP as i}from"./polyfills/index.js";import{FETCH_BRIDGE_FUNCTION_NAME as u,FETCH_BRIDGE_GLOBAL_NAME as c,TOOLS_BRIDGE_GLOBAL_NAME as n}from"../constants.js";const m=100,f=50;function T(r,t){return(e,l)=>{const s=[a(e,r,{globalName:n,budget:l,maxCalls:m,messages:{outputTooLarge:o=>`Tool output is too large (${o} bytes); request narrower data instead`,callLimitExceeded:o=>`Exceeded the limit of ${o} tool calls`}})];return t&&s.push(a(e,{[u]:o=>t(o)},{globalName:c,budget:l,maxCalls:f,messages:{outputTooLarge:o=>`Response is too large (${o} bytes); request less data`,callLimitExceeded:o=>`Exceeded the limit of ${o} fetch calls`}})),p(e,E(!!t)),()=>{for(const o of s)o()}}}function E(r){const t=r?i:"",e=`globalThis[${JSON.stringify(n)}]`;return`(() => {${t}
2
- const tools = ${e};
3
- ${e} = new Proxy(tools, {
4
- get(target, prop) {
5
- if (typeof prop !== 'string' || prop in target || prop === 'then' || prop === 'toJSON') {
6
- return target[prop];
7
- }
8
- throw new TypeError('Unknown tool "' + prop + '". Available tools: ' + Object.keys(target).join(', '));
9
- },
10
- });
11
- })();`}export{T as createSandboxSetup};
1
+ import{setupHostFunctions as l}from"../../../../sandbox/utils/setup-host-functions.js";import{evalGuestCode as r}from"../../../../sandbox/utils/eval-guest-code.js";import{CONSOLE_STUB as u,SANDBOX_FETCH_SETUP as _}from"./polyfills/index.js";import{FETCH_BRIDGE_FUNCTION_NAME as i,FETCH_BRIDGE_GLOBAL_NAME as E,TOOLS_BRIDGE_GLOBAL_NAME as L}from"../constants.js";const T=1e3,c=50,p=8*1024*1024;function A(m,t){return(o,s)=>{r(o,`(() => {${u}})();`);const a=[l(o,m,{globalName:L,budget:s,maxCalls:T,maxOutputBytes:p,messages:{outputTooLarge:e=>`Tool output is too large (${e} bytes); request narrower data instead`,callLimitExceeded:e=>`Exceeded the limit of ${e} tool calls`}})];return t&&(a.push(l(o,{[i]:e=>t(e)},{globalName:E,budget:s,maxCalls:c,messages:{outputTooLarge:e=>`Response is too large (${e} bytes); request less data`,callLimitExceeded:e=>`Exceeded the limit of ${e} fetch calls`}})),r(o,`(() => {${_}})();`)),()=>{for(const e of a)e()}}}export{A as createSandboxSetup};
@@ -0,0 +1,2 @@
1
+ export declare const CONSOLE_STUB = "\nglobalThis.console = Object.freeze({\n assert() {}, clear() {}, count() {}, countReset() {}, debug() {}, dir() {}, dirxml() {},\n error() {}, group() {}, groupCollapsed() {}, groupEnd() {}, info() {}, log() {}, table() {},\n time() {}, timeEnd() {}, timeLog() {}, trace() {}, warn() {},\n});\n";
2
+ //# sourceMappingURL=console.d.ts.map
@@ -0,0 +1,7 @@
1
+ const e=`
2
+ globalThis.console = Object.freeze({
3
+ assert() {}, clear() {}, count() {}, countReset() {}, debug() {}, dir() {}, dirxml() {},
4
+ error() {}, group() {}, groupCollapsed() {}, groupEnd() {}, info() {}, log() {}, table() {},
5
+ time() {}, timeEnd() {}, timeLog() {}, trace() {}, warn() {},
6
+ });
7
+ `;export{e as CONSOLE_STUB};
@@ -1,3 +1,4 @@
1
1
  /** The guest prelude installed when the gateway fetch capability is on */
2
2
  export declare const SANDBOX_FETCH_SETUP: string;
3
+ export { CONSOLE_STUB } from './console.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
- import{FETCH_SHIM as o}from"./fetch-shim.js";import{FORM_DATA_POLYFILL as L}from"./form-data.js";import{URL_POLYFILL as r}from"./url.js";import{URL_SEARCH_PARAMS_POLYFILL as _}from"./url-search-params.js";const i=[_,r,L,o].join(`
2
- `);export{i as SANDBOX_FETCH_SETUP};
1
+ import{FETCH_SHIM as o}from"./fetch-shim.js";import{FORM_DATA_POLYFILL as L}from"./form-data.js";import{URL_POLYFILL as r}from"./url.js";import{URL_SEARCH_PARAMS_POLYFILL as _}from"./url-search-params.js";const p=[_,r,L,o].join(`
2
+ `);import{CONSOLE_STUB as f}from"./console.js";export{f as CONSOLE_STUB,p as SANDBOX_FETCH_SETUP};
@@ -0,0 +1,5 @@
1
+ type ToolInputValidator = (input: unknown) => string | undefined;
2
+ /** Validates a sandbox tool call against the tool's MCP input schema before the handler runs. */
3
+ export declare function createToolInputValidator(sandboxName: string, schema: Record<string, unknown>): ToolInputValidator;
4
+ export {};
5
+ //# sourceMappingURL=tool-input-validator.d.ts.map
@@ -0,0 +1 @@
1
+ import s from"@redocly/ajv";const c=new s({allErrors:!0}),n=new Map;function f(t,r){const e=d(r);if(!e)return()=>{};const o=Object.keys(r.properties??{});return i=>{if(e(i??{}))return;const a=p(e.errors??[]);return`Invalid input for tools.${t}: ${a.join("; ")}. Accepted properties: ${o.join(", ")}. Call describe-tools for the exact signature.`}}function d(t){const r=JSON.stringify(t);if(n.has(r))return n.get(r);let e;try{e=c.compile(t)}catch{e=void 0}return n.set(r,e),e}function p(t){const r=new Set;for(const e of t)switch(e.keyword){case"additionalProperties":r.add(`unknown property "${e.params.additionalProperty}"`);break;case"required":r.add(`missing required property "${e.params.missingProperty}"`);break;default:r.add(`${u(e.instancePath)} ${e.message}`)}return[...r]}function u(t){return t?`"${t.replace(/^\//,"").replace(/\//g,".")}"`:"input"}export{f as createToolInputValidator};
@@ -0,0 +1,12 @@
1
+ import type { GuestPosition } from '../../../../sandbox/types.js';
2
+ export type GuestErrorDescription = {
3
+ message: string;
4
+ unknownTool?: string;
5
+ };
6
+ /**
7
+ * Turns a guest error into the message the model reads. A call on a tool the sandbox does not
8
+ * hold names that tool and lists the available ones; every other error keeps its message and
9
+ * gains the line it was thrown on.
10
+ */
11
+ export declare function describeGuestError(code: string, message: string, position: GuestPosition | undefined, availableTools: string[]): GuestErrorDescription;
12
+ //# sourceMappingURL=unknown-tool-hint.d.ts.map
@@ -0,0 +1,2 @@
1
+ import{TOOLS_BRIDGE_GLOBAL_NAME as c}from"../constants.js";const i="not a function",d=new RegExp(`(?:^|[^\\w$.])${c}\\s*(?:(?:\\?\\.|\\.)\\s*([A-Za-z_$][\\w$]*)|(?:\\?\\.)?\\s*\\[\\s*(['"])([^'"]*)\\2\\s*\\])\\s*(?:\\?\\.)?\\s*$`);function $(o,t,n,e){const f=n&&E(o,n);if(!n||f===void 0)return{message:t};const s=t===i?l(o.slice(0,f),e):void 0;return s===void 0?{message:`${t} (line ${n.line})`}:{message:`Unknown tool "${s}". Available tools: ${e.join(", ")}`,unknownTool:s}}function l(o,t){const n=d.exec(o),e=n?.[1]??n?.[3];return e!==void 0&&!t.includes(e)?e:void 0}function E(o,{line:t,column:n}){const e=o.split(`
2
+ `);if(t>e.length)return;const s=e.slice(0,t-1).reduce((u,r)=>u+r.length+1,0)+n-1;return s<=o.length?s:void 0}export{$ as describeGuestError};
@@ -1 +1,3 @@
1
- import{renderDescribeToolsOutput as S}from"../capabilities/index.js";import{McpServerType as y}from"../../constants.js";import{reportMcpToolCalled as v,reportMcpToolError as O}from"../../workers/mcp-tool-telemetry.js";import{DESCRIBE_TOOLS_TOOL_NAME as p}from"../constants.js";import{DESCRIBE_TOOLS_DESCRIPTION as k}from"../prompts.js";import{sanitizeToolName as s}from"../build-tool-type-declarations.js";import{UnknownToolError as w}from"./tool-errors.js";function x(i,l){const r=[...new Set([...i.map(n=>s(n.name)),...l.map(n=>s(n.id))])];return{name:p,title:"Describe tools",description:k,schema:{type:"object",required:[],additionalProperties:!1,properties:{tools:{type:"array",description:`Tool names to describe: ${r.join(", ")}. Omit to describe everything.`,items:r.length>0?{type:"string",enum:r}:{type:"string"},nullable:!0}}}}}function P(i,l,r,n){const c=new Map(i.map(t=>[s(t.name),t])),m=new Map(r.map(t=>[s(t.id),t]));return async t=>{const d=performance.now(),f=n.mcpMode??"code";try{const o=[...new Set((t.tools??[]).map(s))],a=o.length===0,u=o.filter(e=>!c.has(e)&&!m.has(e));if(u.length>0){const e=[...c.keys(),...m.keys()];throw new w(`Unknown tool(s): ${u.join(", ")}. Valid tools: ${e.join(", ")}.`)}const g=a?r:r.filter(e=>o.includes(s(e.id))),T=a?i:o.filter(e=>c.has(e)).map(e=>c.get(e)),M=await Promise.all(T.map(e=>l(e.name))),E=T.filter((e,b)=>M[b]),h=S(E,g,n);return v({tool:p,mode:f,serverType:y.Docs,durationMs:Math.round(performance.now()-d),outputLength:h.length}),{content:[{type:"text",text:h}]}}catch(o){const a=o instanceof w;throw O({tool:p,mode:f,serverType:y.Docs,durationMs:Math.round(performance.now()-d),message:o instanceof Error?o.message:String(o),stack:!a&&o instanceof Error&&o.stack||"",errorClass:a?"tool_error":"server_error"}),o}}}export{P as describeTools,x as describeToolsSchema};
1
+ import{renderDescribeToolsOutput as O}from"../capabilities/index.js";import{McpServerType as M}from"../../constants.js";import{reportMcpToolCalled as _,reportMcpToolError as k}from"../../workers/mcp-tool-telemetry.js";import{DESCRIBE_TOOLS_TOOL_NAME as d}from"../constants.js";import{DESCRIBE_TOOLS_DESCRIPTION as D}from"../prompts.js";import{sanitizeToolName as n}from"../build-tool-type-declarations.js";import{UnknownToolError as v}from"./tool-errors.js";function x(i,c){const t=[...new Set([...i.map(s=>n(s.name)),...c.map(s=>n(s.id))])];return{name:d,title:"Describe tools",description:D,schema:{type:"object",required:[],additionalProperties:!1,properties:{tools:{type:"array",description:`Tool names to describe: ${t.join(", ")}. Omit to describe everything.`,items:t.length>0?{type:"string",enum:t}:{type:"string"},nullable:!0}}}}}function P(i,c,t,s){const l=new Map(i.map(r=>[n(r.name),r])),f=new Map(t.map(r=>[n(r.id),r]));return async r=>{const u=performance.now(),h=s.mcpMode??"code";try{const o=[...new Set((r.tools??[]).map(n))],a=o.length===0,T=o.filter(e=>!l.has(e)&&!f.has(e));if(T.length>0){const e=[...l.keys(),...f.keys()];throw new v(`Unknown tool(s): ${T.join(", ")}. Valid tools: ${e.join(", ")}.`)}const E=a?t:t.filter(e=>o.includes(n(e.id))),p=a?i:o.filter(e=>l.has(e)).map(e=>l.get(e)),y=await Promise.all(p.map(e=>c(e.name))),S=p.filter((e,m)=>y[m]),w=p.filter((e,m)=>!y[m]),g=[O(S,E,s)];w.length>0&&g.push(`Not available for this request: ${w.map(e=>n(e.name)).join(", ")}`);const b=g.join(`
2
+
3
+ `);return _({tool:d,mode:h,serverType:M.Docs,durationMs:Math.round(performance.now()-u),outputLength:b.length}),{content:[{type:"text",text:b}]}}catch(o){const a=o instanceof v;throw k({tool:d,mode:h,serverType:M.Docs,durationMs:Math.round(performance.now()-u),message:o instanceof Error?o.message:String(o),stack:!a&&o instanceof Error&&o.stack||"",errorClass:a?"tool_error":"server_error"}),o}}}export{P as describeTools,x as describeToolsSchema};
@@ -1 +1 @@
1
- import{runInSandbox as p}from"../../../../sandbox/sandbox.js";import{isMcpToolAvailable as h}from"../../workers/execute-mcp-tool.js";import{importMcpToolHandlers as E}from"../../workers/import-mcp-tool-handlers.js";import{isFetchCapable as b}from"../../gateway-mcp/callable-apis.js";import{buildExecuteHostFetch as w}from"../../gateway-mcp/fetch-capability.js";import{withAuthRequiredMeta as C}from"../../gateway-mcp/upstream-auth.js";import{CODE_MODE_TOOL_NAMES as O,EXECUTE_TOOL_NAME as y}from"../constants.js";import{sanitizeToolName as T}from"../build-tool-type-declarations.js";import{invokeTool as M}from"../invoke-tool.js";import{createSandboxSetup as A}from"../sandbox/create-sandbox-setup.js";import{auditCode as F}from"../code-audit.js";import{reportCodeExecuted as S}from"../code-execution-telemetry.js";import{logCodeExecutionAudit as _}from"../code-execution-audit.js";const x=async(t,o,d)=>{const r=new Set,a=await N(o,d,r),n=[],e=b(o)?await w(o,l=>n.push(l)):void 0;let c=0;const u=e?l=>(c+=1,e(l)):void 0,i=F(t.code);_({audit:i,code:t.code,description:t.description,sessionHandle:t.sessionHandle,toolNames:Object.keys(a),fetchBudget:o.gatewayFetchBudgetPerExec,fetchCapable:e!==void 0});const m=Date.now(),{result:f,error:s}=await p(t.code,{setupContext:A(a,u)});return S({audit:i,fetchCount:c,outcome:s===void 0?"ok":"error",durationMs:Date.now()-m,client:o.client,clientVersion:o.clientVersion}),C({content:[{type:"text",text:JSON.stringify({result:f,error:s})}],isError:s!==void 0,...s!==void 0&&r.has(s)?{errorClass:"tool_error"}:{}},n)};async function N(t,o,d){const r=Object.keys(await E()).filter(e=>!O.has(e)),a=await Promise.all(r.map(e=>h({toolName:e,context:t}).catch(()=>!1))),n={};return r.forEach((e,c)=>{a[c]&&(n[T(e)]=u=>M(e,u,t,o).catch(i=>{throw i instanceof Error&&d.add(i.message),i}))}),n}var J={[y]:x};export{J as default};
1
+ import{runInSandbox as C}from"../../../../sandbox/sandbox.js";import{SANDBOX_FAILURE as E}from"../../../../sandbox/constants/sandbox.js";import{returnLastExpression as y}from"../../../../sandbox/utils/return-last-expression.js";import{isMcpToolAvailable as g}from"../../workers/execute-mcp-tool.js";import{importMcpToolHandlers as A}from"../../workers/import-mcp-tool-handlers.js";import{isFetchCapable as M}from"../../gateway-mcp/callable-apis.js";import{buildExecuteHostFetch as S}from"../../gateway-mcp/fetch-capability.js";import{withAuthRequiredMeta as k}from"../../gateway-mcp/upstream-auth.js";import{CODE_MODE_TOOL_NAMES as v,EXECUTE_TOOL_NAME as x}from"../constants.js";import{sanitizeToolName as F}from"../build-tool-type-declarations.js";import{invokeTool as H}from"../invoke-tool.js";import{createSandboxSetup as R}from"../sandbox/create-sandbox-setup.js";import{createToolInputValidator as D}from"../sandbox/tool-input-validator.js";import{describeGuestError as j}from"../sandbox/unknown-tool-hint.js";import{auditCode as B}from"../code-audit.js";import{reportCodeExecuted as I}from"../code-execution-telemetry.js";import{logCodeExecutionAudit as L}from"../code-execution-audit.js";import{ToolResultError as N}from"./tool-errors.js";const P=async(e,t,n)=>{const i=new Map,s=await U(t,n,i),a=[],o=M(t)?await S(t,h=>a.push(h)):void 0;let f=0;const m=o?h=>(f+=1,o(h).catch(_=>{throw i.set(O(_),{reason:"runtime_error"}),_})):void 0,c=B(e.code);L({audit:c,code:e.code,description:e.description,sessionHandle:e.sessionHandle,toolNames:Object.keys(s),fetchBudget:t.gatewayFetchBudgetPerExec,fetchCapable:o!==void 0});const l=Date.now(),d=y(e.code),{result:u,error:r,failure:b,errorPosition:T}=await C(d,{setupContext:R(s,m),authoredCode:e.code}),w=r===void 0?void 0:j(d,r,T,Object.keys(s)),p=r!==void 0&&b===E.HostError?i.get(r):void 0;return I({audit:c,fetchCount:f,outcome:r===void 0?"ok":"error",durationMs:Date.now()-l,failureReason:V(b,p,w?.unknownTool),failedTool:p?.tool,client:t.client,clientVersion:t.clientVersion}),k({content:[{type:"text",text:JSON.stringify({result:u,error:w?.message})}],isError:r!==void 0,...p?.tool!==void 0?{errorClass:"tool_error"}:{}},a)};function V(e,t,n){return e===E.HostError?t?.reason??"runtime_error":e===E.RuntimeError?n===void 0?e:"unknown_tool":e}async function U(e,t,n){const i=Object.keys(await A()).filter(o=>!v.has(o)),s=await Promise.all(i.map(o=>g({toolName:o,context:e}).catch(()=>!1))),a={};return i.forEach((o,f)=>{if(!s[f])return;const m=F(o),c=e.sandboxToolSchemas?.[o],l=c?D(m,c):void 0;a[m]=d=>{const u=l?.(d);return u?(n.set(u,{tool:o,reason:"inner_tool_error"}),Promise.reject(new Error(u))):H(o,d,e,t).catch(r=>{throw n.set(O(r),{tool:o,reason:r instanceof N?"inner_tool_error":"server_error"}),r})}}),a}function O(e){return e instanceof Error?e.message:String(e)}var ae={[x]:P};export{ae as default};
@@ -1,4 +1,4 @@
1
- import type { CallToolResult, InputRequiredResult } from '@modelcontextprotocol/server';
1
+ import type { CallToolResult, InputRequiredResult, ServerContext } from '@modelcontextprotocol/server';
2
2
  import type { McpToolSchema } from '../../../../types';
3
3
  import type { McpToolContext } from '../../types.js';
4
4
  import type { KvService } from '@redocly/config';
@@ -16,5 +16,5 @@ export declare function manageApiCredentials(context: McpToolContext, deps: Mana
16
16
  api?: unknown;
17
17
  scheme?: unknown;
18
18
  sessionHandle?: unknown;
19
- }) => Promise<CallToolResult | InputRequiredResult>;
19
+ }, ctx: ServerContext) => Promise<CallToolResult | InputRequiredResult>;
20
20
  //# sourceMappingURL=manage-credentials.d.ts.map
@@ -1,2 +1,2 @@
1
- import{MANAGE_API_CREDENTIALS_TOOL_NAME as v}from"../../constants.js";import{buildUpstreamCredentialFallback as y,buildUpstreamCredentialInputRequired as b,schemeLabelOf as P}from"../../gateway-mcp/elicitation.js";import{getCallableApis as m,isFetchCapable as S}from"../../gateway-mcp/callable-apis.js";import{secretStore as I}from"../../gateway-mcp/secret-store.js";import{MISSING_SESSION_HANDLE_MESSAGE as w,resolveSecretSubject as k}from"../../gateway-mcp/subject.js";import{resolveUpstreamApiAuth as j}from"../../gateway-mcp/upstream-auth-scheme.js";function H(e){return!!e.elicitationEnabled&&S(e)}function U(e){const t=m(e).map(n=>n.relativePath);return{name:v,title:"Manage API credentials",description:["Get a secure link where the user sets, replaces, or removes the credentials this server sends to a documented API.","Call it when the user wants to change or clear an API key, or when a tool result tells you the stored credentials were rejected.","The link covers every credential the API accepts, so scheme is optional - pass it only when a tool result names the scheme that was rejected.","It returns a link for the user to open - never ask for the secret in the conversation and never pass it as an argument."].join(`
2
- `),annotations:{readOnlyHint:!1,openWorldHint:!1},schema:{type:"object",required:["api"],additionalProperties:!1,properties:{api:{type:"string",description:`The API to manage credentials for.${t.length>0?` One of: ${t.join(", ")}.`:""}`,minLength:1,...t.length>0?{enum:t}:{}},scheme:{type:"string",description:"Name of the security scheme to manage the credential for, as named in the API description (a tool result that reports a rejected credential names it). Omit it to let the link cover every scheme the API accepts.",minLength:1},sessionHandle:{type:"string",description:"Handle returned by createAnonymousSession. Required while the caller is anonymous, so the credentials are stored against the same subject the API calls use.",minLength:1}}}}}function _(e,c){return async t=>{const n=k(e.user,typeof t.sessionHandle=="string"?t.sessionHandle:void 0);if(n.kind==="invalid")return l(n.message);if(n.kind==="anonymous")return l(w);const{subject:u}=n,h=typeof t.api=="string"?t.api:"",s=m(e).find(o=>o.relativePath===h||o.name===h);if(!s){const o=m(e).map(g=>g.relativePath).join(", ");return l(`Unknown api "${h}". Credentials can only be managed for the APIs this server can call: ${o||"none"}.`)}const r=await j(e,s.relativePath),a=typeof t.scheme=="string"?t.scheme:void 0,A=Object.keys(r.schemes);if(a&&!r.schemes[a])return l(`Unknown scheme "${a}" for api "${s.relativePath}". The security schemes this server can store credentials for are: ${A.join(", ")}.`);const i=a??r.defaultScheme,p=P(r.schemes,i),d=await c.getKv(),f={subject:u,baseUrl:e.baseUrl??"",target:{api:s.relativePath,name:s.name,scheme:i,...p?{schemeLabel:p}:{}},auth:r.schemes[i],apiAuth:r,kv:d,hasExistingSecret:await I.hasSecret(d,u,s.relativePath,i),reason:{kind:"requested"}};return c.getClientCapabilities()?.elicitation?.url?await b(f):{content:[{type:"text",text:await y(f)}],isError:!1}}}function l(e){return{content:[{type:"text",text:e}],isError:!0}}export{H as isManageApiCredentialsToolAvailable,_ as manageApiCredentials,U as manageApiCredentialsSchema};
1
+ import{MANAGE_API_CREDENTIALS_TOOL_NAME as P}from"../../constants.js";import{buildUpstreamCredentialFallback as b,buildUpstreamCredentialInputRequired as I,dedupeElicitation as S,isCredentialElicitationDeclined as k,isStatelessRequest as E,schemeLabelOf as w,supportsUrlElicitation as C}from"../../gateway-mcp/elicitation.js";import{getCallableApis as u,isFetchCapable as j}from"../../gateway-mcp/callable-apis.js";import{secretStore as T}from"../../gateway-mcp/secret-store.js";import{MISSING_SESSION_HANDLE_MESSAGE as q,resolveSecretSubject as $}from"../../gateway-mcp/subject.js";import{upstreamAuthKey as R}from"../../gateway-mcp/upstream-auth.js";import{resolveUpstreamApiAuth as L}from"../../gateway-mcp/upstream-auth-scheme.js";import{apiTitleKey as N,countApiTitles as O}from"../../docs-mcp/utils/api-titles.js";function W(e){return!!e.elicitationEnabled&&j(e)}function z(e){const s=u(e),t=s.map(r=>r.relativePath),a=[...t,...U(s)];return{name:P,title:"Manage API credentials",description:["Get a secure link where the user sets, replaces, or removes the credentials this server sends to a documented API.","Call it when the user wants to change or clear an API key, or when a tool result tells you the stored credentials were rejected.","The link covers every credential the API accepts, so scheme is optional - pass it only when a tool result names the scheme that was rejected.","It returns a link for the user to open - never ask for the secret in the conversation and never pass it as an argument."].join(`
2
+ `),annotations:{readOnlyHint:!1,openWorldHint:!1},schema:{type:"object",required:["api"],additionalProperties:!1,properties:{api:{type:"string",description:`The API to manage credentials for: its \`filePath\` or the \`name\` from \`listApis\`.${t.length>0?` The file paths are: ${t.join(", ")}.`:""}`,minLength:1,...a.length>0?{enum:a}:{}},scheme:{type:"string",description:"Name of the security scheme to manage the credential for, as named in the API description (a tool result that reports a rejected credential names it). Omit it to let the link cover every scheme the API accepts.",minLength:1},sessionHandle:{type:"string",description:"Handle returned by createAnonymousSession. Required while the caller is anonymous, so the credentials are stored against the same subject the API calls use.",minLength:1}}}}}function U(e){const s=O(e);return e.map(t=>t.name).filter(t=>s.get(N(t))===1)}function J(e,s){return async(t,a)=>{const r=$(e.user,typeof t.sessionHandle=="string"?t.sessionHandle:void 0);if(r.kind==="invalid")return h(r.message);if(r.kind==="anonymous")return h(q);const{subject:m}=r,p=typeof t.api=="string"?t.api:"",n=u(e).find(c=>c.relativePath===p||c.name===p);if(!n){const c=u(e).map(v=>v.relativePath).join(", ");return h(`Unknown api "${p}". Credentials can only be managed for the APIs this server can call: ${c||"none"}.`)}if(k(a.mcpReq.inputResponses))return{content:[{type:"text",text:`The user declined the credentials prompt for the "${n.name}" API, so this call minted no link.`}],isError:!1};const i=await L(e,n.relativePath),l=typeof t.scheme=="string"?t.scheme:void 0,y=Object.keys(i.schemes);if(l&&!i.schemes[l])return h(`Unknown scheme "${l}" for api "${n.relativePath}". The security schemes this server can store credentials for are: ${y.join(", ")}.`);const o=l??i.defaultScheme,d=w(i.schemes,o),f=await s.getKv(),A={subject:m,baseUrl:e.baseUrl??"",target:{api:n.relativePath,name:n.name,scheme:o,...d?{schemeLabel:d}:{}},auth:i.schemes[o],apiAuth:i,kv:f,hasExistingSecret:await T.hasSecret(f,m,n.relativePath,o),reason:{kind:"requested"}};if(E(a.mcpReq)&&C(s.getClientCapabilities()))return await I(A);const g=R({api:n.relativePath,scheme:o});return{content:[{type:"text",text:await S(`${m}:${g}`,()=>b(A))}],isError:!1}}}function h(e){return{content:[{type:"text",text:e}],isError:!0}}export{W as isManageApiCredentialsToolAvailable,J as manageApiCredentials,z as manageApiCredentialsSchema};
@@ -1,3 +1,7 @@
1
+ /** The tool answered with `isError`, as opposed to failing before it could answer. */
2
+ export declare class ToolResultError extends Error {
3
+ constructor(message: string);
4
+ }
1
5
  export declare class UnknownToolError extends Error {
2
6
  constructor(message: string);
3
7
  }
@@ -1 +1 @@
1
- class n extends Error{constructor(r){super(r),this.name="UnknownToolError"}}export{n as UnknownToolError};
1
+ class s extends Error{constructor(r){super(r),this.name="ToolResultError"}}class e extends Error{constructor(r){super(r),this.name="UnknownToolError"}}export{s as ToolResultError,e as UnknownToolError};
@@ -15,6 +15,7 @@ export declare const MAX_DOCUMENTS_PER_CATEGORY = 3;
15
15
  export declare const DEFAULT_DOCS_MCP_SERVER_NAME = "Docs MCP server";
16
16
  export declare const SUPPORTED_MCP_SCOPES: readonly ['openid', 'profile', 'email', 'offline_access'];
17
17
  export declare const CREATE_ANONYMOUS_SESSION_TOOL_NAME = "createAnonymousSession";
18
+ export declare const SUBMIT_FEEDBACK_TOOL_NAME = "submit-feedback";
18
19
  export declare const MANAGE_API_CREDENTIALS_TOOL_NAME = "manageApiCredentials";
19
20
  export declare const CUSTOM_MCP_TOOLS_META_DIR = "custom-mcp-tools-meta";
20
21
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- import{LATEST_PROTOCOL_VERSION as o}from"@modelcontextprotocol/server";const r={Docs:"docs"},t={InternalError:-32603,ServerError:-32e3,InvalidRequest:-32600,MethodNotFound:-32601,InvalidParams:-32602},E=o,_=3e4,s=15e3,O=3,n="Docs MCP server",S=["openid","profile","email","offline_access"],c="createAnonymousSession",T="manageApiCredentials",M="custom-mcp-tools-meta";export{c as CREATE_ANONYMOUS_SESSION_TOOL_NAME,M as CUSTOM_MCP_TOOLS_META_DIR,_ as DEFAULT_CONNECTION_TIMEOUT_MS,n as DEFAULT_DOCS_MCP_SERVER_NAME,T as MANAGE_API_CREDENTIALS_TOOL_NAME,O as MAX_DOCUMENTS_PER_CATEGORY,E as MCP_PROTOCOL_VERSION,t as McpErrorCodes,r as McpServerType,s as SSE_KEEPALIVE_INTERVAL_MS,S as SUPPORTED_MCP_SCOPES};
1
+ import{LATEST_PROTOCOL_VERSION as o}from"@modelcontextprotocol/server";const t={Docs:"docs"},E={InternalError:-32603,ServerError:-32e3,InvalidRequest:-32600,MethodNotFound:-32601,InvalidParams:-32602},_=o,r=3e4,s=15e3,O=3,n="Docs MCP server",S=["openid","profile","email","offline_access"],c="createAnonymousSession",T="submit-feedback",M="manageApiCredentials",A="custom-mcp-tools-meta";export{c as CREATE_ANONYMOUS_SESSION_TOOL_NAME,A as CUSTOM_MCP_TOOLS_META_DIR,r as DEFAULT_CONNECTION_TIMEOUT_MS,n as DEFAULT_DOCS_MCP_SERVER_NAME,M as MANAGE_API_CREDENTIALS_TOOL_NAME,O as MAX_DOCUMENTS_PER_CATEGORY,_ as MCP_PROTOCOL_VERSION,E as McpErrorCodes,t as McpServerType,s as SSE_KEEPALIVE_INTERVAL_MS,T as SUBMIT_FEEDBACK_TOOL_NAME,S as SUPPORTED_MCP_SCOPES};
@@ -7,6 +7,7 @@ export declare function getDefaultToolSchemas(config: {
7
7
  hasGraphqlApis?: boolean;
8
8
  elicitationEnabled?: boolean;
9
9
  hasCallableApis?: boolean;
10
+ feedbackHidden?: boolean;
10
11
  }): McpToolSchema[];
11
12
  export declare const ALL_DEFAULT_TOOL_NAMES: ReadonlySet<string>;
12
13
  //# sourceMappingURL=tool-schemas.d.ts.map
@@ -1 +1 @@
1
- import{shouldHandleMcpAuth as d}from"../../../utils/rbac/should-handle-mcp-auth.js";import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as m}from"../constants.js";import{GRAPHQL_TYPE_KINDS as o,GRAPHQL_LIST_SCOPES as h}from"./tools/graphql/constants.js";import{OPERATION_METHODS as p}from"./tools/openapi/constants.js";const i={type:"string",nullable:!0},n={limit:{type:"number"},total:{type:"number"},page:{type:"number"},totalPages:{type:"number"}},r={codemodeType:"OpenApiServer[]"},s={codemodeType:"OpenApiSecurityRequirement[]"},l={codemodeType:"Record<string, OpenApiSecurityScheme>"},y={codemodeType:"OpenApiDocument"},f={codemodeType:"OpenApiOperation & { path: string; method: string }"},g={type:"object",additionalProperties:!1,required:[],properties:{filter:{type:"string",description:"Matches part of an API name, or of a description when no name matches",minLength:1,nullable:!0},page:{type:"number",description:"Page number",minimum:1,default:1,nullable:!0},limit:{type:"number",description:"Number of APIs per page. Default is 300",minimum:1,default:300,nullable:!0}}},a={type:"object",required:["name"],additionalProperties:!1,properties:{name:{type:"string",description:"API name, or a unique part of it",minLength:1},version:{type:"string",description:"API version",nullable:!0},filePath:{type:"string",description:"API definition file path",nullable:!0}}},b={type:"object",required:["name","path","method"],additionalProperties:!1,properties:{name:{type:"string",description:"API name, or a unique part of it",minLength:1},path:{type:"string",description:"Endpoint path (e.g. /api/v1/users)",minLength:1},method:{type:"string",description:"HTTP method (GET, POST, PUT, DELETE, etc.)",enum:[...p.map(e=>e.toUpperCase()),...p],minLength:1},version:{type:"string",description:"API version (required when multiple APIs share the same name but differ by version)",nullable:!0},filePath:{type:"string",description:"API definition file path",nullable:!0}}},S={type:"object",required:[],additionalProperties:!1,properties:{}},v={type:"object",required:[],additionalProperties:!1,properties:{}};function H(e){const t=[{name:"list-apis",title:"List APIs",description:"Lists the APIs documented in this project",schema:g,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{name:{type:"string"},description:i,version:i,servers:r,filePath:{type:"string",description:"API definition file path"},...e.hasCallableApis?{callable:{type:"boolean",description:"true = the documented hosts of this API are reachable via `fetch`; false = documentation only"}}:{}}}},...n}}},{name:"get-endpoints",title:"Get endpoints",description:"Get all endpoints for a specific API",schema:a,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{api:{type:"string"},version:{type:"string"},servers:r,endpoints:{type:"array",items:{type:"object",properties:{path:{type:"string"},method:{type:"string"},summary:i,description:i,security:s}}}}}},{name:"get-endpoint-info",title:"Get endpoint info",description:"Get comprehensive information about specific endpoint including parameters, security, and examples",schema:b,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{api:{type:"string"},version:{type:"string"},servers:r,endpoint:f,globalSecurity:s,securitySchemes:l}}},{name:"get-security-schemes",title:"Get security schemes",description:"Get the security schemes for a specific API",schema:a,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{name:i,version:i,securitySchemes:l,security:s}}},{name:"get-full-api-description",title:"Get full API description",description:"Get the complete OpenAPI description",schema:a,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{api:{type:"string"},version:{type:"string"},definition:y}}},T(e.products,e.locales)];return d(e.requiresLogin,e.rbac)&&t.push({name:"whoami",title:"Who am I",description:"Get information about the currently authenticated user",schema:S,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{email:{type:"string"},name:{type:"string"},subject:{type:"string"},clientId:{type:"string"},scope:{type:"string"},issuedAt:{type:"string"},expiresAt:{type:"string"}}}}),e.hasGraphqlApis&&t.push(...O()),e.elicitationEnabled&&t.push({name:m,title:"Create anonymous session",description:"Create an anonymous session handle for storing upstream API credentials. Pass the returned sessionHandle to execute when an API needs credentials and the caller is not signed in. Treat it as a secret and reuse it across calls.",schema:v,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},outputSchema:{type:"object",required:["sessionHandle"],properties:{sessionHandle:{type:"string"}}}}),t}const A={type:"object",required:[],additionalProperties:!1,properties:{filter:{type:"string",description:"GraphQL schema name (or part of it)",minLength:1,nullable:!0},page:{type:"number",description:"Page number",minimum:1,default:1,nullable:!0},limit:{type:"number",description:"Number of results per page. Default is 300",minimum:1,default:300,nullable:!0}}},P={type:"object",required:["name"],additionalProperties:!1,properties:{name:{type:"string",description:"GraphQL schema name",minLength:1},kind:{type:"string",description:'Optional: return only a single category of schema members. With scope "fields", restricts to the fields of that parent category ("objects", "interfaces", or "inputs" only).',enum:[...o],nullable:!0},scope:{type:"string",description:'Optional: what each list item is. "members" (default) lists top-level types and operations. "fields" flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions \u2014 combine with `filter` to search nested fields anywhere in the schema.',enum:[...h],nullable:!0},filter:{type:"string",description:'Optional: only members whose name or description contains this substring, case-insensitive (e.g. "custom tags")',minLength:1,nullable:!0},referencesType:{type:"string",description:'Optional: only members that reference this type directly or transitively (via return, field, argument, union-member or input-field types). Finds cross-cutting members that never name it \u2014 e.g. referencesType "Book" surfaces a search query returning a union that includes Book.',minLength:1,nullable:!0},page:{type:"number",description:"Page number",minimum:1,default:1,nullable:!0},limit:{type:"number",description:"Number of results per page. Default is 300",minimum:1,default:300,nullable:!0}}},L={type:"object",required:["name","type"],additionalProperties:!1,properties:{name:{type:"string",description:"GraphQL schema name",minLength:1},type:{type:"string",description:"Name of the type, operation, or directive",minLength:1},includeReferencedTypes:{type:"boolean",description:"Also include the SDL of every type referenced transitively. Gives the whole subgraph at once, but can be large for highly-connected types.",default:!1,nullable:!0}}},q={type:"object",required:["name"],additionalProperties:!1,properties:{name:{type:"string",description:"GraphQL schema name",minLength:1}}};function O(){return[{name:"list-graphql-apis",title:"List GraphQL APIs",description:"Lists available GraphQL schemas with their context and purpose",schema:A,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{name:{type:"string"},description:i}}},...n}}},{name:"get-graphql-type-list",title:"Get GraphQL type list",description:'List all operations and types in a GraphQL schema as a flat, paginated list. Each item is tagged with its kind (query, object, enum, \u2026) and carries a one-line description; operations also include their return type and argument signature \u2014 use it to decide which members to fetch in detail. Narrow the result with `kind` (one category), `filter` (case-insensitive substring of the member name or description, e.g. "book"), or `referencesType` (only members that use a given type, directly or transitively) to explore a domain cheaply instead of pulling the full schema. To search nested fields \u2014 not just type names \u2014 set scope "fields": it flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions, so `filter` finds things like an input field whose docstring mentions your keyword.',schema:P,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{name:{type:"string"},items:{type:"array",items:{type:"object",properties:{kind:{type:"string",enum:o},name:{type:"string"},description:i,type:{type:"string"},args:{type:"string"},directives:{type:"string"}}}},...n}}},{name:"get-graphql-type",title:"Get GraphQL type",description:'Get the SDL for a single GraphQL type, operation (query/mutation/subscription field), or directive. Without includeReferencedTypes, the SDL is followed by a one-level manifest of every directly referenced type\'s field names (e.g. "input ActionOperationInput { addTags, removeTags }"), so you can see what nested types contain before fetching them. Set includeReferencedTypes to instead pull in the full SDL of every type it references transitively \u2014 the whole structural subgraph in one call, ideal for complete exploration of an entity (e.g. Book and all the types it touches). That traversal only follows what the target depends on; to go the other direction and find the members that use a type, call get-graphql-type-list with `referencesType`.',schema:L,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"string"}},{name:"get-graphql-schema",title:"Get GraphQL schema",description:"Get the complete GraphQL schema as SDL \u2014 the whole type graph in one call. Returns everything, so it can be very large and token-expensive for big schemas; prefer get-graphql-type-list (filter/paginate) plus targeted get-graphql-type calls, and reach for this only for small schemas or when you truly need the full SDL.",schema:q,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"string"}}]}function T(e,t){const c=e&&e.length>0,u=t&&t.length>0;return{name:"search",title:"Search documentation",description:"Search across the documentation to fetch relevant content for a given query",schema:{type:"object",required:["query"],additionalProperties:!1,properties:{query:{type:"string",description:"Search query. Should be a single word or that phrase that is presented in a documentation.",minLength:1},...c?{product:{type:"string",description:"Optional product name to filter search results by specific product.",enum:e,nullable:!0}}:{},...u?{locale:{type:"string",description:"Optional locale code to filter search results by documentation language (e.g. 'en', 'ja'). Use the locale matching the language of the user's request. Defaults to the project's default locale.",enum:t,nullable:!0}}:{}}},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},outputSchema:{type:"string"}}}const E=new Set(H({requiresLogin:!0,hasGraphqlApis:!0,elicitationEnabled:!0}).map(e=>e.name));export{E as ALL_DEFAULT_TOOL_NAMES,H as getDefaultToolSchemas};
1
+ import{SEMANTIC_SEARCH_API_URL as y}from"../../../constants/common.js";import{shouldHandleMcpAuth as f}from"../../../utils/rbac/should-handle-mcp-auth.js";import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as g,SUBMIT_FEEDBACK_TOOL_NAME as b}from"../constants.js";import{GRAPHQL_TYPE_KINDS as l,GRAPHQL_LIST_SCOPES as v}from"./tools/graphql/constants.js";import{OPERATION_METHODS as c}from"./tools/openapi/constants.js";const i={type:"string",nullable:!0},s={limit:{type:"number"},total:{type:"number"},page:{type:"number"},totalPages:{type:"number"}},a={codemodeType:"OpenApiServer[]"},o={codemodeType:"OpenApiSecurityRequirement[]"},u={codemodeType:"Record<string, OpenApiSecurityScheme>"},P={codemodeType:"OpenApiDocument"},A={codemodeType:"OpenApiOperation & { path: string; method: string }"},n={filePath:{type:"string",description:"API definition file path"},otherMatches:{type:"array",description:"Other API definitions the lookup also matched. Present only when several matched; pass `filePath` to pick another one",items:{type:"object",required:["filePath"],properties:{version:{type:"string"},filePath:{type:"string"}}}}},r="When several definitions match the name, the highest version or the shortest file path is used and the rest are listed in `otherMatches`; tell the user which version or file the answer is based on.",S={type:"object",additionalProperties:!1,required:[],properties:{filter:{type:"string",description:"Matches part of an API name, or of a description when no name matches",minLength:1,nullable:!0},page:{type:"number",description:"Page number",minimum:1,default:1,nullable:!0},limit:{type:"number",description:"Number of APIs per page. Default is 300",minimum:1,default:300,nullable:!0}}},p={type:"object",required:[],additionalProperties:!1,properties:{name:{type:"string",description:"API name, or a unique part of it. Omit when `filePath` is given.",minLength:1,nullable:!0},apiName:{type:"string",description:"Alias of `name`",nullable:!0},api:{type:"string",description:"Alias of `name`",nullable:!0},version:{type:"string",description:"API version. When omitted and several versions exist, the highest one is used",nullable:!0},filePath:{type:"string",description:"API definition file path, as returned by `listApis`",nullable:!0}}},H={type:"object",required:["path","method"],additionalProperties:!1,properties:{name:{type:"string",description:"API name, or a unique part of it. Omit when `filePath` is given.",minLength:1,nullable:!0},apiName:{type:"string",description:"Alias of `name`",nullable:!0},api:{type:"string",description:"Alias of `name`",nullable:!0},path:{type:"string",description:"Endpoint path (e.g. /api/v1/users)",minLength:1},method:{type:"string",description:"HTTP method (GET, POST, PUT, DELETE, etc.)",enum:[...c.map(e=>e.toUpperCase()),...c],minLength:1},version:{type:"string",description:"API version. When omitted and several versions exist, the highest one is used",nullable:!0},filePath:{type:"string",description:"API definition file path, as returned by `listApis`",nullable:!0}}},L={type:"object",required:[],additionalProperties:!1,properties:{}},q={type:"object",required:[],additionalProperties:!1,properties:{}},O={type:"object",required:["path","summary"],additionalProperties:!1,properties:{path:{type:"string",description:"Path or URL of the documentation page the feedback is about (e.g. /guides/auth)",minLength:1,maxLength:1e3},summary:{type:"string",description:"One sentence that names what is wrong with the page",minLength:1,maxLength:500},details:{type:"string",description:"Expected versus actual behavior, missing steps, or the snippet that failed",maxLength:4e3,nullable:!0},targetFeature:{type:"string",description:"The API or feature the page documents",maxLength:500,nullable:!0}}};function T(e){const t=[{name:"list-apis",title:"List APIs",description:"Lists the APIs documented in this project",schema:S,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{name:{type:"string"},description:i,version:i,servers:a,filePath:{type:"string",description:"API definition file path"},ambiguousTitle:{type:"boolean",description:"true = another API shares this title; a lookup picks the highest version, or the shortest file path at the same version, and lists the rest in `otherMatches`. Pass `filePath` to pick another one"},...e.hasCallableApis?{callable:{type:"boolean",description:"true = the documented hosts of this API are reachable via `fetch`; false = documentation only"}}:{}}}},...s}}},{name:"get-endpoints",title:"Get endpoints",description:`Get all endpoints for a specific API. ${r}`,schema:p,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",required:["filePath"],properties:{api:{type:"string"},version:{type:"string"},...n,servers:a,endpoints:{type:"array",items:{type:"object",properties:{path:{type:"string"},method:{type:"string"},summary:i,description:i,security:o}}}}}},{name:"get-endpoint-info",title:"Get endpoint info",description:`Get comprehensive information about specific endpoint including parameters, security, and examples. ${r}`,schema:H,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",required:["filePath"],properties:{api:{type:"string"},version:{type:"string"},...n,servers:a,endpoint:A,globalSecurity:o,securitySchemes:u}}},{name:"get-security-schemes",title:"Get security schemes",description:`Get the security schemes for a specific API. ${r}`,schema:p,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",required:["filePath"],properties:{name:i,version:i,...n,securitySchemes:u,security:o}}},{name:"get-full-api-description",title:"Get full API description",description:`Get the complete OpenAPI description. ${r}`,schema:p,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",required:["filePath"],properties:{api:{type:"string"},version:{type:"string"},...n,definition:P}}},...y?[d(e.products,e.locales)]:[]];return f(e.requiresLogin,e.rbac)&&t.push({name:"whoami",title:"Who am I",description:"Get information about the currently authenticated user",schema:L,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{email:{type:"string"},name:{type:"string"},subject:{type:"string"},clientId:{type:"string"},scope:{type:"string"},issuedAt:{type:"string"},expiresAt:{type:"string"}}}}),e.feedbackHidden||t.push({name:b,title:"Submit feedback",description:"Report a documentation page that is wrong or incomplete",schema:O,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},outputSchema:{type:"object",required:["status","page","message"],properties:{status:{type:"string"},page:{type:"string"},message:{type:"string"}}}}),e.hasGraphqlApis&&t.push(...E()),e.elicitationEnabled&&e.hasCallableApis&&t.push({name:g,title:"Create anonymous session",description:"Create an anonymous session handle for storing upstream API credentials. Pass the returned sessionHandle to execute when an API needs credentials and the caller is not signed in. Treat it as a secret and reuse it across calls.",schema:q,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},outputSchema:{type:"object",required:["sessionHandle"],properties:{sessionHandle:{type:"string"}}}}),t}const G={type:"object",required:[],additionalProperties:!1,properties:{filter:{type:"string",description:"GraphQL schema name (or part of it)",minLength:1,nullable:!0},page:{type:"number",description:"Page number",minimum:1,default:1,nullable:!0},limit:{type:"number",description:"Number of results per page. Default is 300",minimum:1,default:300,nullable:!0}}},w={type:"object",required:["name"],additionalProperties:!1,properties:{name:{type:"string",description:"GraphQL schema name",minLength:1},kind:{type:"string",description:'Optional: return only a single category of schema members. With scope "fields", restricts to the fields of that parent category ("objects", "interfaces", or "inputs" only).',enum:[...l,null],nullable:!0},scope:{type:"string",description:'Optional: what each list item is. "members" (default) lists top-level types and operations. "fields" flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions \u2014 combine with `filter` to search nested fields anywhere in the schema.',enum:[...v,null],nullable:!0},filter:{type:"string",description:'Optional: only members whose name or description contains this substring, case-insensitive (e.g. "custom tags")',minLength:1,nullable:!0},referencesType:{type:"string",description:'Optional: only members that reference this type directly or transitively (via return, field, argument, union-member or input-field types). Finds cross-cutting members that never name it \u2014 e.g. referencesType "Book" surfaces a search query returning a union that includes Book.',minLength:1,nullable:!0},page:{type:"number",description:"Page number",minimum:1,default:1,nullable:!0},limit:{type:"number",description:"Number of results per page. Default is 300",minimum:1,default:300,nullable:!0}}},I={type:"object",required:["name"],additionalProperties:!1,properties:{name:{type:"string",description:"GraphQL schema name",minLength:1},type:{type:"string",description:"Name of the type, operation, or directive",minLength:1,nullable:!0},typeName:{type:"string",description:"Alias of `type`",nullable:!0},includeReferencedTypes:{type:"boolean",description:"Also include the SDL of every type referenced transitively. Gives the whole subgraph at once, but can be large for highly-connected types.",default:!1,nullable:!0}}},j={type:"object",required:["name"],additionalProperties:!1,properties:{name:{type:"string",description:"GraphQL schema name",minLength:1}}};function E(){return[{name:"list-graphql-apis",title:"List GraphQL APIs",description:"Lists available GraphQL schemas with their context and purpose",schema:G,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{name:{type:"string"},description:i}}},...s}}},{name:"get-graphql-type-list",title:"Get GraphQL type list",description:'List all operations and types in a GraphQL schema as a flat, paginated list. Each item is tagged with its kind (query, object, enum, \u2026) and carries a one-line description; operations also include their return type and argument signature \u2014 use it to decide which members to fetch in detail. Narrow the result with `kind` (one category), `filter` (case-insensitive substring of the member name or description, e.g. "book"), or `referencesType` (only members that use a given type, directly or transitively) to explore a domain cheaply instead of pulling the full schema. To search nested fields \u2014 not just type names \u2014 set scope "fields": it flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions, so `filter` finds things like an input field whose docstring mentions your keyword.',schema:w,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{name:{type:"string"},items:{type:"array",items:{type:"object",properties:{kind:{type:"string",enum:l},name:{type:"string"},description:i,type:{type:"string"},args:{type:"string"},directives:{type:"string"}}}},...s}}},{name:"get-graphql-type",title:"Get GraphQL type",description:'Get the SDL for a single GraphQL type, operation (query/mutation/subscription field), or directive. Without includeReferencedTypes, the SDL is followed by a one-level manifest of every directly referenced type\'s field names (e.g. "input ActionOperationInput { addTags, removeTags }"), so you can see what nested types contain before fetching them. Set includeReferencedTypes to instead pull in the full SDL of every type it references transitively \u2014 the whole structural subgraph in one call, ideal for complete exploration of an entity (e.g. Book and all the types it touches). That traversal only follows what the target depends on; to go the other direction and find the members that use a type, call get-graphql-type-list with `referencesType`.',schema:I,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"string"}},{name:"get-graphql-schema",title:"Get GraphQL schema",description:"Get the complete GraphQL schema as SDL \u2014 the whole type graph in one call. Returns everything, so it can be very large and token-expensive for big schemas; prefer get-graphql-type-list (filter/paginate) plus targeted get-graphql-type calls, and reach for this only for small schemas or when you truly need the full SDL.",schema:j,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"string"}}]}function d(e,t){const h=e&&e.length>0,m=t&&t.length>0;return{name:"search",title:"Search documentation",description:"Search across the documentation to fetch relevant content for a given query",schema:{type:"object",required:["query"],additionalProperties:!1,properties:{query:{type:"string",description:"Search query. Should be a single word or that phrase that is presented in a documentation.",minLength:1},...h?{product:{type:"string",description:"Optional product name to filter search results by specific product.",enum:[...e,null],nullable:!0}}:{},...m?{locale:{type:"string",description:"Optional locale code to filter search results by documentation language (e.g. 'en', 'ja'). Use the locale matching the language of the user's request. Defaults to the project's default locale.",enum:[...t,null],nullable:!0}}:{}}},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},outputSchema:{type:"string"}}}const x=new Set([...T({requiresLogin:!0,hasGraphqlApis:!0,elicitationEnabled:!0,hasCallableApis:!0}).map(e=>e.name),d().name]);export{x as ALL_DEFAULT_TOOL_NAMES,T as getDefaultToolSchemas};
@@ -1 +1 @@
1
- import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as t}from"../../../constants.js";import{createSessionHandle as n}from"../../../gateway-mcp/subject.js";const o=async()=>({content:[{type:"text",text:JSON.stringify({sessionHandle:n()})}],isError:!1});function i(e){return!!e.elicitationEnabled&&!e.user?.isAuthenticated}var a={[t]:{execute:o,isAvailable:i}};export{a as default,i as isAnonymousSessionToolAvailable};
1
+ import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as o}from"../../../constants.js";import{isFetchCapable as i}from"../../../gateway-mcp/callable-apis.js";import{createSessionHandle as t}from"../../../gateway-mcp/subject.js";const r=async()=>({content:[{type:"text",text:JSON.stringify({sessionHandle:t()})}],isError:!1});function s(e){return!!e.elicitationEnabled&&e.mcpMode==="code"&&i(e)&&!e.user?.isAuthenticated}var c={[o]:{execute:r,isAvailable:s}};export{c as default,s as isAnonymousSessionToolAvailable};
@@ -1,6 +1,6 @@
1
- import{removeTrailingSlash as g,withPathPrefix as y,withoutPathPrefix as E}from"@redocly/theme/core/utils";import{ServerRoutes as L}from"../../../../../../constants/api.js";import{DEFAULT_LOCALE_PLACEHOLDER as S}from"../../../../../../constants/common.js";const w=async(n,t)=>{const{query:e,product:c,locale:l}=n,u=t.config.l10n?.defaultLocale||S,h=JSON.stringify({query:e,product:c,locale:l||u}),f=`${t.internalBaseUrl||t.baseUrl}${y(L.SEMANTIC_SEARCH)}`,o=t.accessToken?`authorization=${String(t.accessToken).replace(/^Bearer /,"")}`:"";try{const s=await fetch(f,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...o?{Cookie:o}:{}},body:h});if(!s.ok)return{content:[{type:"text",text:"Error retrieving search results."}],isError:!0};const p=await s.json(),d=new Set(t.searchIgnoredRoutes??[]),a=(p||[]).filter(r=>!R(r.url,d));if(a.length===0)return{content:[{type:"text",text:"No results found."}]};const m=r=>{try{return new URL(r,t.baseUrl).toString()}catch{return r}},i=a.map(r=>`### [${r.title}](${m(r.url)})
1
+ import{removeTrailingSlash as g,withPathPrefix as y,withoutPathPrefix as E}from"@redocly/theme/core/utils";import{ServerRoutes as L}from"../../../../../../constants/api.js";import{DEFAULT_LOCALE_PLACEHOLDER as S}from"../../../../../../constants/common.js";const w=async(n,t)=>{const{query:e,product:o,locale:l}=n,u=t.config.l10n?.defaultLocale||S,h=JSON.stringify({query:e,...o?{product:o}:{},locale:l||u}),f=`${t.internalBaseUrl||t.baseUrl}${y(L.SEMANTIC_SEARCH)}`,s=t.accessToken?`authorization=${String(t.accessToken).replace(/^Bearer /,"")}`:"";try{const a=await fetch(f,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...s?{Cookie:s}:{}},body:h});if(!a.ok)return{content:[{type:"text",text:"Error retrieving search results."}],isError:!0};const p=await a.json(),d=new Set(t.searchIgnoredRoutes??[]),i=(p||[]).filter(r=>!R(r.url,d));if(i.length===0)return{content:[{type:"text",text:"No results found."}]};const m=r=>{try{return new URL(r,t.baseUrl).toString()}catch{return r}},c=i.map(r=>`### [${r.title}](${m(r.url)})
2
2
 
3
3
  ${r.content}
4
4
  `).join(`
5
5
 
6
- `).trim();return{content:[{type:"text",text:i.length?i:"No results found."}]}}catch{return{content:[{type:"text",text:"Error retrieving search results."}],isError:!0}}};function R(n,t){if(t.size===0)return!1;let e;try{e=new URL(n,"https://relative.invalid").pathname}catch{return!1}e=g(E(e));try{e=decodeURI(e)}catch{}return t.has(e)}var v={search:w};export{v as default};
6
+ `).trim();return{content:[{type:"text",text:c.length?c:"No results found."}]}}catch{return{content:[{type:"text",text:"Error retrieving search results."}],isError:!0}}};function R(n,t){if(t.size===0)return!1;let e;try{e=new URL(n,"https://relative.invalid").pathname}catch{return!1}e=g(E(e));try{e=decodeURI(e)}catch{}return t.has(e)}var v={search:w};export{v as default};
@@ -0,0 +1,7 @@
1
+ import type { McpToolHandler } from '../../../types.js';
2
+ import type { SubmitFeedbackArgs } from './types.js';
3
+ declare const _default: {
4
+ "submit-feedback": McpToolHandler<SubmitFeedbackArgs>;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=submit-feedback.d.ts.map
@@ -0,0 +1,3 @@
1
+ import{getPathPrefix as p,withPathPrefix as h,withoutPathPrefix as l}from"@redocly/theme/core/utils";import{ServerRoutes as g}from"../../../../../../constants/api.js";import{normalizeRouteSlug as b}from"../../../../../../utils/path/normalize-route-slug.js";import{SUBMIT_FEEDBACK_TOOL_NAME as y}from"../../../constants.js";const k="mcp",P="mcp-client";function r(t,e=!1){return{content:[{type:"text",text:JSON.stringify(t)}],isError:e}}function i(t){const e=t?.trim();return e||void 0}function U(t){const e=p();return!!e&&(t===e||t.startsWith(`${e}/`))?l(t):t}function F(t,e){try{const{pathname:n}=new URL(t,e),a=new URL(e);return a.pathname=U(b(n)),a.toString()}catch{return}}function T(t){const e=t.client??P;return t.clientVersion?`${e}/${t.clientVersion}`:e}async function A(t){const n=(await t.json().catch(()=>{}))?.errors;return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}const E=async(t,e)=>{const n=i(t.path),a=i(t.summary);if(!n||!a)return r({error:"Invalid arguments",message:"`path` and `summary` are required."},!0);const c=e.baseUrl;if(!c)return r({error:"Unavailable",message:"The feedback endpoint of this site is not configured."},!0);const s=F(n,c);if(!s)return r({error:"Invalid arguments",message:"`path` must be a page path or URL of this site."},!0);const u=i(t.details),d=T(e),f=e.accessToken?.replace(/^Bearer /,""),m=`${e.internalBaseUrl||c}${h(g.FEEDBACK)}`;let o;try{o=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":d,...f?{Cookie:`authorization=${f}`}:{},...e.clientIp?{"X-Real-IP":e.clientIp}:{}},body:JSON.stringify({component:"comment",path:s,comment:u?`${a}
2
+
3
+ ${u}`:a,agent:d,targetFeature:i(t.targetFeature),origin:k})})}catch{return r({error:"Failed to submit feedback",message:"The feedback endpoint could not be reached."},!0)}return o.status===403?r({error:"Forbidden",message:"You have no access to this page, so feedback for it is not accepted."},!0):o.status===404?r({error:"Not found",message:`No page exists at ${s}.`},!0):o.status===400?r({error:"Invalid feedback",errors:await A(o)},!0):o.ok?r({status:"received",page:s,message:"Thanks for your feedback. The documentation team sees it on the Feedback page."}):r({error:"Failed to submit feedback",message:`The feedback endpoint answered ${o.status}.`},!0)};var N={[y]:E};export{N as default};
@@ -1,7 +1,13 @@
1
1
  export type SearchArgs = {
2
2
  query: string;
3
- product?: string;
4
- locale?: string;
3
+ product?: string | null;
4
+ locale?: string | null;
5
5
  };
6
6
  export type WhoamiArgs = Record<string, never>;
7
+ export type SubmitFeedbackArgs = {
8
+ path: string;
9
+ summary: string;
10
+ details?: string;
11
+ targetFeature?: string;
12
+ };
7
13
  //# sourceMappingURL=types.d.ts.map
@@ -1,10 +1,10 @@
1
- import{respondWithGraphqlSchema as d}from"./tool-helpers.js";import{printTypeOrField as y,printTypeOrFieldWithReferences as a,referencedTypeManifest as $}from"./utils.js";const m=(r,c)=>d(r.name,c,({name:p,schema:n})=>{const{type:e,includeReferencedTypes:l}=r;if(l){const{sdl:t,referencedCount:s}=a(n,e);return`# Schema: ${p}
2
- # Type: ${e} (+ ${s} referenced types)
1
+ import{respondWithGraphqlSchema as s}from"./tool-helpers.js";import{printTypeOrField as d,printTypeOrFieldWithReferences as a,referencedTypeManifest as m}from"./utils.js";const h=(n,i)=>s(n.name,i,({name:p,schema:t})=>{const{includeReferencedTypes:c}=n,e=n.type??n.typeName;if(!e)throw new Error("Pass `type`: the name of the type, operation, or directive.");if(c){const{sdl:r,referencedCount:l}=a(t,e);return`# Schema: ${p}
2
+ # Type: ${e} (+ ${l} referenced types)
3
3
 
4
- ${t}`}const o=`# Schema: ${p}
4
+ ${r}`}const o=`# Schema: ${p}
5
5
  # Type: ${e}
6
6
 
7
- ${y(n,e)}`,f=$(n,e);if(f.length===0)return o;const i=["# Referenced types (one level, names only; fetch a type or set includeReferencedTypes for full SDL):",...f.map(t=>`# ${t}`)].join(`
7
+ ${d(t,e)}`,f=m(t,e);if(f.length===0)return o;const y=["# Referenced types (one level, names only; fetch a type or set includeReferencedTypes for full SDL):",...f.map(r=>`# ${r}`)].join(`
8
8
  `);return`${o}
9
9
 
10
- ${i}`});var h={"get-graphql-type":m};export{h as default};
10
+ ${y}`});var T={"get-graphql-type":h};export{T as default};
@@ -28,7 +28,8 @@ export type GetGraphqlTypeListArgs = {
28
28
  };
29
29
  export type GetGraphqlTypeArgs = {
30
30
  name: string;
31
- type: string;
31
+ type?: string;
32
+ typeName?: string;
32
33
  includeReferencedTypes?: boolean;
33
34
  };
34
35
  export type GetGraphqlSchemaArgs = {
@@ -10,6 +10,7 @@ declare const _default: {
10
10
  'get-full-api-description': import("../../types.js").McpToolHandler<import("./openapi/types.js").ApiNameVersionArgs>;
11
11
  search: import("../../types.js").McpToolHandler<import("./core/types.js").SearchArgs>;
12
12
  whoami: import("../../types.js").McpToolHandler<import("./core/types.js").WhoamiArgs>;
13
+ "submit-feedback": import("../../types.js").McpToolHandler<import("./core/types.js").SubmitFeedbackArgs>;
13
14
  'list-graphql-apis': import("../../types.js").McpToolHandler<import("./graphql/types.js").ListGraphqlApisArgs>;
14
15
  'get-graphql-type-list': import("../../types.js").McpToolHandler<import("./graphql/types.js").GetGraphqlTypeListArgs>;
15
16
  'get-graphql-type': import("../../types.js").McpToolHandler<import("./graphql/types.js").GetGraphqlTypeArgs>;
@@ -1 +1 @@
1
- import o from"./openapi/list-apis.js";import r from"./openapi/get-endpoints.js";import t from"./openapi/get-endpoint-info.js";import m from"./openapi/get-security-schemes.js";import i from"./openapi/get-full-api-description.js";import p from"./core/search.js";import e from"./core/whoami.js";import f from"./core/create-anonymous-session.js";import s from"./graphql/list-graphql-apis.js";import a from"./graphql/get-graphql-type-list.js";import l from"./graphql/get-graphql-type.js";import n from"./graphql/get-graphql-schema.js";var w={...o,...r,...t,...m,...i,...p,...e,...f,...s,...a,...l,...n};export{w as default};
1
+ import o from"./openapi/list-apis.js";import r from"./openapi/get-endpoints.js";import m from"./openapi/get-endpoint-info.js";import t from"./openapi/get-security-schemes.js";import i from"./openapi/get-full-api-description.js";import p from"./core/search.js";import e from"./core/whoami.js";import f from"./core/create-anonymous-session.js";import s from"./core/submit-feedback.js";import a from"./graphql/list-graphql-apis.js";import l from"./graphql/get-graphql-type-list.js";import n from"./graphql/get-graphql-type.js";import h from"./graphql/get-graphql-schema.js";var k={...o,...r,...m,...t,...i,...p,...e,...f,...s,...a,...l,...n,...h};export{k as default};
@@ -1 +1 @@
1
- import{resolveParameters as l,resolveRequestBody as f,resolveResponses as y}from"../../utils/resolve-refs.js";import{isMcpEndpoint as x}from"./utils.js";import{describeMethodMiss as v,describePathMiss as E,visibleMethodsAt as M}from"./endpoint-suggestions.js";import{loadApiDescription as g}from"./load-api-description.js";import{checkEndpointAndDeleteXMcp as P}from"../../../utils/xmcp-utils.js";const b=async(p,a)=>{const{path:r,method:o}=p;if(!r||!o)return{content:[{type:"text",text:'Both "path" and "method" are required (e.g. path: "/tickets", method: "GET").'}],isError:!0};let e;try{e=await g(p,a)}catch(u){return{content:[{type:"text",text:u.message}],isError:!0}}const s=r.startsWith("/")?r:`/${r}`,{title:n=""}=e.info||{},i=e.paths?.[s],c=o.toLowerCase();if(!i||M(e,s).length===0)return{content:[{type:"text",text:E(e,n,s,a.mcpMode)}],isError:!0};const t=i[c];if(!x(t)||!P(t,"docs"))return{content:[{type:"text",text:v(e,n,s,o)}],isError:!0};const d=i?.parameters||[],m=t.parameters||[],h={...t,parameters:l({pathParams:d,opParams:m,definition:e}),requestBody:f(t.requestBody,e),responses:y(t.responses,e)};return{content:[{type:"text",text:JSON.stringify({api:n,version:e.info?.version||"",servers:e.servers||[],endpoint:{path:r,method:o.toUpperCase(),...h},globalSecurity:e.security||[],securitySchemes:e.components?.securitySchemes||{}},null,2)}]}};var C={"get-endpoint-info":b};export{C as default};
1
+ import{resolveParameters as v,resolveRequestBody as E,resolveResponses as M}from"../../utils/resolve-refs.js";import{isMcpEndpoint as P}from"./utils.js";import{describeMethodMiss as g,describePathMiss as b,visibleMethodsAt as q}from"./endpoint-suggestions.js";import{loadApiDescription as B}from"./load-api-description.js";import{checkEndpointAndDeleteXMcp as S}from"../../../utils/xmcp-utils.js";const k=async(c,d)=>{const{path:r,method:o}=c;if(!r||!o)return{content:[{type:"text",text:'Both "path" and "method" are required (e.g. path: "/tickets", method: "GET").'}],isError:!0};let h;try{h=await B(c,d)}catch(p){return{content:[{type:"text",text:p.message}],isError:!0}}const{description:t,filePath:l,otherMatches:n}=h,m=n?` Other definitions share this title: ${n.map(p=>`"${p.filePath}"`).join(", ")}. Pass "filePath" to check them.`:"",s=r.startsWith("/")?r:`/${r}`,{title:i=""}=t.info||{},a=t.paths?.[s],f=o.toLowerCase();if(!a||q(t,s).length===0)return{content:[{type:"text",text:b(t,i,s,d.mcpMode)+m}],isError:!0};const e=a[f];if(!P(e)||!S(e,"docs"))return{content:[{type:"text",text:g(t,i,s,o)+m}],isError:!0};const u=a?.parameters||[],y=e.parameters||[],x={...e,parameters:v({pathParams:u,opParams:y,definition:t}),requestBody:E(e.requestBody,t),responses:M(e.responses,t)};return{content:[{type:"text",text:JSON.stringify({api:i,version:t.info?.version||"",filePath:l,otherMatches:n,servers:t.servers||[],endpoint:{path:r,method:o.toUpperCase(),...x},globalSecurity:t.security||[],securitySchemes:t.components?.securitySchemes||{}},null,2)}]}};var D={"get-endpoint-info":k};export{D as default};
@@ -1 +1 @@
1
- import{loadApiDescription as i}from"./load-api-description.js";import{getEndpointsFromPaths as s}from"./utils.js";const p=async(e,r)=>{let t;try{t=await i(e,r)}catch(o){return{content:[{type:"text",text:o.message}],isError:!0}}const n=s(t);return{content:[{type:"text",text:JSON.stringify({api:t.info?.title||"",version:t.info?.version||"",servers:t.servers||[],endpoints:n},null,2)}]}};var d={"get-endpoints":p};export{d as default};
1
+ import{loadApiDescription as a}from"./load-api-description.js";import{getEndpointsFromPaths as c}from"./utils.js";const d=async(r,n)=>{let e;try{e=await a(r,n)}catch(p){return{content:[{type:"text",text:p.message}],isError:!0}}const{description:t,filePath:o,otherMatches:i}=e,s=c(t);return{content:[{type:"text",text:JSON.stringify({api:t.info?.title||"",version:t.info?.version||"",filePath:o,otherMatches:i,servers:t.servers||[],endpoints:s},null,2)}]}};var m={"get-endpoints":d};export{m as default};
@@ -1 +1 @@
1
- import{loadApiDescription as n}from"./load-api-description.js";const o=async(e,i)=>{let t;try{t=await n(e,i)}catch(r){return{content:[{type:"text",text:r.message}],isError:!0}}return{content:[{type:"text",text:JSON.stringify({api:t.info?.title||"",version:t.info?.version||"",definition:t},null,2)}]}};var s={"get-full-api-description":o};export{s as default};
1
+ import{loadApiDescription as a}from"./load-api-description.js";const c=async(i,r)=>{let e;try{e=await a(i,r)}catch(s){return{content:[{type:"text",text:s.message}],isError:!0}}const{description:t,filePath:n,otherMatches:o}=e;return{content:[{type:"text",text:JSON.stringify({api:t.info?.title||"",version:t.info?.version||"",filePath:n,otherMatches:o,definition:t},null,2)}]}};var p={"get-full-api-description":c};export{p as default};
@@ -1 +1 @@
1
- import{loadApiDescription as s}from"./load-api-description.js";const c=async(t,r)=>{let e;try{e=await s(t,r)}catch(i){return{content:[{type:"text",text:i.message}],isError:!0}}return{content:[{type:"text",text:JSON.stringify({name:e.info?.title,version:e.info?.version,securitySchemes:e.components?.securitySchemes||{},security:e.security||[]},null,2)}]}};var o={"get-security-schemes":c};export{o as default};
1
+ import{loadApiDescription as o}from"./load-api-description.js";const a=async(r,s)=>{let t;try{t=await o(r,s)}catch(n){return{content:[{type:"text",text:n.message}],isError:!0}}const{description:e,filePath:i,otherMatches:c}=t;return{content:[{type:"text",text:JSON.stringify({name:e.info?.title,version:e.info?.version,filePath:i,otherMatches:c,securitySchemes:e.components?.securitySchemes||{},security:e.security||[]},null,2)}]}};var y={"get-security-schemes":a};export{y as default};
@@ -1 +1 @@
1
- import{isFetchCapable as d}from"../../../gateway-mcp/callable-apis.js";import{filterApiDescriptionsByName as g}from"../../utils/api-name-matching.js";const h=async(n,i)=>{const{filter:s,page:l=1,limit:e=300}=n,o=d(i);let t=Object.values(i.apiDescriptionsMap);s&&(t=g(t,s));const a=(l-1)*e,c=a+e,p=Math.ceil(t.length/e),r=t.length;return t=t.slice(a,c),{content:[{type:"text",text:JSON.stringify({items:t.map(({relativePath:f,fetchEligible:m,...u})=>({filePath:f,...u,...o?{callable:m===!0}:{}})),limit:e,total:r,page:l,totalPages:p})}]}};var y={"list-apis":h};export{y as default};
1
+ import{isFetchCapable as h}from"../../../gateway-mcp/callable-apis.js";import{filterApiDescriptionsByName as b}from"../../utils/api-name-matching.js";import{apiTitleKey as y,countApiTitles as T,orderSharedTitles as x}from"../../utils/api-titles.js";const A=async(r,i)=>{const{filter:s,page:l=1,limit:e=300}=r,c=h(i),a=x(Object.values(i.apiDescriptionsMap)),p=T(a);let t=a;s&&(t=b(t,s));const n=(l-1)*e,m=n+e,u=Math.ceil(t.length/e),f=t.length;return t=t.slice(n,m),{content:[{type:"text",text:JSON.stringify({items:t.map(({relativePath:d,fetchEligible:g,...o})=>({filePath:d,...o,...(p.get(y(o.name))??0)>1?{ambiguousTitle:!0}:{},...c?{callable:g===!0}:{}})),limit:e,total:f,page:l,totalPages:u})}]}};var M={"list-apis":A};export{M as default};
@@ -1,8 +1,22 @@
1
1
  import type { OpenAPIDefinition } from '@redocly/api-docs';
2
2
  import type { McpToolContext } from '../../../types.js';
3
- export declare function loadApiDescription({ name, version, filePath }: {
4
- name: string;
3
+ type ApiDescriptionRef = {
4
+ version?: string;
5
+ filePath: string;
6
+ };
7
+ type LoadedApiDescription = {
8
+ description: OpenAPIDefinition;
9
+ filePath: string;
10
+ otherMatches?: ApiDescriptionRef[];
11
+ };
12
+ type ApiLookup = {
13
+ name?: string;
5
14
  version?: string;
6
15
  filePath?: string;
7
- }, context: McpToolContext): Promise<OpenAPIDefinition>;
16
+ };
17
+ export declare function loadApiDescription(args: ApiLookup & {
18
+ apiName?: string;
19
+ api?: string;
20
+ }, context: McpToolContext): Promise<LoadedApiDescription>;
21
+ export {};
8
22
  //# sourceMappingURL=load-api-description.d.ts.map
@@ -1 +1 @@
1
- import{describeAvailableApis as c,findApiDescriptionByNameAndVersion as u}from"../../utils/api-name-matching.js";import{getApiDescriptionFromFs as d}from"./utils.js";async function l({name:r,version:n,filePath:o},i){const e=o?Object.values(i.apiDescriptionsMap).find(s=>s.relativePath===o):u(i.apiDescriptionsMap,r,n);if(!e){if(o)throw new Error(`No API found with filePath "${o}". File paths are returned by the list-apis tool.`);const s=c(i.apiDescriptionsMap,r);throw new Error(s?`No API found matching "${r}". Available APIs: ${s}.`:`No API found matching "${r}".`)}const t=!!i?.config?.access?.requiresLogin,p=i?.config?.access?.rbac||{},a=await d({relativePath:e.relativePath||"",outdir:i.outdir||"",user:i.user,rbac:p,requiresLogin:t});if(!a)throw new Error(`No API found matching "${o||r}".`);return a}export{l as loadApiDescription};
1
+ import{describeAvailableApis as u,findApiDescriptionByNameAndVersion as d}from"../../utils/api-name-matching.js";import{getApiDescriptionFromFs as m}from"./utils.js";function P({name:i,version:t,filePath:c},o){const e=Object.values(o);if(c)return e.filter(s=>s.relativePath===c);const r=e.find(s=>s.relativePath===i);if(r)return[r];const a=d(o,i??"",t);return a?[a.description,...a.otherMatches??[]]:[]}function A({version:i,relativePath:t}){return{...i?{version:i}:{},filePath:t}}async function w(i,t){const{version:c,filePath:o}=i,e=i.name??i.apiName??i.api;if(!o&&!e)throw new Error("Pass `name` (the API title, or a unique part of it) or `filePath` from list-apis.");const r=P({name:e,version:c,filePath:o},t.apiDescriptionsMap);if(r.length===0){if(o)throw new Error(`No API found with filePath "${o}". File paths are returned by the list-apis tool.`);const n=u(t.apiDescriptionsMap,e??"");throw new Error(n?`No API found matching "${e}". Available APIs: ${n}.`:`No API found matching "${e}".`)}const a=!!t?.config?.access?.requiresLogin,s=t?.config?.access?.rbac||{};for(const n of r){const f=await m({relativePath:n.relativePath,outdir:t.outdir||"",user:t.user,rbac:s,requiresLogin:a});if(!f)continue;const h=r.filter(p=>p!==n);return{description:f,filePath:n.relativePath,otherMatches:h.length>0?h.map(A):void 0}}const l=r.map(({relativePath:n})=>`"${n}"`).join(", ");throw new Error(r.length>1?`No API found matching "${e}". None of the matching definitions could be loaded: ${l}.`:`No API found matching "${o||e}".`)}export{w as loadApiDescription};
@@ -4,12 +4,16 @@ export type ListApisArgs = {
4
4
  limit?: number;
5
5
  };
6
6
  export type ApiNameVersionArgs = {
7
- name: string;
7
+ name?: string;
8
+ apiName?: string;
9
+ api?: string;
8
10
  version?: string;
9
11
  filePath?: string;
10
12
  };
11
13
  export type GetEndpointInfoArgs = {
12
- name: string;
14
+ name?: string;
15
+ apiName?: string;
16
+ api?: string;
13
17
  path: string;
14
18
  method: string;
15
19
  version?: string;
@@ -1,8 +1,13 @@
1
1
  import type { ApiDescriptionInfo } from '../../types.js';
2
2
  export declare const MAX_LISTED_CANDIDATES = 15;
3
+ export type ApiDescriptionMatch = {
4
+ description: ApiDescriptionInfo;
5
+ /** The other definitions the lookup matched, absent when it matched exactly one. */
6
+ otherMatches?: ApiDescriptionInfo[];
7
+ };
3
8
  export declare function formatCandidates(items: string[]): string;
4
9
  /** Every API name in the catalog, closest to `name` first. Used to make a miss recoverable. */
5
10
  export declare function describeAvailableApis(apiDescriptionsMap: Record<string, ApiDescriptionInfo>, name: string): string;
6
- export declare function findApiDescriptionByNameAndVersion(apiDescriptionsMap: Record<string, ApiDescriptionInfo>, name: string, version?: string): ApiDescriptionInfo | undefined;
11
+ export declare function findApiDescriptionByNameAndVersion(apiDescriptionsMap: Record<string, ApiDescriptionInfo>, name: string, version?: string): ApiDescriptionMatch | undefined;
7
12
  export declare function filterApiDescriptionsByName(apiDescriptions: ApiDescriptionInfo[], filter: string): ApiDescriptionInfo[];
8
13
  //# sourceMappingURL=api-name-matching.d.ts.map
@@ -1 +1 @@
1
- const $=15,p=new Set(["api","apis","rest","restful","openapi","graphql","spec","specification","service","services"]);function w(s){return s.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean)}function f(s){return new Set(w(s).filter(t=>!p.has(t)))}function d(s,t){return s.size===t.size&&[...s].every(n=>t.has(n))}function h(s){const t=s.slice(0,15),n=s.length-t.length;return n>0?`${t.join(", ")} (+${n} more)`:t.join(", ")}function v(s,t){const n=f(t);return[...new Set(s.map(e=>e.name))].map(e=>({name:e,score:[...f(e)].filter(r=>n.has(r)).length})).sort((e,r)=>r.score-e.score||e.name.localeCompare(r.name)).map(({name:e})=>e)}function g(s,t){const n=Object.values(s);return n.length===0?"":h(v(n,t).map(e=>`"${e}"`))}function T(s,t){const n=t.trim().toLowerCase();if(!n)return{matches:[],isExactTitle:!1};const e=s.map(a=>({api:a,title:a.name.trim().toLowerCase()})),r=a=>a.map(({api:o})=>o),i=e.filter(({title:a})=>a===n);if(i.length>0)return{matches:r(i),isExactTitle:!0};const l=e.filter(({title:a})=>a.includes(n));if(l.length>0)return{matches:r(l),isExactTitle:!1};const m=f(n);if(m.size===0)return{matches:[],isExactTitle:!1};const u=e.filter(({title:a})=>{const o=f(a);return o.size>0&&d(o,m)});return{matches:r(u),isExactTitle:!1}}function A(s,t,n){if(!t)return;const{matches:e,isExactTitle:r}=T(Object.values(s),t);if(e.length===0)return;if(!r){const o=[...new Set(e.map(({name:c})=>c))];if(o.length>1)throw new Error(`"${t}" matches ${o.length} APIs: ${h(o.map(c=>`"${c}"`))}. Pass one of those names exactly, or the "filePath" parameter from list-apis.`)}const i=n?e.filter(o=>o.version===n):e;if(i.length===0){const o=[...new Set(e.map(({version:c})=>c||"(no version)"))];throw new Error(`"${e[0].name||t}" has no version "${n}". Available versions: ${h(o)}.`)}if(i.length===1)return i[0];const l=i[0].name||t;if(new Set(i.map(({version:o})=>o||"")).size>1){const o=i.map(({version:c})=>c||"(no version)").join(", ");throw new Error(`Multiple versions of "${l}" found: ${o}. Specify a version to disambiguate.`)}const u=i.map(({relativePath:o})=>`"${o||"(unknown path)"}"`).join(", "),a=i[0].version?` at version "${i[0].version}"`:"";throw new Error(`Multiple APIs are titled "${l}"${a}. Pass the "filePath" parameter to select one of: ${u}.`)}function E(s,t){const n=t.trim().toLowerCase();if(!n)return s;const e=s.filter(({name:r})=>r.toLowerCase().includes(n));return e.length>0?e:s.filter(({description:r})=>!!r?.toLowerCase().includes(n))}export{$ as MAX_LISTED_CANDIDATES,g as describeAvailableApis,E as filterApiDescriptionsByName,A as findApiDescriptionByNameAndVersion,h as formatCandidates};
1
+ import{apiTitleKey as u,compareApiDescriptions as h}from"./api-titles.js";const T=15,d=new Set(["api","apis","rest","restful","openapi","graphql","spec","specification","service","services"]);function g(r){return r.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean)}function f(r){return new Set(g(r).filter(n=>!d.has(n)))}function w(r,n){return r.size===n.size&&[...r].every(e=>n.has(e))}function m(r){const n=r.slice(0,T),e=r.length-n.length;return e>0?`${n.join(", ")} (+${e} more)`:n.join(", ")}function x(r,n){const e=f(n);return[...new Set(r.map(t=>t.name))].map(t=>({name:t,score:[...f(t)].filter(s=>e.has(s)).length})).sort((t,s)=>s.score-t.score||t.name.localeCompare(s.name)).map(({name:t})=>t)}function E(r,n){const e=Object.values(r);return e.length===0?"":m(x(e,n).map(t=>`"${t}"`))}function A(r,n){const e=u(n);if(!e)return{matches:[],isExactTitle:!1};const t=r.map(o=>({api:o,title:u(o.name)})),s=o=>o.map(({api:l})=>l),c=t.filter(({title:o})=>o===e);if(c.length>0)return{matches:s(c),isExactTitle:!0};const i=t.filter(({title:o})=>o.includes(e));if(i.length>0)return{matches:s(i),isExactTitle:!1};const a=f(e);if(a.size===0)return{matches:[],isExactTitle:!1};const p=t.filter(({title:o})=>{const l=f(o);return l.size>0&&w(l,a)});return{matches:s(p),isExactTitle:!1}}function k(r){const[n,...e]=[...r].sort(h);return e.length===0?{description:n}:{description:n,otherMatches:e}}function S(r,n,e){if(!n)return;const{matches:t,isExactTitle:s}=A(Object.values(r),n);if(t.length===0)return;if(!s){const i=[...new Set(t.map(({name:a})=>a))];if(i.length>1)throw new Error(`"${n}" matches ${i.length} APIs: ${m(i.map(a=>`"${a}"`))}. Pass one of those names exactly, or the "filePath" parameter from list-apis.`)}const c=e?t.filter(i=>i.version===e):t;if(c.length===0){const i=[...new Set(t.map(({version:a})=>a||"(no version)"))];throw new Error(`"${t[0].name||n}" has no version "${e}". Available versions: ${m(i)}.`)}return k(c)}function $(r,n){const e=n.trim().toLowerCase();if(!e)return r;const t=r.filter(({name:s})=>s.toLowerCase().includes(e));return t.length>0?t:r.filter(({description:s})=>!!s?.toLowerCase().includes(e))}export{T as MAX_LISTED_CANDIDATES,E as describeAvailableApis,$ as filterApiDescriptionsByName,S as findApiDescriptionByNameAndVersion,m as formatCandidates};