Skip to main content
Glama

Generate tests for a saved request

generate_tests

Writes pm.test assertions for status, Content-Type, and JSON body schema from a real or described response into a saved request and saves that response as a mock example. Existing tests are kept.

Instructions

Write pm.test assertions into a saved request from a real or described response: its status, its Content-Type and a JSON schema of its body (types and required fields, never values), and save the response as an example the mock server serves. from: run (default) sends the request, so it creates what a POST creates. from: example takes the status and body, or schema, the code returns, for an API that is not running anywhere yet. Tests the request already has are kept; a test with the same name is not added twice.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyNoWith from: example, a representative response body.
fromNorun sends the request and tests its response; example tests the response you describe. Defaults to run.
schemaNoA JSON Schema for the body to use instead of one inferred from the response, for example built from the response type in the code.
statusNoWith from: example, the status the code returns (default 200).
replaceNoReplace the request's test script instead of adding to it.
requestYesRequest id or path (Collection/Folder/Name).
variablesNoWith from: run, variable overrides for this call.
contentTypeNoWith from: example, the Content-Type. Defaults to application/json for a JSON body.
environmentNoWith from: run, the environment to send it with. Defaults to the one the server was started with.
exampleNameNoExample name. Defaults to the status, for example "200 OK".
saveExampleNoSave the response as an example (default true). An example of the same name is replaced.
allowErrorStatusNoWith from: run, write tests even when the response is 4xx or 5xx, to test an error case on purpose.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.4.1

TDQS

A4.5/5.0
Behavior4/5

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

Goes well beyond the annotations by disclosing that from:run actually fires the request ('it creates what a POST creates'), which is a real external side effect, and by documenting merge/dedup semantics for existing test scripts. It does not discuss auth requirements, rate limits, or what happens on network failure, so it stops short of full disclosure.

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 core capability is front-loaded and the two-mode branching is stated early, with no filler sentences. It is dense and slightly run-on, and the mock-example behavior is buried mid-sentence rather than given its own clause, but overall it is efficiently packed for a 12-parameter tool.

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 12 parameters and no output schema, the description does the heavy lifting on the run/example distinction and the side-effect profile, which are the hardest things to infer. It omits any hint of the return value (e.g. the generated test script or example id) and says nothing about the tuning parameters, so it is complete enough to call correctly but not fully self-contained.

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?

Schema coverage is 100%, but the description still adds genuine meaning: it explains that `schema` overrides one inferred from the response (e.g. derived from a code type), and that duplicate-named tests are not added, which clarifies the `replace` semantics. Some parameters (variables, environment, allowErrorStatus, exampleName) are left entirely to the schema.

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?

States a specific verb and resource ('Write pm.test assertions into a saved request') and enumerates exactly what gets asserted: status, Content-Type, and a JSON schema of the body. It also carves out its own scope against siblings like send_request and save_example by explaining that it both tests and persists the response as a mock example.

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

Usage Guidelines5/5

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

Explicitly branches on the `from` parameter: 'run (default) sends the request' versus 'example ... for an API that is not running anywhere yet,' naming the precondition that selects each mode. It also states the merge rule up front ('Tests the request already has are kept; a test with the same name is not added twice'), leaving nothing for the agent to infer.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.