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 }],
          };
        }
      }
    );

Tool Definition Quality

Score is being calculated. Check back soon.

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