Skip to main content
Glama

create_service

Define and configure services on the APISIX-MCP server by specifying ID, name, labels, upstream settings, and plugins for efficient API management.

Instructions

Create a service

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNoservice id
serviceYesservice configuration object

Implementation Reference

  • The implementation of the create_service tool handler. It checks if an ID is provided; if not, it creates a new service via POST to /services, otherwise updates via PUT to /services/{id}. Uses makeAdminAPIRequest helper.
    server.tool("create_service", "Create a service", CreateServiceSchema.shape, async (args) => {
      const serviceId = args.id;
      if (!serviceId) {
        return await makeAdminAPIRequest(`/services`, "POST", args.service);
      } else {
        return await makeAdminAPIRequest(`/services/${serviceId}`, "PUT", args.service);
      }
    });
  • Supporting utility function that executes HTTP requests to the APISIX Admin API, formats success/error responses as MCP CallToolResult.
    export async function makeAdminAPIRequest(
      path: string,
      method: string = "GET",
      data?: object
    ): Promise<CallToolResult> {
      const baseUrl = `${APISIX_SERVER_HOST}:${APISIX_ADMIN_API_PORT}${APISIX_ADMIN_API_PREFIX}`;
      const url = `${baseUrl}${path}`;
    
      try {
        const response = await axios({
          method,
          url,
          data,
          headers: {
            "X-API-KEY": APISIX_ADMIN_KEY,
            "Content-Type": "application/json",
          },
        });
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(response.data, null, 2),
            },
          ],
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          console.error(`Request failed: ${method} ${url}`);
          console.error(
            `Status: ${error.response?.status}, Error: ${error.message}`
          );
    
          if (error.response?.data) {
            try {
              const stringifiedData = JSON.stringify(error.response.data);
              console.error(`Response data: ${stringifiedData}`);
            } catch {
              console.error(`Response data: [Cannot parse as JSON]`);
            }
          }
    
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  `Status: ${error.response?.status}\nMessage: ${error.message}
    Data:\n${JSON.stringify(error.response?.data || {}, null, 2)}`,
                  null,
                  2
                ),
              },
            ],
          };
        } else {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: JSON.stringify(error, null, 2),
              },
            ],
          };
        }
      }
    }
Behavior1/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 but fails completely. It doesn't indicate whether this is a mutating operation, what permissions are required, whether it's idempotent, what happens on conflicts, or what the response contains. For a complex creation tool, this is a critical gap.

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

Conciseness2/5

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

While technically concise with just two words, this is under-specification rather than effective conciseness. The description fails to convey essential information about the tool's purpose and behavior, making it inefficient for an AI agent trying to understand when and how to use this tool.

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

Completeness1/5

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

Given the complexity of the input schema (with extensive nested objects for service configuration), the absence of annotations, and no output schema, the description is completely inadequate. It should explain what a 'service' means in this context, what the creation entails, and what happens after creation, but provides none of this.

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%, so the schema already documents both parameters thoroughly. The description adds zero information about parameters beyond what's in the schema. According to the scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description.

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

Purpose2/5

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

The description 'Create a service' is a tautology that merely restates the tool name without adding specificity. It doesn't explain what type of service is being created, what system it operates within, or how it differs from sibling tools like 'create_route' or 'create_upstream'.

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

Usage Guidelines1/5

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

The description provides absolutely no guidance about when to use this tool versus alternatives. There's no mention of prerequisites, when this operation is appropriate, or how it relates to sibling tools like 'update_service' or 'create_upstream'.

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

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/api7/apisix-mcp'

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