Skip to main content
Glama

updateSpecFile

Idempotent

Update an API specification file's name, type, or content in Postman. Specify file path and spec ID, with optional type selection (ROOT or DEFAULT).

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

  • The handler function that executes the 'updateSpecFile' tool logic. It makes a PATCH request to `/specs/{specId}/files/{filePath}` with optional name, type, and content fields in the body.
    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 input parameters: specId (string), filePath (string), name (string, optional), type (enum 'DEFAULT'|'ROOT', optional, preprocessed to uppercase), content (string, optional).
    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(),
    });
  • The tool module defines `export const method = 'updateSpecFile'` which serves as the registration identifier. It is imported/registered in enabledResources.ts as part of the full and minimal tool lists.
    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,
  • The tool name 'updateSpecFile' is listed in the `full` tools array in enabledResources.ts, registering it as an available tool.
    'updateSpecFile',
  • The tool name 'updateSpecFile' is also listed in the `minimal` tools array in enabledResources.ts, making it available in the minimal toolset as well.
    'updateSpecFile',
    'updateSpecProperties',
Behavior4/5

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

Annotations indicate readOnlyHint=false, destructiveHint=false, idempotentHint=true. The description adds behavioral context beyond annotations: the endpoint rejects empty bodies, does not accept multiple properties, and has side effects on root file type changes. These details are valuable and do not contradict annotations.

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 concise with a title followed by bullet-pointed notes. Every sentence adds necessary information about usage constraints. It is well-structured but could be slightly more streamlined. The front-loading is good.

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 tool's complexity (5 parameters, 2 required, 1 enum) and absence of output schema, the description covers key behavioral constraints and parameter interactions. It is complete enough for an agent to use correctly, but missing return value information is acceptable given no output schema.

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

Parameters4/5

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

Input schema coverage is 100% with descriptions for all parameters. The description adds value by explaining constraints like no multiple properties and empty body, which are not evident from the schema alone. This elevates the score above the baseline of 3, but since the schema itself is descriptive, it is a 4.

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

Purpose4/5

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

The description clearly states 'Updates an API specification's file.' The purpose is specific to updating a spec file. However, it does not differentiate from sibling tools like 'createSpecFile' or 'updateSpecProperties', which could cause confusion. The verb 'updates' and resource 'spec file' are clear, but lacking sibling differentiation drops it from 5 to 4.

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

Usage Guidelines4/5

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

The description provides explicit notes on usage constraints: no empty body, no multiple properties, root file handling, and size limits. These guidelines help the agent understand when to call the tool correctly. However, it does not explicitly state when not to use the tool or list alternatives, but the context is sufficiently clear for a 4.

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