Skip to main content
Glama

get_api_endpoint_info

Retrieve API endpoint definitions from Apifox projects to access request methods, parameters, headers, and response schemas for development and code generation.

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

  • The handler function for the 'get_api_endpoint_info' tool. It sends a POST request to Apifox API to export OpenAPI 3.1 spec for the specified project and endpoint, returning the JSON response or an error message.
    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 for the tool using Zod: projectId (number, Apifox project ID) and endpointId (number, endpoint ID).
    {
      projectId: z.number().describe("Apifox的项目ID"),
      endpointId: z.number().describe("接口Endpoint的ID"),
    },
  • src/index.ts:22-67 (registration)
    Registration of the 'get_api_endpoint_info' tool on the MCP server, specifying name, description, input schema, and handler function.
    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 }],
          };
        }
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions the data format (OpenAPI 3.1) and URL parsing context, it doesn't describe important behavioral traits such as authentication requirements, rate limits, error handling, or what the response looks like (especially critical with no output schema). For a tool that fetches API definitions with zero annotation coverage, this is a significant gap.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, with the core purpose stated first ('获取apifox的接口定义信息'), followed by data format details and usage instructions. Both sentences earn their place by providing essential information without redundancy. A minor deduction to 4 is due to some potential verbosity in the example URL, but overall it's efficient.

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 fetching API definitions, the lack of annotations, and no output schema, the description is incomplete. It covers the purpose and usage context well but fails to address critical behavioral aspects like authentication, response format, error cases, or rate limits. For a tool with no structured safety or output information, this leaves significant gaps for an AI agent.

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?

Schema description coverage is 100%, with both parameters (projectId and endpointId) well-documented in the schema. The description adds value by explaining how these parameters should be extracted from Apifox URLs ('解析出projectId和endpointId'), providing practical context beyond the schema's basic definitions. This justifies a baseline score of 3, as the schema does the heavy lifting but the description adds meaningful semantic context.

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 tool's purpose: '获取apifox的接口定义信息' (get Apifox API endpoint definition information) and specifies the data format ('符合OpenAPI 3.1规范'). It provides a specific verb (获取/get) and resource (接口定义信息/API endpoint definition information), though without sibling tools to distinguish from, it cannot achieve a perfect 5.

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 provides clear context for when to use this tool: when encountering specific Apifox URLs that need parsing to extract projectId and endpointId. It includes an example URL pattern and instructs to '调用本工具获取接口定义信息' (call this tool to get the interface definition information). However, it doesn't explicitly state when NOT to use it or mention alternatives, preventing a score of 5.

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