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
          };
        }
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a creation operation ('Add a new API'), implying mutation, but doesn't cover critical aspects like required permissions, whether the operation is idempotent, error conditions, or what happens on success (e.g., returns an API ID). For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. Every part of the sentence ('Add a new API to an API group') directly contributes to understanding the tool's function, with zero waste or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a mutation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (e.g., an API ID or confirmation), error handling, or side effects. While the schema covers parameters well, the overall context for safe and effective use is lacking, especially for a tool that modifies system state.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with all parameters well-documented in the schema itself (e.g., 'apigroup_id' as 'ID of the API group to add the API to'). The description adds no additional parameter semantics beyond what's in the schema, so it meets the baseline of 3 where the schema does the heavy lifting. However, it doesn't compensate for any gaps since there are none.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add') and resource ('API to an API group'), making the purpose immediately understandable. It distinguishes from sibling tools like 'create-api-group' (which creates groups rather than adding APIs to them) and 'browse-apis' (which reads rather than creates). However, it doesn't specify what constitutes an 'API' in this context beyond the parameters listed in the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing API group), exclusions, or comparisons to siblings like 'create-api-group' for when no group exists. The agent must infer usage solely from the tool name and parameters.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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