Skip to main content
Glama

run-collection

Execute Postman API test collections with Newman to validate endpoints and get detailed results. Specify collection path, environment, globals, and iteration count.

Instructions

Run a Postman Collection using Newman

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesPath or URL to the Postman collection
environmentNoOptional path or URL to environment file
globalsNoOptional path or URL to globals file
iterationCountNoOptional number of iterations to run

Implementation Reference

  • Core handler function that executes the Newman CLI to run the Postman collection, processes the run summary and failures into a structured TestResult.
    async runCollection(options: CollectionRunOptions): Promise<TestResult> {
        return new Promise((resolve, reject) => {
            const startTime = new Date().toISOString();
            
            newman.run({
                collection: options.collection,
                environment: options.environment,
                globals: options.globals,
                iterationCount: options.iterationCount,
                reporters: 'cli'
            }, (err, summary) => {
                if (err) {
                    reject(err);
                    return;
                }
    
                const endTime = new Date().toISOString();
                
                // Format the results
                const result: TestResult = {
                    success: summary.run.failures.length === 0,
                    summary: {
                        total: summary.run.stats.tests.total || 0,
                        failed: summary.run.stats.tests.failed || 0,
                        passed: (summary.run.stats.tests.total || 0) - (summary.run.stats.tests.failed || 0)
                    },
                    failures: (summary.run.failures || [])
                        .map(extractFailureInfo)
                        .filter((failure): failure is TestFailure => failure !== null),
                    timings: {
                        started: startTime,
                        completed: endTime,
                        duration: new Date(endTime).getTime() - new Date(startTime).getTime()
                    }
                };
    
                resolve(result);
            });
        });
    }
  • MCP CallToolRequest handler specifically for 'run-collection' tool: validates input, executes NewmanRunner.runCollection, and formats success/error responses.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
        if (request.params.name !== "run-collection") {
            throw new Error(`Unknown tool: ${request.params.name}`);
        }
    
        // Validate input
        const args = RunCollectionSchema.parse(request.params.arguments);
    
        try {
            // Run the collection
            const result = await this.runner.runCollection(args);
    
            // Format the response
            return {
                content: [{
                    type: "text",
                    text: JSON.stringify(result, null, 2)
                }]
            };
        } catch (error) {
            const errorMessage = error instanceof Error ? error.message : String(error);
            return {
                content: [{
                    type: "text",
                    text: JSON.stringify({
                        error: errorMessage,
                        success: false
                    }, null, 2)
                }],
                isError: true
            };
        }
    });
  • Zod schema for validating the input arguments to the 'run-collection' tool.
    const RunCollectionSchema = z.object({
        collection: z.string(),
        environment: z.string().optional(),
        globals: z.string().optional(),
        iterationCount: z.number().min(1).optional()
    });
  • Tool registration in ListToolsRequest handler: defines name, description, and JSON inputSchema for 'run-collection'.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: [
            {
                name: "run-collection",
                description: "Run a Postman Collection using Newman",
                inputSchema: {
                    type: "object",
                    properties: {
                        collection: {
                            type: "string",
                            description: "Path or URL to the Postman collection"
                        },
                        environment: {
                            type: "string",
                            description: "Optional path or URL to environment file"
                        },
                        globals: {
                            type: "string",
                            description: "Optional path or URL to globals file"
                        },
                        iterationCount: {
                            type: "number",
                            description: "Optional number of iterations to run"
                        }
                    },
                    required: ["collection"]
                }
            }
        ]
    }));
  • Helper function to safely parse and extract structured failure information from Newman's failure objects.
    function extractFailureInfo(failure: NewmanRunFailure): TestFailure | null {
        try {
            if (!failure.error || !failure.source?.request) {
                return null;
            }
    
            const { error, source } = failure;
            const { request } = source;
    
            // Ensure we have all required properties
            if (!error.test || !error.message || !request.method || !request.url) {
                return null;
            }
    
            return {
                name: error.test,
                error: error.message,
                request: {
                    method: request.method,
                    url: request.url.toString()
                }
            };
        } catch {
            return null;
        }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'run' but doesn't specify whether this is a read-only operation, if it modifies data, requires authentication, has side effects, or what the output looks like. This leaves significant gaps for an agent to understand the tool's behavior.

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 with zero wasted words. It's appropriately sized and gets straight to the point without unnecessary elaboration.

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

Completeness2/5

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

For a tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what happens when the tool runs (e.g., test execution results, potential side effects), nor does it provide behavioral context needed for safe and effective use by an AI agent.

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?

The schema has 100% description coverage, so all parameters are documented in the schema. The description doesn't add any additional semantic context about parameters beyond what's already in the schema, which is acceptable but not exceptional given the schema's completeness.

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 the action ('Run') and the resource ('a Postman Collection using Newman'), providing specific technical context. It doesn't need to differentiate from siblings since none exist, but it could be slightly more specific about what 'run' entails (e.g., executing API tests).

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 is provided about when to use this tool versus alternatives, prerequisites, or typical use cases. The description simply states what it does without context about appropriate scenarios or limitations.

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

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