browse-apis
Browse and filter APIs within a specific API group in Xano to manage endpoints and documentation.
Instructions
Browse APIs in a specific API group
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apigroup_id | Yes | ID of the API group to browse | |
| page | No | Page number for pagination | |
| per_page | No | Number of items per page | |
| search | No | Search term to filter APIs | |
| sort | No | Field to sort by | |
| order | No | Sort order |
Implementation Reference
- src/index.ts:863-918 (handler)The main handler function for the 'browse-apis' tool. It fetches APIs from a specific API group in Xano using makeXanoRequest, formats them into markdown, and returns as text content.async ({ apigroup_id, page, per_page, search, sort, order }) => { console.error(`[Tool] Executing browse-apis for API group ID: ${apigroup_id}`); try { // Build query parameters const queryParams = new URLSearchParams(); if (page !== undefined) queryParams.append("page", page.toString()); if (per_page !== undefined) queryParams.append("per_page", per_page.toString()); if (search) queryParams.append("search", search); if (sort) queryParams.append("sort", sort); if (order) queryParams.append("order", order); const queryString = queryParams.toString() ? `?${queryParams.toString()}` : ''; const response = await makeXanoRequest<{ items: XanoApi[], curPage: number, nextPage?: number, prevPage?: number }>( `/workspace/${XANO_WORKSPACE}/apigroup/${apigroup_id}/api${queryString}` ); const apis = response.items; // Format APIs into a readable structure const formattedContent = `# APIs in API Group ID: ${apigroup_id}\n\n` + `Page ${response.curPage}${response.nextPage ? ` (Next: ${response.nextPage})` : ''}${response.prevPage ? ` (Prev: ${response.prevPage})` : ''}\n\n` + `${apis.map(api => `## ${api.name}\n` + `**ID**: ${api.id}\n` + `**Verb**: ${api.verb}\n` + `**Description**: ${api.description || 'No description'}\n` + `${api.docs ? `**Documentation**: ${api.docs}\n` : ''}` + `**Created**: ${new Date(api.created_at).toLocaleString()}\n` + `**Updated**: ${new Date(api.updated_at).toLocaleString()}\n` + `${api.guid ? `**GUID**: ${api.guid}\n` : ''}` + `${api.tag && api.tag.length > 0 ? `**Tags**: ${api.tag.join(', ')}\n` : ''}` ).join('\n\n')}`; console.error(`[Tool] Successfully listed ${apis.length} APIs for API group ID: ${apigroup_id}`); return { content: [ { type: "text", text: formattedContent } ] }; } catch (error) { console.error(`[Error] Failed to browse APIs: ${error instanceof Error ? error.message : String(error)}`); return { content: [ { type: "text", text: `Error browsing APIs: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/index.ts:855-862 (schema)Input schema for the 'browse-apis' tool using Zod validation, defining parameters like apigroup_id (required), and optional pagination, search, sort options.{ apigroup_id: z.string().describe("ID of the API group to browse"), page: z.number().optional().describe("Page number for pagination"), per_page: z.number().optional().describe("Number of items per page"), search: z.string().optional().describe("Search term to filter APIs"), sort: z.enum(["created_at", "updated_at", "name"]).optional().describe("Field to sort by"), order: z.enum(["asc", "desc"]).optional().describe("Sort order") },
- src/index.ts:852-919 (registration)Registration of the 'browse-apis' tool on the MCP server using server.tool(), specifying name, description, input schema, and handler function.server.tool( "browse-apis", "Browse APIs in a specific API group", { apigroup_id: z.string().describe("ID of the API group to browse"), page: z.number().optional().describe("Page number for pagination"), per_page: z.number().optional().describe("Number of items per page"), search: z.string().optional().describe("Search term to filter APIs"), sort: z.enum(["created_at", "updated_at", "name"]).optional().describe("Field to sort by"), order: z.enum(["asc", "desc"]).optional().describe("Sort order") }, async ({ apigroup_id, page, per_page, search, sort, order }) => { console.error(`[Tool] Executing browse-apis for API group ID: ${apigroup_id}`); try { // Build query parameters const queryParams = new URLSearchParams(); if (page !== undefined) queryParams.append("page", page.toString()); if (per_page !== undefined) queryParams.append("per_page", per_page.toString()); if (search) queryParams.append("search", search); if (sort) queryParams.append("sort", sort); if (order) queryParams.append("order", order); const queryString = queryParams.toString() ? `?${queryParams.toString()}` : ''; const response = await makeXanoRequest<{ items: XanoApi[], curPage: number, nextPage?: number, prevPage?: number }>( `/workspace/${XANO_WORKSPACE}/apigroup/${apigroup_id}/api${queryString}` ); const apis = response.items; // Format APIs into a readable structure const formattedContent = `# APIs in API Group ID: ${apigroup_id}\n\n` + `Page ${response.curPage}${response.nextPage ? ` (Next: ${response.nextPage})` : ''}${response.prevPage ? ` (Prev: ${response.prevPage})` : ''}\n\n` + `${apis.map(api => `## ${api.name}\n` + `**ID**: ${api.id}\n` + `**Verb**: ${api.verb}\n` + `**Description**: ${api.description || 'No description'}\n` + `${api.docs ? `**Documentation**: ${api.docs}\n` : ''}` + `**Created**: ${new Date(api.created_at).toLocaleString()}\n` + `**Updated**: ${new Date(api.updated_at).toLocaleString()}\n` + `${api.guid ? `**GUID**: ${api.guid}\n` : ''}` + `${api.tag && api.tag.length > 0 ? `**Tags**: ${api.tag.join(', ')}\n` : ''}` ).join('\n\n')}`; console.error(`[Tool] Successfully listed ${apis.length} APIs for API group ID: ${apigroup_id}`); return { content: [ { type: "text", text: formattedContent } ] }; } catch (error) { console.error(`[Error] Failed to browse APIs: ${error instanceof Error ? error.message : String(error)}`); return { content: [ { type: "text", text: `Error browsing APIs: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );