Skip to main content
Glama

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

Retrieve specific API operation details using path and HTTP method to access OpenAPI specifications within development tools.

Instructions

Load an operation by path and method

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
specIdYes
pathYes
methodYes

Implementation Reference

  • Registers the MCP tool 'load-api-operation-by-path-and-method' with description, input schema, and inline handler.
    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; } } );
  • Input schema definition using Zod for specId, path, and method parameters.
    { specId: z.string(), path: z.string(), method: z.string(), },
  • Handler function that invokes specExplorer.findOperationByPathAndMethod, handles errors, and returns the operation as YAML.
    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; } }
  • Implements findOperationByPathAndMethod to retrieve OpenAPI operation object from spec.paths[path][method].
    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