Skip to main content
Glama

load-api-operation-by-path-and-method

Retrieve specific API operation details by specifying the path and method within OpenAPI specifications, enabling precise API interaction and integration in development workflows.

Instructions

Load an operation by path and method

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodYes
pathYes
specIdYes

Implementation Reference

  • The main handler function for the MCP tool 'load-api-operation-by-path-and-method'. It takes specId, path, method; calls specExplorer.findOperationByPathAndMethod; returns YAML stringified operation or throws error.
    async (args, extra) => { try { this.logger.debug('Loading API operation by path and method', { specId: args.specId, path: args.path, method: args.method }); const operation = await this.specExplorer.findOperationByPathAndMethod( args.specId, args.path, args.method ); if (!operation) { this.logger.warn('Operation not found', { specId: args.specId, path: args.path, method: args.method }); } return { content: [ { type: "text", text: stringify(operation, { indent: 2 }) }, ], }; } catch (error) { this.logger.error('Failed to load API operation by path and method', { error, specId: args.specId, path: args.path, method: args.method }); throw error; } }
  • Zod input schema validation for the tool parameters: specId (string), path (string), method (string).
    { specId: z.string(), path: z.string(), method: z.string(), },
  • Registration of the tool in McpServer using server.tool() with name, description, schema, and handler function.
    server.tool( "load-api-operation-by-path-and-method", "Load an operation by path and method", { specId: z.string(), path: z.string(), method: z.string(), }, async (args, extra) => { try { this.logger.debug('Loading API operation by path and method', { specId: args.specId, path: args.path, method: args.method }); const operation = await this.specExplorer.findOperationByPathAndMethod( args.specId, args.path, args.method ); if (!operation) { this.logger.warn('Operation not found', { specId: args.specId, path: args.path, method: args.method }); } return { content: [ { type: "text", text: stringify(operation, { indent: 2 }) }, ], }; } catch (error) { this.logger.error('Failed to load API operation by path and method', { error, specId: args.specId, path: args.path, method: args.method }); throw error; } } );
  • Core helper method in FileSystemSpecService (implements ISpecExplorer) that implements the logic to find and return the LoadOperationResult for given specId, path, and method from the loaded OpenAPI document.
    async findOperationByPathAndMethod( specId: string, path: string, method: string ): Promise<LoadOperationResult | null> { const spec = this.specs[specId]; if (!spec) { return null; } const pathItem = spec.paths[path]; if (!pathItem) { return null; } const operation = pathItem[method]; if (!operation) { return null; } return { path, method, operation, specId, uri: `apis://${specId}/operations/${operation.operationId}`, }; }

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/ReAPI-com/mcp-openapi'

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