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
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"specId": "<specId>",
"path": "<path>",
"method": "<method>"
},
"name": "load-api-operation-by-path-and-method"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| specId | Yes | ||
| path | Yes | ||
| method | Yes |
Implementation Reference
- src/McpService.ts:174-216 (registration)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; } } ); - src/McpService.ts:177-181 (schema)Input schema definition using Zod for specId, path, and method parameters.
{ specId: z.string(), path: z.string(), method: z.string(), }, - src/McpService.ts:182-215 (handler)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; } } - src/core/SpecService.ts:465-489 (helper)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}`, }; }