import{findAllDefinitionsByName as p}from"../utils.js";import{telemetry as a}from"../../../../telemetry/index.js";const r="list-apis",n={type:"object",required:[],additionalProperties:!1,properties:{name:{type:"string",description:"API name (or part of it)",nullable:!0}}};function y(l,o){l.tool(r,"Lists available APIs with their context and purpose",n,async({name:s})=>{try{let e=o;return s&&s!=="null"&&(e=p(o,s)),e.length===0?{content:[{type:"text",text:s?`No APIs found matching "${s}"`:"No APIs available"}]}:(a.sendMcpToolCalledMessage({server_type:"docs",tool:r}),{content:e.map(t=>({type:"text",text:JSON.stringify({name:t.info?.title||"",description:t.info?.description||"",version:t.info?.version||"",paths:Object.keys(t.paths||{}).length,schemas:Object.keys(t.components?.schemas||{}).length,servers:t.servers||[]},null,2)}))})}catch(e){throw a.sendMcpErrorMessage({server_type:"docs",tool:r,message:e?.message||"",stack:e?.stack||""}),e}})}export{y as registerListApisTools};
