Skip to main content
Glama
zidong0822
by zidong0822

api_list_endpoints

List all available API endpoints from Swagger specifications to discover and understand available operations. Filter results by HTTP method or keywords to find specific endpoints quickly.

Instructions

列出示例API API的所有可用端点

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNo过滤端点的关键词(可选)
methodNo按HTTP方法过滤(可选)

Implementation Reference

  • The main handler function for the 'api_list_endpoints' tool. It invokes the helper to list endpoints with optional filters and formats the response as MCP content.
    async function listEndpoints(args) {
      const { filter = "", method = "" } = args || {};
    
      try {
        const endpoints = listApiEndpoints(filter, method);
    
        return {
          content: [
            {
              type: "text",
              text: `找到 ${endpoints.length} 个API端点:\n\n${endpoints
                .map(
                  (ep) =>
                    `${ep.method} ${ep.path}\n  ${
                      ep.summary || ep.description || "无描述"
                    }\n  标签: ${ep.tags.join(", ") || "无"}`
                )
                .join("\n\n")}`,
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `获取端点列表失败: ${error.message}`
        );
      }
    }
    
    /**
     * 获取端点详情
  • The input schema and metadata definition for the 'api_list_endpoints' tool, returned by createUnifiedApiTools().
    {
      name: "api_list_endpoints",
      description: `列出${swaggerDoc.info.title} API的所有可用端点`,
      inputSchema: {
        type: "object",
        properties: {
          filter: {
            type: "string",
            description: "过滤端点的关键词(可选)",
          },
          method: {
            type: "string",
            enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
            description: "按HTTP方法过滤(可选)",
          },
        },
      },
    },
  • src/index.js:839-840 (registration)
    Registration of the tool handler in the switch statement within the CallToolRequestSchema handler.
    case "api_list_endpoints":
      return await listEndpoints(args);
  • Helper function that parses the Swagger document to extract API endpoints and applies filtering.
    function listApiEndpoints(filter = "", methodFilter = "") {
      const swaggerDoc = global.swaggerDoc;
      const endpoints = [];
    
      for (const [path, methods] of Object.entries(swaggerDoc.paths)) {
        for (const [method, operation] of Object.entries(methods)) {
          if (typeof operation !== "object" || !operation) continue;
    
          const endpoint = {
            method: method.toUpperCase(),
            path: path,
            summary: operation.summary || "",
            description: operation.description || "",
            operationId: operation.operationId || "",
            tags: operation.tags || [],
          };
    
          // 应用过滤器
          if (
            filter &&
            !JSON.stringify(endpoint).toLowerCase().includes(filter.toLowerCase())
          ) {
            continue;
          }
    
          if (methodFilter && endpoint.method !== methodFilter.toUpperCase()) {
            continue;
          }
    
          endpoints.push(endpoint);
        }
      }
    
      return endpoints;
    }
  • src/index.js:824-829 (registration)
    Registers the ListToolsRequestSchema handler, which provides the list of tools including 'api_list_endpoints' 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 lists endpoints but doesn't describe behavioral traits like whether it's a read-only operation, if it requires authentication, rate limits, pagination, or the format of the returned data. For a tool with no annotations, this leaves significant gaps in understanding how it behaves.

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 in Chinese: '列出示例API API的所有可用端点'. It is front-loaded with the core action and resource, with no unnecessary words or redundancy. Every part of the sentence contributes directly to 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 lack of annotations and output schema, the description is incomplete for effective tool use. It doesn't explain what the output looks like (e.g., list format, data structure), behavioral aspects like safety or performance, or how it relates to sibling tools. For a tool with no structured metadata, the description should provide more context to compensate, but it falls short.

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 clear documentation for both parameters ('filter' and 'method'), including an enum for 'method'. The description adds no additional meaning beyond what the schema provides, such as examples or usage tips. With high schema coverage, the baseline score of 3 is appropriate, as the schema adequately handles parameter semantics.

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的所有可用端点' (List all available endpoints of the example API API). It specifies the verb '列出' (list) and resource '端点' (endpoints), making the action clear. However, it doesn't explicitly differentiate from sibling tools like 'api_get_endpoint_info', which might provide detailed information about a specific endpoint.

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 such as 'api_call' or 'api_get_endpoint_info', nor does it specify any prerequisites, exclusions, or contextual cues for usage. The agent must infer usage based on 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