Skip to main content
Glama
amrsa1

Swagger MCP Server

get_endpoint_details

Retrieve detailed specifications for API endpoints, including parameters and responses, from Swagger/OpenAPI documentation to understand and test API behavior.

Instructions

Get detailed information about a specific API endpoint

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe endpoint path to get details for (e.g., '/users/{id}')
methodYesThe HTTP method (GET, POST, PUT, DELETE, etc.)

Implementation Reference

  • The core handler function that extracts and formats detailed information about a specific API endpoint (path and method) from the loaded Swagger documentation, including parameters, requestBody, and responses.
    function getEndpointDetails(path, method) {
      if (!swaggerDoc) {
        throw new Error('Swagger documentation not loaded. Call fetch_swagger_info first.');
      }
      
      const paths = swaggerDoc.paths || {};
      method = method.toLowerCase();
      
      if (!paths[path] || !paths[path][method]) {
        throw new Error(`Endpoint ${method.toUpperCase()} ${path} not found in the Swagger documentation`);
      }
      
      const endpoint = paths[path][method];
      const parameters = endpoint.parameters || [];
      const responses = endpoint.responses || {};
      
      const formattedResponses = {};
      for (const statusCode in responses) {
        formattedResponses[statusCode] = {
          description: responses[statusCode].description || '',
          schema: responses[statusCode].schema || null,
          examples: responses[statusCode].examples || null
        };
      }
      
      return {
        summary: endpoint.summary || '',
        description: endpoint.description || '',
        operationId: endpoint.operationId || '',
        parameters,
        requestBody: endpoint.requestBody || null,
        responses: formattedResponses,
        consumes: endpoint.consumes || swaggerDoc.consumes || ['application/json'],
        produces: endpoint.produces || swaggerDoc.produces || ['application/json']
      };
    }
  • The input schema definition for the get_endpoint_details tool, specifying path and method as required string parameters.
    {
      name: "get_endpoint_details",
      description: "Get detailed information about a specific API endpoint",
      inputSchema: {
        type: "object",
        properties: {
          path: { 
            type: "string", 
            description: "The endpoint path to get details for (e.g., '/users/{id}')"
          },
          method: { 
            type: "string", 
            description: "The HTTP method (GET, POST, PUT, DELETE, etc.)" 
          }
        },
        required: ["path", "method"],
      },
    },
  • The registration and dispatching logic in the CallToolRequestSchema handler's switch statement, which extracts arguments, validates them, calls the handler, and returns the result.
    case "get_endpoint_details": {
      const path = request.params.arguments?.path;
      const method = request.params.arguments?.method;
      
      if (!path || !method) {
        throw new Error("Both path and method are required");
      }
    
      try {
        const details = getEndpointDetails(path, method);
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify(details)
          }],
          isError: false,
        };
      } catch (error) {
        throw new Error(`Failed to get endpoint details: ${error.message}`);
      }
    }
  • src/server.js:260-262 (registration)
    The server capabilities registration where the tools array (including get_endpoint_details) is registered with the MCP Server instance.
    capabilities: {
      tools: tools.reduce((acc, tool) => ({ ...acc, [tool.name]: tool }), {}),
    },

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

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