Skip to main content
Glama

load-api-operation-by-operationId

Retrieve specific API operations from OpenAPI specifications using their unique operationId, enabling AI tools to understand and work with API endpoints in development environments.

Instructions

Load an operation by operationId

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
specIdYes
operationIdYes

Implementation Reference

  • Registration of the MCP tool 'load-api-operation-by-operationId', including inline input schema (specId: string, operationId: string) and handler function that delegates to specExplorer.findOperationById, logs, handles errors, and returns the operation as YAML string.
    server.tool(
      "load-api-operation-by-operationId",
      "Load an operation by operationId",
      {
        specId: z.string(),
        operationId: z.string(),
      },
      async (args, extra) => {
        try {
          this.logger.debug('Loading API operation by ID', { specId: args.specId, operationId: args.operationId });
          const operation = await this.specExplorer.findOperationById(
            args.specId,
            args.operationId
          );
          if (!operation) {
            this.logger.warn('Operation not found', { specId: args.specId, operationId: args.operationId });
          }
          return {
            content: [
              { type: "text", text: stringify(operation, { indent: 2 }) },
            ],
          };
        } catch (error) {
          this.logger.error('Failed to load API operation by ID', { 
            error, 
            specId: args.specId, 
            operationId: args.operationId 
          });
          throw error;
        }
      }
    );
  • Zod input schema for the tool: specId (string), operationId (string).
    {
      specId: z.string(),
      operationId: z.string(),
    },
  • MCP tool handler: validates inputs implicitly via schema, calls ISpecExplorer.findOperationById, stringifies result to YAML if found, handles not found and errors.
    async (args, extra) => {
      try {
        this.logger.debug('Loading API operation by ID', { specId: args.specId, operationId: args.operationId });
        const operation = await this.specExplorer.findOperationById(
          args.specId,
          args.operationId
        );
        if (!operation) {
          this.logger.warn('Operation not found', { specId: args.specId, operationId: args.operationId });
        }
        return {
          content: [
            { type: "text", text: stringify(operation, { indent: 2 }) },
          ],
        };
      } catch (error) {
        this.logger.error('Failed to load API operation by ID', { 
          error, 
          specId: args.specId, 
          operationId: args.operationId 
        });
        throw error;
      }
    }
  • Core implementation: Iterates over paths and methods in the spec's paths object to find the operation matching the given operationId, returns LoadOperationResult with path, method, operation object, specId, and constructed URI, or null if not found.
    async findOperationById(
      specId: string,
      operationId: string
    ): Promise<LoadOperationResult | null> {
      const spec = this.specs[specId];
      if (!spec) {
        return null;
      }
    
      for (const path in spec.paths) {
        const pathItem = spec.paths[path];
        for (const method in pathItem) {
          if (pathItem[method]["operationId"] === operationId) {
            return {
              path,
              method,
              operation: pathItem[method],
              specId,
              uri: `apis://${specId}/operations/${operationId}`,
            };
          }
        }
      }
      return null;
    }
  • TypeScript interface defining the structure of the loaded operation result (output type), used by the helper method.
    export interface LoadOperationResult {
      /** Path of the operation */
      path: string;
      /** HTTP method */
      method: string;
      /** The operation object */
      operation: OpenAPIV3.OperationObject;
      /** ID of the specification containing the operation */
      specId: string;
      /** URI identifying the operation */
      uri: string;
Behavior1/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. The description only states what the tool does at a high level ('load an operation') without explaining what 'loading' entails operationally—whether it's a read-only fetch, requires authentication, has side effects, returns structured data, or handles errors. For a tool with no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence with no wasted words. It's front-loaded with the core action and resource. However, this brevity comes at the cost of under-specification, as it omits necessary details for effective tool use. While structurally efficient, it prioritizes conciseness over completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

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

Given the tool's complexity (2 required parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the tool's behavior, parameter meanings, return values, or how it fits with sibling tools. For a tool that likely interacts with an API catalog or specification system, this minimal description leaves critical gaps in understanding its role and usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, meaning neither parameter (specId, operationId) is documented in the schema. The description adds no meaning beyond the schema—it doesn't explain what 'specId' or 'operationId' represent, their expected formats, or examples. With two required parameters and zero coverage, the description fails to compensate, leaving parameters semantically opaque.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Load an operation by operationId' is a tautology that essentially restates the tool name with minimal elaboration. It specifies the verb 'load' and resource 'operation' but lacks specificity about what an 'operation' represents in this context or what 'loading' entails. Compared to siblings like 'search-api-operations' or 'load-api-schema-by-schemaName', it doesn't clearly differentiate its unique scope or purpose beyond the basic name.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, context for when this is appropriate, or contrast with sibling tools like 'load-api-operation-by-path-and-method' or 'search-api-operations'. Without any usage context, an agent must infer when to select this tool based solely on the name and schema.

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

Install Server

Other Tools

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