Skip to main content
Glama

generateSpecFromCollection

Create an API specification from a Postman collection. Get a polling link to track task status.

Instructions

Generates an API specification for the given collection. The response contains a polling link to the task status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionUidYesThe collection's unique ID.
elementTypeYesThe `spec` value.
nameYesThe API specification's name.
typeYesThe specification's type.
formatYesThe format of the API specification.

Implementation Reference

  • Handler function that generates an API specification from a collection. Makes a POST request to /collections/{collectionUid}/generations/spec with name, type, and format parameters.
    export async function handler(
      args: z.infer<typeof parameters>,
      extra: { client: PostmanAPIClient; headers?: IsomorphicHeaders; serverContext?: ServerContext }
    ): Promise<CallToolResult> {
      try {
        const endpoint = `/collections/${args.collectionUid}/generations/${args.elementType}`;
        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.format !== undefined) bodyPayload.format = args.format;
        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 defining input parameters: collectionUid (string), elementType (literal 'spec'), name (string), type (enum OPENAPI:2.0/3.0/3.1 with case-insensitive preprocessing), format (enum JSON/YAML with case-insensitive preprocessing).
    export const parameters = z.object({
      collectionUid: z.string().describe("The collection's unique ID."),
      elementType: z.literal('spec').describe('The `spec` value.'),
      name: z.string().describe("The API specification's name."),
      type: z
        .preprocess(
          (v) => (typeof v === 'string' ? v.toUpperCase() : v),
          z.enum(['OPENAPI:2.0', 'OPENAPI:3.0', 'OPENAPI:3.1'])
        )
        .describe("The specification's type."),
      format: z
        .preprocess((v) => (typeof v === 'string' ? v.toUpperCase() : v), z.enum(['JSON', 'YAML']))
        .describe('The format of the API specification.'),
    });
  • Registered in the 'full' tool set list of enabled resources.
    'generateSpecFromCollection',
  • Also registered in the 'minimal' tool set list of enabled resources.
    'generateSpecFromCollection',
  • Supporting helper: asMcpError function used by the handler to wrap errors into MCP errors.
    export function asMcpError(error: unknown): McpError {
      const cause = (error as any)?.cause ?? String(error);
      return new McpError(ErrorCode.InternalError, cause);
    }
Behavior3/5

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

Annotations are mostly false, so description adds that response contains a polling link, implying async behavior. However, no details on auth, rate limits, or what happens if collection doesn't exist.

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?

Two concise sentences with the first stating purpose and second adding key behavioral detail. No wasted words.

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

Completeness3/5

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

Missing details about the polling endpoint structure and task status model. Output schema is absent, but description is adequate for a basic async tool.

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%, and description adds no extra meaning beyond the schema descriptions. Baseline score is appropriate.

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 the verb 'generates' and the resource 'API specification for the given collection'. It also specifies the response contains a polling link, distinguishing it from siblings like createSpec.

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?

No guidance on when to use this tool vs alternatives (e.g., createSpec, generateCollection). No mention of prerequisites or error conditions.

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