browse-apis
Explore and filter APIs within a specific API group, using pagination, search terms, and sorting options for efficient navigation and management within the Xano MCP Server.
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 | |
| order | No | Sort order | |
| 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 |
Implementation Reference
- src/index.ts:863-919 (handler)The handler function for the "browse-apis" tool. It constructs query parameters for pagination, search, sorting, fetches the list of APIs from the specified API group using makeXanoRequest, formats them into a Markdown document with details like ID, verb, description, dates, and tags, and returns the 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)Zod input schema defining the parameters for the "browse-apis" tool: required apigroup_id and optional pagination, search, sort, and order parameters.{ 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-920 (registration)The server.tool() call that registers the "browse-apis" tool, specifying its 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 }; } } );