RequestRocketRequestRocketDocs
GovernResponse transforms

Response transforms with an agent

Create a response transform from the Core MCP.

Create a response transform when a target response needs code after filters run. You need the organisation clientId, the parent proxyId, and source that default-exports a function.

Call get_guide with guide_key: "transform-creation" before the first create. The transform tools are shared with request transforms. Set transformType to response; it cannot be changed later.

Call order

  1. Call list_proxy_transforms with clientId and proxyId. Keep rows whose transformType is response.
  2. Call create_proxy_transform with clientId, proxyId, transformType, transformMode, transformActive, and code.
  3. Save the returned transform sKey as transformId.
  4. Call get_proxy_transform with all three ids to read its source.
  5. Call update_proxy_transform with the ids and only the fields to change.

For conditional transforms, pass effect and any request or response predicates. Optional fields include priority, notes, variables, and alerts.

Example

{
  "clientId": "organisation-id",
  "proxyId": "proxy-id",
  "transformType": "response",
  "transformMode": "all",
  "transformActive": true,
  "code": "export default function transform(proxyContext, proxyRequest, targetResponse) { return { ...targetResponse, headers: { ...targetResponse.headers, \"x-request-path\": proxyContext.path } }; }"
}

A successful tool result has success: true. Its data.transforms[0].sKey is the new transformId.

The function receives (proxyContext, proxyRequest, targetResponse). It must return an object with a numeric status; headers and data carry the transformed response. Imports, require, fetch, and process are rejected.

Use a filter for retain or destroy operations on successful JSON. Use a response transform when the output requires code.

Next

On this page