Skip to main content
Glama
amrsa1

Swagger MCP Server

by amrsa1

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 }), {}),
    },

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.1/5.0
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 retrieves information, implying a read-only operation, but doesn't specify aspects like authentication requirements, rate limits, error handling, or the format of the returned details. This is a significant gap for a tool with no annotation coverage.

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 purpose without unnecessary words. Every part earns its place by directly stating the tool's function, 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.

Completeness3/5

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

Given the tool's moderate complexity (2 required parameters, no output schema, no annotations), the description is minimally adequate. It clarifies the purpose but lacks behavioral details and usage guidelines. Without an output schema, it doesn't explain return values, which could be a gap, but the description focuses on the input aspect, making it borderline complete for a basic read operation.

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 schema description coverage is 100%, with clear descriptions for both parameters ('path' and 'method'), so the schema does the heavy lifting. The description adds no additional parameter semantics beyond implying that these inputs identify a 'specific API endpoint', which is already inferred from the schema. Baseline 3 is appropriate as the schema provides adequate documentation.

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 verb ('Get') and resource ('detailed information about a specific API endpoint'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'fetch_swagger_info' or 'list_endpoints', which likely provide similar API information but with different scopes or formats.

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?

No guidance is provided on when to use this tool versus alternatives. With siblings like 'fetch_swagger_info' (which might retrieve broader API documentation) and 'list_endpoints' (which might list endpoints without details), the description lacks context for selection, leaving the agent to infer usage based on tool names alone.

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