Skip to main content
Glama
amrsa1

Swagger MCP Server

by amrsa1

list_endpoints

Discover available API endpoints by fetching and parsing Swagger/OpenAPI documentation to explore API capabilities.

Instructions

List all available API endpoints after fetching Swagger documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that iterates over swaggerDoc.paths, identifies HTTP methods, and constructs a list of endpoints with path, method, summary, operationId, and tags.
    function listEndpoints() {
      if (!swaggerDoc) {
        throw new Error('Swagger documentation not loaded. Call fetch_swagger_info first.');
      }
      
      const endpoints = [];
      const paths = swaggerDoc.paths || {};
      
      for (const path in paths) {
        const methods = Object.keys(paths[path]).filter(key => 
          ['get', 'post', 'put', 'delete', 'patch', 'options', 'head'].includes(key.toLowerCase())
        );
        
        methods.forEach(method => {
          const operation = paths[path][method];
          
          endpoints.push({
            path,
            method: method.toUpperCase(),
            summary: operation.summary || '',
            operationId: operation.operationId || '',
            tags: operation.tags || []
          });
        });
      }
      
      return endpoints;
    }
  • src/server.js:169-177 (registration)
    Tool registration in the tools array, including name, description, and empty input schema (no parameters required). This object is used in server capabilities.
    {
      name: "list_endpoints",
      description: "List all available API endpoints after fetching Swagger documentation",
      inputSchema: {
        type: "object",
        properties: {},
        required: [],
      },
    },
  • Input schema definition for the list_endpoints tool: an empty object (no input parameters).
    inputSchema: {
      type: "object",
      properties: {},
      required: [],
    },
  • Dispatch handler in the CallToolRequestSchema switch statement that checks for swaggerDoc, calls listEndpoints(), and returns the JSON-formatted result as tool content.
    case "list_endpoints": {
      try {
        if (!swaggerDoc) {
          throw new Error('Swagger documentation not loaded. Call fetch_swagger_info first.');
        }
        
        const endpoints = listEndpoints();
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify(endpoints)
          }],
          isError: false,
        };
      } catch (error) {
        throw new Error(`Failed to list endpoints: ${error.message}`);
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.4/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that endpoints are listed 'after fetching Swagger documentation', hinting at a dependency or sequence, but it doesn't describe what 'list' entails (e.g., format, pagination, or if it's a read-only operation). 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 that front-loads the core action ('List all available API endpoints') and adds necessary context ('after fetching Swagger documentation'). There is no wasted verbiage, and every part of the sentence contributes to understanding the tool's purpose and sequence.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity is low (0 parameters, no output schema), the description is adequate but has gaps. It covers the purpose and hints at a sequence, but without annotations or output schema, it lacks details on behavior (e.g., what 'list' returns, any side effects). For a simple listing tool, it's minimally viable but could be more complete by clarifying the output or dependencies.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% description coverage, so the schema fully documents the lack of inputs. The description doesn't need to add parameter details, and it appropriately doesn't mention any. Baseline is 4 for 0 parameters, as the description doesn't introduce confusion or redundancy.

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 action ('List all available API endpoints') and the resource ('API endpoints'), making the purpose immediately understandable. It distinguishes itself from siblings like 'fetch_swagger_info' by specifying it operates 'after fetching Swagger documentation', though it doesn't explicitly contrast with all siblings like 'get_endpoint_details'.

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

Usage Guidelines3/5

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

The description implies usage by mentioning 'after fetching Swagger documentation', suggesting a prerequisite or sequence, but it doesn't provide explicit guidance on when to use this tool versus alternatives like 'get_endpoint_details' or 'execute_api_request'. No exclusions or clear alternatives are stated, leaving usage context somewhat vague.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.