Skip to main content
Glama

add-api

Add a new API to an API group in the Xano MCP Server by specifying its ID, name, description, HTTP verb, and optional tags for organization.

Instructions

Add a new API to an API group

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apigroup_idYesID of the API group to add the API to
descriptionYesDescription of the API
docsNoDocumentation for the API
nameYesName of the API
tagNoTags to associate with the API
verbYesHTTP verb for the API

Implementation Reference

  • The asynchronous handler function for the 'add-api' tool. It constructs a request body from the input parameters and uses makeXanoRequest to POST a new API to the specified API group endpoint. It formats a success response with details or returns an error message.
    async ({ apigroup_id, name, description, docs, verb, tag }) => { console.error(`[Tool] Executing add-api for API group ID: ${apigroup_id}`); try { const requestBody = { name, description, verb, ...(docs !== undefined && { docs }), ...(tag !== undefined && { tag }) }; const response = await makeXanoRequest<XanoApi>( `/workspace/${XANO_WORKSPACE}/apigroup/${apigroup_id}/api`, 'POST', requestBody ); console.error(`[Tool] Successfully added API "${name}" with ID: ${response.id} to API group ID: ${apigroup_id}`); const formattedContent = `# API Added\n\n` + `**Name**: ${response.name}\n` + `**ID**: ${response.id}\n` + `**API Group ID**: ${apigroup_id}\n` + `**Verb**: ${response.verb}\n` + `**Description**: ${response.description}\n` + `${response.docs ? `**Documentation**: ${response.docs}\n` : ''}` + `**Created**: ${new Date(response.created_at).toLocaleString()}\n` + `${response.guid ? `**GUID**: ${response.guid}\n` : ''}` + `${response.tag && response.tag.length > 0 ? `**Tags**: ${response.tag.join(', ')}\n` : ''}`; return { content: [ { type: "text", text: formattedContent } ] }; } catch (error) { console.error(`[Error] Failed to add API: ${error instanceof Error ? error.message : String(error)}`); return { content: [ { type: "text", text: `Error adding API: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
  • Zod schema defining the input parameters for the 'add-api' tool: apigroup_id (required string), name (string), description (string), docs (optional string), verb (enum of HTTP methods), tag (optional array of strings).
    apigroup_id: z.string().describe("ID of the API group to add the API to"), name: z.string().describe("Name of the API"), description: z.string().describe("Description of the API"), docs: z.string().optional().describe("Documentation for the API"), verb: z.enum(["GET", "POST", "DELETE", "PUT", "PATCH", "HEAD"]).describe("HTTP verb for the API"), tag: z.array(z.string()).optional().describe("Tags to associate with the API") },
  • src/index.ts:922-984 (registration)
    Registration of the 'add-api' tool using server.tool(), including name, description, input schema, and inline handler function.
    server.tool( "add-api", "Add a new API to an API group", { apigroup_id: z.string().describe("ID of the API group to add the API to"), name: z.string().describe("Name of the API"), description: z.string().describe("Description of the API"), docs: z.string().optional().describe("Documentation for the API"), verb: z.enum(["GET", "POST", "DELETE", "PUT", "PATCH", "HEAD"]).describe("HTTP verb for the API"), tag: z.array(z.string()).optional().describe("Tags to associate with the API") }, async ({ apigroup_id, name, description, docs, verb, tag }) => { console.error(`[Tool] Executing add-api for API group ID: ${apigroup_id}`); try { const requestBody = { name, description, verb, ...(docs !== undefined && { docs }), ...(tag !== undefined && { tag }) }; const response = await makeXanoRequest<XanoApi>( `/workspace/${XANO_WORKSPACE}/apigroup/${apigroup_id}/api`, 'POST', requestBody ); console.error(`[Tool] Successfully added API "${name}" with ID: ${response.id} to API group ID: ${apigroup_id}`); const formattedContent = `# API Added\n\n` + `**Name**: ${response.name}\n` + `**ID**: ${response.id}\n` + `**API Group ID**: ${apigroup_id}\n` + `**Verb**: ${response.verb}\n` + `**Description**: ${response.description}\n` + `${response.docs ? `**Documentation**: ${response.docs}\n` : ''}` + `**Created**: ${new Date(response.created_at).toLocaleString()}\n` + `${response.guid ? `**GUID**: ${response.guid}\n` : ''}` + `${response.tag && response.tag.length > 0 ? `**Tags**: ${response.tag.join(', ')}\n` : ''}`; return { content: [ { type: "text", text: formattedContent } ] }; } catch (error) { console.error(`[Error] Failed to add API: ${error instanceof Error ? error.message : String(error)}`); return { content: [ { type: "text", text: `Error adding API: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lowcodelocky2/xano-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server