Skip to main content
Glama

createSpecFile

Creates an API specification file in Postman. Provide a spec ID, file path, and stringified content to generate a new spec file with default type and folder support.

Instructions

Creates an API specification file.

Note:

  • If the file path contains a `/` (forward slash) character, then a folder is created. For example, if the path is the `components/schemas.json` value, then a `components` folder is created with the `schemas.json` file inside.

  • Creating a spec file assigns it the `DEFAULT` file type.

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

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
specIdYesThe spec's ID.
pathYesThe file's path. Accepts JSON or YAML files.
contentYesThe file's stringified contents.

Implementation Reference

  • The main tool logic: constructs a POST request to /specs/{specId}/files with path and content, sends it via PostmanAPIClient, and returns the result.
    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`;
        const query = new URLSearchParams();
        const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
        const bodyPayload: any = {};
        if (args.path !== undefined) bodyPayload.path = args.path;
        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.post(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 for the tool's input parameters: specId (string), path (string), content (string).
    export const parameters = z.object({
      specId: z.string().describe("The spec's ID."),
      path: z.string().describe("The file's path. Accepts JSON or YAML files."),
      content: z.string().describe("The file's stringified contents."),
    });
  • Exported method name constant 'createSpecFile' used for tool identification.
    export const method = 'createSpecFile';
  • Annotations for the tool including title, readOnlyHint, destructiveHint, idempotentHint.
    export const annotations = {
      title: 'Creates an API specification file.',
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: false,
    };
  • src/index.ts:253-262 (registration)
    Registration of all tools (including createSpecFile) via server.registerTool() using the module's method, description, inputSchema, annotations, and handler.
    // Register all tools using the McpServer registerTool method
    for (const tool of tools) {
      server.registerTool(
        tool.method,
        {
          description: tool.description,
          inputSchema: tool.parameters.shape,
          annotations: tool.annotations || {},
        },
        async (args, extra) => {
Behavior4/5

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

Annotations only indicate non-read-only, non-destructive, non-idempotent. The description adds valuable context: folder creation via forward slashes, default file type assignment, the 'only one root file' constraint for multi-file specs, and a 10 MB file size limit. These details help the agent understand side effects and limitations beyond what annotations provide.

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 concise: one main sentence followed by four bullet-pointed notes. Every sentence adds value, no redundancy. Front-loaded with the core purpose, then structured detail.

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 simplicity (3 required params, no output schema), the description covers key constraints (folder creation, file type, root file, size limit). However, it omits whether overwriting an existing file is allowed or if an error occurs, which would be helpful for an agent. Still, for a tool of this complexity, it is mostly complete.

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?

Input schema has 100% coverage with descriptions for all three parameters (specId, path, content). The description does not add any new semantic information about parameters; it only touches on path behavior (folder creation) which is more about tool behavior than parameter meaning. Baseline 3 is appropriate given full schema coverage.

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 clearly states 'Creates an API specification file,' with specific verb and resource. The added notes about folder creation and file type assignment further clarify the action, distinguishing it from sibling tools like createSpec which likely creates a new spec document. No ambiguity.

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 like createSpec or updateSpecFile. It does not mention prerequisites or exclusions, leaving the agent to infer appropriate usage context without explicit direction.

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