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
    }
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It only states the action of getting API info, without details on permissions required, rate limits, error handling, or response format. This lack of information is a significant gap for a tool with no structured safety hints.

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 a single, straightforward sentence that directly states the tool's purpose without unnecessary words. It is appropriately sized for a simple tool, though it could be slightly more informative to improve clarity without sacrificing brevity.

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 lack of annotations and output schema, the description is insufficiently complete. It does not explain what 'info' includes in the response, how errors are handled, or any behavioral nuances, leaving critical gaps for the agent to understand the tool's full context and usage.

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 input schema has 100% description coverage, clearly documenting both required parameters (apiId and projectId) with their purposes. The description does not add any meaning beyond this, such as explaining parameter relationships or constraints, so it meets the baseline score of 3 where the schema handles the heavy lifting.

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

Purpose3/5

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

The description states the tool 'Get the info of Apifox API,' which clearly indicates it retrieves information about an API. However, it lacks specificity about what 'info' entails (e.g., metadata, details, status) and does not distinguish it from the sibling tool 'get_apifox_project_id_and_api_id_from_url,' which might serve a related but different purpose. This vagueness prevents a higher score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, such as the sibling tool. It does not mention any prerequisites, contexts, or exclusions for usage, leaving the agent without direction on appropriate invocation scenarios.

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

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