Skip to main content
Glama
Vizioz

Swagger MCP

by Vizioz

list_endpoints

Retrieve and display all available API endpoints from Swagger documentation to understand service capabilities and structure.

Instructions

List all available API endpoints after fetching Swagger documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'listEndpoints' that invokes the service function and returns formatted JSON response.
    export async function handleListEndpoints(input: any) {
      logger.info('Calling swaggerService.listEndpoints()');
      logger.info(`Input parameters: ${JSON.stringify(input)}`);
    
      try {
        const endpoints = await swaggerService.listEndpoints(input);
        logger.info(`Endpoints response: ${JSON.stringify(endpoints).substring(0, 200)}...`);
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(endpoints, null, 2)
          }]
        };
      } catch (error: any) {
        logger.error(`Error in listEndpoints handler: ${error.message}`);
        return {
          content: [{
            type: "text",
            text: `Error retrieving endpoints: ${error.message}`
          }]
        };
      }
  • Tool schema definition for 'listEndpoints', including name, description, and input schema.
    export const listEndpoints = {
      name: "listEndpoints",
      description: "Lists all endpoints from the Swagger definition including their HTTP methods and descriptions. Priority: CLI --swagger-url > swaggerFilePath parameter.",
      inputSchema: {
        type: "object",
        properties: {
          swaggerFilePath: {
            type: "string",
            description: "Optional path to the Swagger file. Used only if --swagger-url is not provided. You can find this path in the .swagger-mcp file in the solution root with the format SWAGGER_FILEPATH=path/to/file.json."
          }
        },
        required: []
      }
    };
  • Core helper function that loads Swagger definition and extracts list of endpoints with details.
    async function listEndpoints(params?: { swaggerFilePath?: string }): Promise<Endpoint[]> {
      try {
        // Load Swagger definition (checks CLI arg, then swaggerFilePath, then env var)
        const swaggerJson = await loadSwaggerDefinition(params?.swaggerFilePath);
    
        // Check if it's OpenAPI or Swagger
        const isOpenApi = !!swaggerJson.openapi;
        const paths = swaggerJson.paths || {};
    
        // Extract endpoints
        const endpoints: Endpoint[] = [];
    
        for (const path in paths) {
          const pathItem = paths[path];
    
          for (const method in pathItem) {
            if (['get', 'post', 'put', 'delete', 'patch', 'options', 'head'].includes(method)) {
              const operation = pathItem[method];
    
              endpoints.push({
                path,
                method: method.toUpperCase(),
                summary: operation.summary,
                description: operation.description,
                operationId: operation.operationId,
                tags: operation.tags
              });
            }
          }
        }
    
        return endpoints;
      } catch (error: any) {
        logger.error(`Error listing endpoints: ${error.message}`);
        throw error;
      }
    }
    
    export default listEndpoints; 
  • Type definition for Endpoint objects returned by the tool.
    export interface Endpoint {
      path: string;
      method: string;
      summary?: string;
      description?: string;
      operationId?: string;
      tags?: string[];
    }
  • Registration of the listEndpoints tool in the toolDefinitions array and export of its handler.
    import { getSwaggerDefinition } from './getSwaggerDefinition.js';
    import { listEndpoints } from './listEndpoints.js';
    import { listEndpointModels } from './listEndpointModels.js';
    import { generateModelCode } from './generateModelCode.js';
    import { generateEndpointToolCode } from './generateEndpointToolCode.js';
    import { version } from './version.js';
    
    // Tool definitions array
    export const toolDefinitions = [
      getSwaggerDefinition,
      listEndpoints,
      listEndpointModels,
      generateModelCode,
      generateEndpointToolCode,
      version
    ];
    
    // Export all tool handlers
    export { handleGetSwaggerDefinition } from './getSwaggerDefinition.js';
    export { handleListEndpoints } from './listEndpoints.js';
    export { handleListEndpointModels } from './listEndpointModels.js';
    export { handleGenerateModelCode } from './generateModelCode.js';
    export { handleGenerateEndpointToolCode } from './generateEndpointToolCode.js';
    export { handleVersion } from './version.js';
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.

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/Vizioz/Swagger-MCP'

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