Request transforms with an agent
Create a request transform from the Core MCP.
Create a request transform when an outbound request needs code after overrides and before the target call. 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. List and get return both request and response transforms. Filter on transformType request. List results omit the code.
Call order
- Call
list_proxy_transformswithclientIdandproxyIdto inspect existing transforms. - Call
create_proxy_transformwithclientId,proxyId,transformType,transformMode,transformActive, andcode. - Save the returned transform
sKeyastransformId. - Call
get_proxy_transformwith all three ids to read the stored source. - Call
update_proxy_transformwith the ids and only the fields to change.transformTypecannot change.
For conditional transforms, pass effect and any predicate fields. Optional fields also include priority, notes, variables, and alerts.
Example
Ask the agent to call create_proxy_transform with:
{
"clientId": "organisation-id",
"proxyId": "proxy-id",
"transformType": "request",
"transformMode": "all",
"transformActive": true,
"code": "export default function transform(proxyContext, proxyRequest) { return { ...proxyRequest, headers: { ...proxyRequest.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) and returns an object containing any changed method, relative url, headers, params, or data. Imports, require, fetch, and process are rejected.