Skip to main content

Default behavior

When your handler returns a plain object, the platform responds with 200 OK and Content-Type: application/json:
When you need a different status code or custom headers, use the response builder.

Response builder

Import response from @jelou/functions:

Custom status code

Custom headers

Multiple headers at once

Full chaining

The builder is immutable — each method returns a new instance:

API

.json() and .noContent() are the terminal methods — after calling them you get a final response, not a builder.

Practical examples

Output validation

When using response.json(body) with an output schema, validation applies to the body — same as with plain objects. Validation never blocks the response.

MCP behavior

When invoked via MCP (Brain Studio AI agents):
  • The body is emitted as structuredContent
  • Status code and headers are ignored — MCP has no HTTP status concept
  • The body is also sent as JSON text for compatibility
No need to condition your code for HTTP vs MCP — use the response builder normally. The platform extracts the body and discards HTTP metadata for MCP invocations.

Limitations

For advanced needs (streaming, binary, dynamic content-type), use raw mode.