Skip to main content
Glama

get_api_endpoint_info

Retrieve API endpoint definitions from Apifox projects using project and endpoint IDs. Returns OpenAPI 3.1-compliant specifications for methods, parameters, headers, and response schemas.

Instructions

获取apifox的接口定义信息,数据符合OpenAPI 3.1规范。遇到例如:https://app.apifox.com/link/project/{projectId}/apis/api-{endpointId}的链接,请解析出projectId和endpointId,并调用本工具获取接口定义信息。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesApifox的项目ID
endpointIdYes接口Endpoint的ID

Implementation Reference

  • src/index.ts:22-67 (registration)
    Registration of the tool 'get_api_endpoint_info' via server.tool() with name, description, schema, and handler.
    server.tool(
      "get_api_endpoint_info",
      "获取apifox的接口定义信息,数据符合OpenAPI 3.1规范。遇到例如:https://app.apifox.com/link/project/{projectId}/apis/api-{endpointId}的链接,请解析出projectId和endpointId,并调用本工具获取接口定义信息。",
      {
        projectId: z.number().describe("Apifox的项目ID"),
        endpointId: z.number().describe("接口Endpoint的ID"),
      },
      async ({ projectId, endpointId }) => {
        try {
          const response = await axios.post(
            `${BASE_URL}/v1/projects/${projectId}/export-openapi`,
            JSON.stringify({
              scope: {
                type: "SELECTED_ENDPOINTS",
                selectedEndpointIds: [endpointId],
              },
            }),
            {
              headers: {
                "Content-Type": "application/json",
                "X-Apifox-Api-Version": "2024-03-28",
                Authorization: `Bearer ${APIFOX_AUTH}`,
              },
            }
          );
          return {
            content: [
              { type: "text", text: JSON.stringify(response.data, null, 2) },
            ],
          };
        } catch (error) {
          let errorMessage = "";
          if (axios.isAxiosError(error)) {
            errorMessage = JSON.stringify(error.response?.data, null, 2);
          } else if (error instanceof Error) {
            errorMessage = error.message;
          } else {
            errorMessage = JSON.stringify(error, null, 2);
          }
          return {
            isError: true,
            content: [{ type: "text", text: errorMessage }],
          };
        }
      }
    );
  • Handler function that makes an HTTP POST request to Apifox's export-openapi endpoint to retrieve endpoint info in OpenAPI 3.1 format, then returns the response as text content.
      async ({ projectId, endpointId }) => {
        try {
          const response = await axios.post(
            `${BASE_URL}/v1/projects/${projectId}/export-openapi`,
            JSON.stringify({
              scope: {
                type: "SELECTED_ENDPOINTS",
                selectedEndpointIds: [endpointId],
              },
            }),
            {
              headers: {
                "Content-Type": "application/json",
                "X-Apifox-Api-Version": "2024-03-28",
                Authorization: `Bearer ${APIFOX_AUTH}`,
              },
            }
          );
          return {
            content: [
              { type: "text", text: JSON.stringify(response.data, null, 2) },
            ],
          };
        } catch (error) {
          let errorMessage = "";
          if (axios.isAxiosError(error)) {
            errorMessage = JSON.stringify(error.response?.data, null, 2);
          } else if (error instanceof Error) {
            errorMessage = error.message;
          } else {
            errorMessage = JSON.stringify(error, null, 2);
          }
          return {
            isError: true,
            content: [{ type: "text", text: errorMessage }],
          };
        }
      }
    );
  • Input schema using Zod: requires projectId (number) and endpointId (number).
    {
      projectId: z.number().describe("Apifox的项目ID"),
      endpointId: z.number().describe("接口Endpoint的ID"),
    },
Behavior3/5

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

With no annotations, the description carries full burden. It discloses the output conforms to OpenAPI 3.1 specification, implying a read operation. However, it does not address potential errors, auth requirements, or whether the tool is read-only, which is a minor gap.

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 concise at two sentences. The first sentence states the main purpose, and the second provides a practical example. No redundant information.

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

Completeness4/5

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

Given the tool's simplicity (2 parameters, no output schema), the description covers the core functionality and output format (OpenAPI 3.1). It does not mention error conditions or response handling, but the context from schema coverage compensates.

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

Parameters4/5

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

Schema coverage is 100% with descriptions already provided. The description adds significant value by explaining how to derive the parameters from a URL, which is not inferable from the schema alone.

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

Purpose5/5

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

The description clearly states the tool retrieves API endpoint definitions from apifox conforming to OpenAPI 3.1. It specifies the exact data format and provides a concrete usage scenario with URL parsing, making the purpose unambiguous.

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

Usage Guidelines4/5

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

The description explicitly instructs when to use the tool: when encountering a specific URL pattern. It provides step-by-step guidance to extract parameters, but does not explicitly mention when not to use it or list alternatives, though no siblings exist.

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/Juzisuan965/apifox-mcp'

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