Skip to main content
Glama

add-api

Create a new API endpoint within an API group to define HTTP methods, descriptions, and documentation for database interactions.

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
nameYesName of the API
descriptionYesDescription of the API
docsNoDocumentation for the API
verbYesHTTP verb for the API
tagNoTags to associate with the API

Implementation Reference

  • The handler function that implements the core logic of the 'add-api' tool. It constructs a request body from the input parameters and makes a POST request to the Xano API to create a new API in the specified API group. It formats and returns a success message with details of the created 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 }; } }
  • Zod schema defining the input parameters and validation for the 'add-api' tool.
    { 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)
    The server.tool registration call that defines and registers the 'add-api' tool with the MCP server, including its name, description, input schema, and 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 }; } } );

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