Skip to main content
Glama
zidong0822
by zidong0822

api_get_endpoint_info

Retrieve detailed information about specific API endpoints from Swagger 2.0 specifications, including parameters and methods, to enable direct REST API calls through AI assistants.

Instructions

获取示例API API特定端点的详细信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodYesHTTP方法
pathYesAPI路径

Implementation Reference

  • The main handler function for the 'api_get_endpoint_info' tool. It validates input, retrieves endpoint information using getEndpointInfo, formats the details including parameters and responses, and returns the content.
    async function getEndpointDetails(args) {
      const { method, path } = args || {};
    
      if (!method || !path) {
        throw new McpError(ErrorCode.InvalidParams, "method和path参数是必需的");
      }
    
      try {
        const info = getEndpointInfo(method, path);
    
        const paramInfo = info.parameters
          .map(
            (p) =>
              `  - ${p.name} (${p.in}): ${p.type} ${
                p.required ? "[必需]" : "[可选]"
              }\n    ${p.description || "无描述"}`
          )
          .join("\n");
    
        return {
          content: [
            {
              type: "text",
              text:
                `端点详情: ${info.method} ${info.path}\n\n` +
                `摘要: ${info.summary}\n` +
                `描述: ${info.description}\n` +
                `操作ID: ${info.operationId}\n` +
                `标签: ${info.tags.join(", ")}\n\n` +
                `参数:\n${paramInfo || "  无参数"}\n\n` +
                `响应: ${JSON.stringify(info.responses, null, 2)}`,
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `获取端点详情失败: ${error.message}`
        );
      }
    }
  • The tool definition including name, description, and inputSchema for 'api_get_endpoint_info' used in tool listing.
    {
      name: "api_get_endpoint_info",
      description: `获取${swaggerDoc.info.title} API特定端点的详细信息`,
      inputSchema: {
        type: "object",
        properties: {
          method: {
            type: "string",
            enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
            description: "HTTP方法",
          },
          path: {
            type: "string",
            description: "API路径",
          },
        },
        required: ["method", "path"],
      },
    },
  • src/index.js:832-852 (registration)
    The CallToolRequestSchema handler registration where the switch statement dispatches to getEndpointDetails for 'api_get_endpoint_info'.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        switch (name) {
          case "api_call":
            return await executeUnifiedApiCall(args);
          case "api_list_endpoints":
            return await listEndpoints(args);
          case "api_get_endpoint_info":
            return await getEndpointDetails(args);
          default:
            throw new McpError(ErrorCode.InvalidRequest, `未知工具: ${name}`);
        }
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(ErrorCode.InternalError, error.message);
      }
    });
  • Helper function that extracts detailed information about a specific endpoint from the Swagger document.
    function getEndpointInfo(method, path) {
      const swaggerDoc = global.swaggerDoc;
    
      if (
        !swaggerDoc.paths[path] ||
        !swaggerDoc.paths[path][method.toLowerCase()]
      ) {
        throw new Error(`端点 ${method.toUpperCase()} ${path} 不存在`);
      }
    
      const operation = swaggerDoc.paths[path][method.toLowerCase()];
      const params = operation.parameters || [];
    
      return {
        method: method.toUpperCase(),
        path: path,
        summary: operation.summary || "",
        description: operation.description || "",
        operationId: operation.operationId || "",
        tags: operation.tags || [],
        parameters: params.map((param) => ({
          name: param.name,
          in: param.in,
          type: param.type,
          required: param.required || false,
          description: param.description || "",
        })),
        responses: operation.responses || {},
      };
    }
  • src/index.js:824-829 (registration)
    The ListToolsRequestSchema handler that returns the list of tools including 'api_get_endpoint_info' via createUnifiedApiTools().
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      const tools = createUnifiedApiTools();
      return {
        tools: tools,
      };
    });
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. It states the tool retrieves detailed information, implying a read-only operation, but doesn't specify what '详细信息' (detailed information) includes—such as response formats, error handling, rate limits, or authentication needs. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 a single, efficient sentence: '获取示例API API特定端点的详细信息'. It's front-loaded with the core action and resource, with zero wasted words. Every part of the sentence contributes directly to clarifying the tool's purpose, making it highly concise and well-structured.

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 (a tool with 2 required parameters, no annotations, and no output schema), the description is incomplete. It doesn't explain what '详细信息' entails—such as the structure or type of information returned—leaving the agent uncertain about the tool's output. For a tool that retrieves endpoint details, more context on the expected result is needed to be fully helpful.

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, with parameters 'method' (HTTP method with enum values) and 'path' (API path) clearly documented. The description adds no additional meaning beyond what the schema provides—it doesn't explain parameter interactions, examples, or constraints. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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: '获取示例API API特定端点的详细信息' (Get detailed information about a specific endpoint of the example API). It specifies the verb ('获取' - get) and resource ('API特定端点的详细信息' - detailed information about a specific API endpoint), making the intent unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'api_list_endpoints' (which likely lists endpoints rather than getting details for one).

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. It doesn't mention sibling tools like 'api_call' (which might invoke an endpoint) or 'api_list_endpoints' (which might list endpoints), nor does it specify prerequisites, contexts, or exclusions for usage. The agent must infer usage from the tool name and description alone.

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/zidong0822/swagger-mcp'

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