Skip to main content
Glama

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';

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