Skip to main content
Glama

get_apifox_api_info

Retrieve detailed information about a specific API from an Apifox project by providing the project ID and API ID. Integrates API documentation for AI assistants to extract and understand data.

Instructions

Get the info of Apifox API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiIdYesThe API ID of Apifox
projectIdYesThe project ID of Apifox

Implementation Reference

  • Handler function for the get_apifox_api_info tool. Retrieves access token from env or args, calls fetchApiInfoApi, and handles errors.
    async ({ projectId, apiId }) => { try { // Get token from command line arguments or environment variable let token = process.env.APIFOX_ACCESS_TOKEN // Check if token is provided in command line arguments // Format: --token=your_token or --apifox-token=your_token const args = process.argv.slice(2) for (const arg of args) { const tokenArg = arg.match(/^--(?:apifox-)?token=(.+)$/) if (tokenArg) { token = tokenArg[1] break } } if (!token) { throw new Error("No token provided") } const result = await fetchApiInfoApi(projectId, apiId, token) return { content: [ { type: "text", text: result, }, ], } } catch (error: any) { return { content: [ { type: "text", text: `Error fetching API info: ${error.message}`, }, ], isError: true, } } },
  • Zod input schema defining projectId and apiId parameters.
    { projectId: z.string().describe("The project ID of Apifox"), apiId: z.string().describe("The API ID of Apifox"), },
  • src/index.ts:35-83 (registration)
    Registration of the get_apifox_api_info tool with McpServer.tool() including name, description, schema, and handler.
    server.tool( "get_apifox_api_info", "Get the info of Apifox API.", { projectId: z.string().describe("The project ID of Apifox"), apiId: z.string().describe("The API ID of Apifox"), }, async ({ projectId, apiId }) => { try { // Get token from command line arguments or environment variable let token = process.env.APIFOX_ACCESS_TOKEN // Check if token is provided in command line arguments // Format: --token=your_token or --apifox-token=your_token const args = process.argv.slice(2) for (const arg of args) { const tokenArg = arg.match(/^--(?:apifox-)?token=(.+)$/) if (tokenArg) { token = tokenArg[1] break } } if (!token) { throw new Error("No token provided") } const result = await fetchApiInfoApi(projectId, apiId, token) return { content: [ { type: "text", text: result, }, ], } } catch (error: any) { return { content: [ { type: "text", text: `Error fetching API info: ${error.message}`, }, ], isError: true, } } }, )
  • Helper function that performs the actual API request to Apifox to export OpenAPI JSON for the specified project and API.
    export async function fetchApiInfoApi(projectId: string, apiId: string, accessToken: string) { const response = await request(`https://api.apifox.com/v1/projects/${projectId}/export-openapi`, { method: 'POST', headers: { 'X-Apifox-Api-Version': '2024-03-28', 'Authorization': `Bearer ${accessToken}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ scope: { type: 'SELECTED_ENDPOINTS', selectedEndpointIds: [apiId] }, options: { includeApifoxExtensionProperties: false, addFoldersToTags: false }, oasVersion: '3.1', exportFormat: 'JSON' }) }); const result = await response.body.text(); return result }

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

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