Skip to main content
Glama

updateSpecFile

Idempotent

Update an API specification file by providing its ID and file path. Optionally change the file name, type, or content.

Instructions

Updates an API specification's file.

Note:

  • This endpoint does not accept an empty request body. You must pass one of the accepted values.

  • This endpoint does not accept multiple request body properties in a single call. For example, you cannot pass both the `content` and `type` property at the same time.

  • Multi-file specifications can only have one root file.

  • When updating a file type to `ROOT`, the previous root file is updated to the `DEFAULT` file type.

  • Files cannot exceed a maximum of 10 MB in size.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
specIdYesThe spec's ID.
filePathYesThe path to the file.
nameNoThe file's name.
typeNoThe type of file: - `ROOT` — The file containing the full OpenAPI structure. This serves as the entry point for the API spec and references other (`DEFAULT`) spec files. Multi-file specs can only have one root file. - `DEFAULT` — A file referenced by the `ROOT` file.
contentNoThe specification's stringified contents.

Implementation Reference

  • Main handler implementation for updateSpecFile tool. Makes a PATCH request to /specs/{specId}/files/{filePath} with optional name, type, and content parameters. Validates type as 'DEFAULT' or 'ROOT' using zod schema.
    import { z } from 'zod';
    import { PostmanAPIClient, ContentType } from '../clients/postman.js';
    import { IsomorphicHeaders, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
    import { ServerContext, asMcpError, McpError } from './utils/toolHelpers.js';
    
    export const method = 'updateSpecFile';
    export const description =
      "Updates an API specification's file.\n\n**Note:**\n\n- This endpoint does not accept an empty request body. You must pass one of the accepted values.\n- This endpoint does not accept multiple request body properties in a single call. For example, you cannot pass both the \\`content\\` and \\`type\\` property at the same time.\n- Multi-file specifications can only have one root file.\n- When updating a file type to \\`ROOT\\`, the previous root file is updated to the \\`DEFAULT\\` file type.\n- Files cannot exceed a maximum of 10 MB in size.\n";
    export const parameters = z.object({
      specId: z.string().describe("The spec's ID."),
      filePath: z.string().describe('The path to the file.'),
      name: z.string().describe("The file's name.").optional(),
      type: z
        .preprocess((v) => (typeof v === 'string' ? v.toUpperCase() : v), z.enum(['DEFAULT', 'ROOT']))
        .describe(
          'The type of file:\n- `ROOT` — The file containing the full OpenAPI structure. This serves as the entry point for the API spec and references other (`DEFAULT`) spec files. Multi-file specs can only have one root file.\n- `DEFAULT` — A file referenced by the `ROOT` file.\n'
        )
        .optional(),
      content: z.string().describe("The specification's stringified contents.").optional(),
    });
    export const annotations = {
      title: "Updates an API specification's file.",
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: true,
    };
    
    export async function handler(
      args: z.infer<typeof parameters>,
      extra: { client: PostmanAPIClient; headers?: IsomorphicHeaders; serverContext?: ServerContext }
    ): Promise<CallToolResult> {
      try {
        const endpoint = `/specs/${args.specId}/files/${args.filePath}`;
        const query = new URLSearchParams();
        const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
        const bodyPayload: any = {};
        if (args.name !== undefined) bodyPayload.name = args.name;
        if (args.type !== undefined) bodyPayload.type = args.type;
        if (args.content !== undefined) bodyPayload.content = args.content;
        const options: any = {
          body: JSON.stringify(bodyPayload),
          contentType: ContentType.Json,
          headers: extra.headers,
        };
        const result = await extra.client.patch(url, options);
        return {
          content: [
            {
              type: 'text',
              text: `${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}`,
            },
          ],
        };
      } catch (e: unknown) {
        if (e instanceof McpError) {
          throw e;
        }
        throw asMcpError(e);
      }
    }
  • Zod schema defining the input parameters: specId (string), filePath (string), name (optional string), type (optional enum DEFAULT|ROOT with case preprocessing), content (optional string).
    export const parameters = z.object({
      specId: z.string().describe("The spec's ID."),
      filePath: z.string().describe('The path to the file.'),
      name: z.string().describe("The file's name.").optional(),
      type: z
        .preprocess((v) => (typeof v === 'string' ? v.toUpperCase() : v), z.enum(['DEFAULT', 'ROOT']))
        .describe(
          'The type of file:\n- `ROOT` — The file containing the full OpenAPI structure. This serves as the entry point for the API spec and references other (`DEFAULT`) spec files. Multi-file specs can only have one root file.\n- `DEFAULT` — A file referenced by the `ROOT` file.\n'
        )
        .optional(),
      content: z.string().describe("The specification's stringified contents.").optional(),
    });
  • Annotations for the tool: title, readOnlyHint, destructiveHint, idempotentHint.
    export const annotations = {
      title: "Updates an API specification's file.",
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: true,
    };
  • Registered in the 'full' enabled resources list (line 106).
    'updateSpecFile',
  • Also registered in the 'minimal' enabled resources list (line 195).
    'updateSpecFile',
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate idempotentHint=true and destructiveHint=false. The description adds behavioral context beyond annotations: multi-file root constraints, property update limitations, and the 10 MB file size limit. This additional detail helps the agent understand side effects and constraints.

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 clear sentence followed by a concise bullet list. Every sentence and bullet adds distinct behavioral information. No fluff, no repetition. It is appropriately front-loaded with the core purpose.

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

Completeness4/5

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

Given the 5-parameter complexity and no output schema, the description covers key behavioral details (constraints on body, type transitions, size limit). It does not document return values, but that is acceptable since no output schema exists. Overall, it provides sufficient context for safe invocation.

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?

Schema coverage is 100%, so parameters are well-documented in the schema. The description adds value by noting that 'content' and 'type' cannot be passed together, and explains the file type change behavior. However, this is incremental; the schema already covers parameter meaning comprehensively.

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

Purpose5/5

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

The description starts with 'Updates an API specification's file,' which clearly states the verb (update) and resource (API spec file). This distinguishes it from sibling tools like createSpecFile (creation) and getSpecFile (retrieval), enabling the agent to select the right tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description includes important constraints (no empty body, no multiple properties, single root rule) but does not explicitly state when to use this tool versus alternatives like updateSpecProperties or createSpecFile. The context is implicitly clear but lacks explicit guidance, earning a 3.

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/postmanlabs/postman-mcp-server'

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