Skip to main content
Glama

runCollection

Idempotent

Run a Postman collection by ID to execute API tests and get detailed results with statistics. Optionally use an environment for variable substitution.

Instructions

Runs a Postman collection by ID with detailed test results and execution statistics. Supports optional environment for variable substitution. Note: Advanced parameters like custom delays and other runtime options are not yet available.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionIdYesThe collection ID in the format <OWNER_ID>-<UUID> (e.g. 12345-33823532ab9e41c9b6fd12d0fd459b8b).
environmentIdNoOptional environment ID to use for variable substitution during the run.
stopOnErrorNoGracefully halt on errors (default: false)
stopOnFailureNoGracefully halt on test failures (default: false)
abortOnErrorNoAbruptly halt on errors (default: false)
abortOnFailureNoAbruptly halt on test failures (default: false)
iterationCountNoNumber of iterations to run (default: 1)
requestTimeoutNoRequest timeout in milliseconds (default: 60000)
scriptTimeoutNoScript timeout in milliseconds (default: 5000)

Implementation Reference

  • The main handler function for the runCollection MCP tool. Calls runCollection() from the runner module, which uses Newman to execute a Postman collection and returns output text.
    export async function handler(
      params: z.infer<typeof parameters>,
      extra: { client: PostmanAPIClient; headers?: IsomorphicHeaders; serverContext?: ServerContext }
    ): Promise<CallToolResult> {
      try {
        const output = await runCollection(params, extra.client);
    
        return {
          content: [
            {
              type: 'text',
              text: output,
            },
          ],
        };
      } catch (e: unknown) {
        if (e instanceof McpError) {
          throw e;
        }
        throw asMcpError(e);
      }
    }
  • Zod schema defining input parameters for runCollection: collectionId (required), environmentId, stopOnError, stopOnFailure, abortOnError, abortOnFailure, iterationCount, requestTimeout, scriptTimeout (all optional).
    export const parameters = z.object({
      collectionId: z
        .string()
        .describe(
          'The collection ID in the format <OWNER_ID>-<UUID> (e.g. 12345-33823532ab9e41c9b6fd12d0fd459b8b).'
        ),
      environmentId: z
        .string()
        .optional()
        .describe('Optional environment ID to use for variable substitution during the run.'),
      stopOnError: z.boolean().optional().describe('Gracefully halt on errors (default: false)'),
      stopOnFailure: z
        .boolean()
        .optional()
        .describe('Gracefully halt on test failures (default: false)'),
      abortOnError: z.boolean().optional().describe('Abruptly halt on errors (default: false)'),
      abortOnFailure: z
        .boolean()
        .optional()
        .describe('Abruptly halt on test failures (default: false)'),
      iterationCount: z.number().optional().describe('Number of iterations to run (default: 1)'),
      requestTimeout: z
        .number()
        .optional()
        .describe('Request timeout in milliseconds (default: 60000)'),
      scriptTimeout: z.number().optional().describe('Script timeout in milliseconds (default: 5000)'),
    });
    
    export type RunCollectionParameters = z.infer<typeof parameters>;
  • Registration of 'runCollection' in the full resources list (line 49), minimal resources list (line 215), and excludedFromGeneration list (line 249), marking it as enabled but not auto-generated.
    'runCollection',
  • The core runCollection orchestrator function that fetches the collection and optional environment from the Postman API, executes via Newman, formats output, and reports telemetry.
    export async function runCollection(
      params: CollectionRunParams,
      client: PostmanAPIClient
    ): Promise<string> {
      const collection = await fetchCollection(params.collectionId, client);
    
      let environment;
      if (params.environmentId) {
        environment = await fetchEnvironment(params.environmentId, client);
      }
    
      const result = await executeCollection({
        collection,
        environment,
        params,
      });
    
      const telemetryPayload = parseToTelemetry(result, params.collectionId, collection.name);
    
      const userOutput = formatUserOutput(result);
    
      reportTelemetryAsync(telemetryPayload, client);
    
      return userOutput;
    }
  • The executeCollection function that runs the collection using Newman library, builds options from params, tracks assertions/test results, and produces an ExecutionResult with output, stats, summary, and timing.
    export async function executeCollection(context: ExecutionContext): Promise<ExecutionResult> {
      const tracker = new TestTracker();
      const output = new OutputBuilder();
    
      output.add(`🚀 Starting collection: ${context.collection.name}`);
      if (context.environment) {
        output.add(`🌍 Using environment: ${context.environment.name}\n`);
      }
    
      const newmanOptions = buildNewmanOptions(
        context.params,
        context.collection.json,
        context.environment?.json
      );
    
      const startTime = Date.now();
    
      const summary = await runNewman(newmanOptions, tracker, output);
    
      const endTime = Date.now();
      const durationMs = endTime - startTime;
    
      return {
        output: output.build(),
        testStats: tracker.getTotalStats(),
        summary,
        startTime,
        endTime,
        durationMs,
      };
    }
Behavior4/5

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

Annotations give idempotentHint=true and destructiveHint=false. The description adds that it returns detailed results and statistics, and notes limitations on advanced parameters. No contradiction.

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 sentences: first states purpose and output, second notes limitations. No fluff, front-loaded with key info.

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?

For a tool with 9 parameters and no output schema, the description covers the return value (detailed results/statistics) and key limitation. Lacks details on error handling but schema covers that.

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 the description doesn't need to explain parameters. It mentions collectionId and environmentId but not others, which is acceptable since schema descriptions are sufficient.

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 tool runs a Postman collection by ID and provides detailed test results and execution statistics. It distinguishes itself from sibling tools like createCollection or getCollection by focusing on execution.

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 mentions optional environment support and notes that advanced parameters are not available, guiding users on when to use (basic runs) and when to avoid (if advanced options needed). It doesn't explicitly mention alternatives but contextually clear.

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