Skip to main content
Glama

Write Bruno Request

write_request

Create new Bruno API request files (.bru or .yml) or partially update existing ones by filePath, preserving untouched fields. Write multiple HTTP, WebSocket, or gRPC requests in a single batch call.

Instructions

Create a request file or change an existing one (.bru and .yml). The locator decides which: collectionPath plus name creates, filePath changes what is already there. Creating never overwrites — an existing file is refused, so address it by filePath. Changing is a partial merge: only provided fields are updated and every other field is preserved. Pass requests to write a whole set in ONE call, not one call per request. Authors HTTP requests by default, WebSocket requests with kind "websocket" (url plus websocket.messages) and gRPC requests with kind "grpc" (url plus grpc.method, grpc.protoPath and grpc.messages); neither takes an HTTP method or a body. Supports multipart/form-data with file uploads and per-part contentType (body.type "form-data" with formData entries of type "file"), and inline scripts (pre-request/post-response/tests) so no separate add_test_script call is needed. Scripts run as async functions: top-level await works, and bru.sleep(ms)/setTimeout/setInterval spend the script timeout (settings.timeout, default 5000ms) — raise it via the settings argument. Inline scripts REPLACE the existing script of the same type by default, so repeated calls do not accumulate duplicate blocks; scriptMode:"append" concatenates instead, and remove_script clears one. RENAMING: name and filename are independent, as they are in Bruno itself — name changes the request's name inside the file and filename moves the file. Pass both to keep them in step, and read the new path back from the response.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "write_request"
  }
}

Input Schema

NameRequiredDescriptionDefault
urlNoRequired when creating a request. On an existing one it replaces the URL.
authNo
bodyNo
grpcNogRPC-only fields. Applies to kind "grpc" and is refused otherwise. Headers given for a gRPC request are written as metadata, which is that transport's only header surface.
kindNoTransport. Defaults to "http". "websocket" and "grpc" take no method and no body; their payloads are websocket.messages and grpc.messages. Set only when creating: an existing request cannot change transport.
nameNoThe request's name. Required when creating. On an existing request this changes the name inside the file and does NOT rename the file — pass filename for that.
varsNo
queryNo
assertNoDeclared assertions, evaluated on every run without needing a test() block. On an existing request this replaces the whole assert block; omit to leave existing assertions untouched.
folderNoSubfolder within the collection to create the request in. Only valid when creating.
methodNoRequired for kind "http", refused for "websocket" and "grpc", which have no HTTP method. A gRPC request names its RPC method in grpc.method.
headersNo
scriptsNoInline scripts to persist with the request. Keys: pre-request, post-response, tests (aliases before-request/after-response accepted). IMPORTANT for tests/post-response: only assertions inside a test() block are reported. Write test("status is 200", function() { expect(res.getStatus()).to.equal(200); }); — a bare top-level expect() still runs, but a passing one records nothing, so run_collection reports "tests": []. Available: res.getStatus()/getStatusText()/getHeader(name)/getHeaders()/getBody()/getResponseTime(), res.getStopReason()/getCloseCode()/getSessionTruncated() on a websocket request, reporting the same session outcome the result does (all null or false on an HTTP response), bru.setVar(name, value)/getVar(name)/getEnvVar(name)/hasEnvVar(name), and expect(actual) with .to.equal/.contain/.include, .to.have.property/.lengthOf, .to.be.a/.an, .to.be.above/.below/.at.least/.at.most (aliases .gt/.lt/.gte/.lte/.greaterThan/.lessThan), .to.be.within(min, max), .to.be.oneOf([...]), .to.match(/re/), .to.startWith/.endWith, .to.be.true/.false/.null/.undefined/.empty/.json, and .to.not.* negations. VARIABLES: bru.getVar(name) resolves environment and collection variables as well as anything a script set. bru.getEnvVar(name) reads the environment layer only, so a runtime variable of the same name does not shadow it. There is no setEnvVar — nothing here writes an environment file. RETURN TYPE: res.getBody() returns the response already parsed when the Content-Type is application/json or a +json type (raw text otherwise). Access fields directly — res.getBody().field — and do NOT JSON.parse() it, which throws SyntaxError: "[object Object]" is not valid JSON.
filePathNoAbsolute path to the .yml or .bru request file to change. Get from list_requests or get_collection_stats. Only provided fields are updated; every other field is kept.
filenameNoRenames the file, keeping it in its own folder. Basename only, no path separators. The extension is optional and must match the collection's format if given. Refused if another file of that name already exists. The new path comes back in the response; use it as filePath from then on. Only valid on an existing request.
requestsNoWrite several requests in one call. Each item takes the same fields as a single write and means the same thing: name creates one in the collection named at the top level, filePath edits an existing one. collectionPath belongs at the top level, named once for the whole batch. Every item is validated before anything is written, so a refusal leaves no partial state; a write that fails after that is reported against its own item and the remaining items still run. The response lists every item in the order passed, with the path written or the reason it failed.
sequenceNoRun order within the folder. Defaults to after the folder's other requests. Only valid when creating.
settingsNoRequest-level settings: transport behaviour (timeouts, redirects, URL encoding), not payload. What reaches the file depends on the dialect, because Bruno's own two writers differ: a .yml request always carries a fully resolved settings block whether or not you pass one, while a .bru request carries only what you supply. Fields are merged individually over the existing block, so setting one does not clear the rest. Note encodeUrl: in .bru, creating a block at all changes the URL-encoding default.
websocketNoWebSocket-only fields. Applies to kind "websocket" and is refused otherwise.
pathParamsNoValues for :name segments in the URL, e.g. { id: "42" } for /users/:id. On an existing request this replaces the declared path parameters; query parameters are left alone.
scriptModeNoHow to write the scripts field. "replace" (the default) overwrites the existing script of each provided type, so repeating the same call is idempotent. "append" concatenates onto the existing script, accumulating blocks across calls. Each script type has its own slot in both .bru and .yml, so replacing one leaves the others untouched. One exception on .yml: post-response and tests supplied together in a single call both merge into the after-response slot, so write the tests script in its own call to keep it in the tests slot. Only valid on an existing request.
collectionPathNoAbsolute path to existing collection directory. Passing it, with name, creates a new request; pass filePath instead to change an existing one.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.6.0

TDQS

A4.5/5.0
Behavior5/5

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

With no annotations at all, the description carries the full burden and does it well: creation refuses to overwrite, editing is a partial merge preserving untouched fields, batch items are all validated before anything is written, and a failed item does not abort the rest. It also discloses script replacement vs append semantics, the shared script timeout behavior, and the name-vs-filename distinction, which is exactly the kind of non-obvious behavior an agent would otherwise get wrong.

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 opening is front-loaded with the create-vs-edit decision rule, and nearly every sentence adds information rather than restating the schema. It is a single dense paragraph with only one bolded section header (RENAMING), so the topic switches among kinds, multipart, scripts, and renaming are harder to scan than they need to be for a 22-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?

For a very complex mutation tool with no annotations and no output schema, the description covers create vs edit, batching, transport kinds, multipart uploads, inline scripts, and the rename interaction, and it sketches the response shape (items in order with path or failure reason). Error surfaces beyond 'refused' and the response structure are only lightly described, but nothing needed to call the tool correctly is missing.

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 77%, so the schema already documents most parameters, but the description adds real meaning on top: the locator parameters act as a mode switch, collectionPath belongs at the top level of a batch while each item uses filePath, and scriptMode governs how scripts are written. The deepest semantics (encodeUrl defaults, settings dialect differences) live in the schema rather than here, which keeps this from a 5.

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 first two sentences give a specific verb (create/change), the resource (request files in .bru and .yml), and the exact routing rule: collectionPath plus name creates, filePath edits. It also names the siblings it replaces or interacts with (add_test_script, remove_script), so an agent can distinguish it without opening any schema.

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?

Clear guidance on create-vs-edit, on batching via requests instead of one call per request, and on which fields apply to which kind. It also tells the agent it need not call add_test_script and that remove_script clears a script. It stops short of explicit exclusions against other siblings such as move_request, delete_request, or read_request as a pre-edit inspection step.

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