functions
The functions.* tools of the Runbase MCP server, generated from their definitions.
functions.create
Creates a TypeScript function (admin scope), refused if the name exists. Then usable as block fn.<name>. Code: export default async (input, \{ records, events, secrets, test \}) => output. Failure convention in a workflow (fn._ step): return \{ ok: false, error: "message" \} or throw: the step fails, is retried per its retry policy, then the run fails and the error appears in errors.list. test: true inside a test run (runs.start { test: true }, or a run inherited from one); records and events written by the function in a test run are marked test automatically. Declared secrets: secrets context key (and input.secrets if the input does not already have that field). Records SDK (permissions.records 'read': get, search; 'write': + upsert, update, transact, delete, merge): await records.get(id), records.search(object, \{filter, limit\}) (object = slug or uuid), records.upsert(\{objectId: slug or uuid, data, match\}) (returns {record, created}), records.update(id, data), records.transact(ops), records.delete(id) (trash), records.merge(keepId, [ids]); also as a global records. Events SDK (permissions.events 'read': events.list(\{type, recordId, from, to, cursor, limit\}); 'write': + events.push(\{type, recordId, payload, occurredAt, idempotencyKey\})). permissions.domains: hostnames or '_'= whole public internet (admin scope); private/loopback/link-local/cloud metadata IPs (RFC1918, 127/8, ::1, 169.254/16, 100.64/10, fc00::/7) are blocked after DNS resolution and on redirects. HTML:parseHTML(html)returns\{ document \}(linkedom: querySelectorAll, textContent, getAttribute) andnew DOMParser().parseFromString(html, 'text/html'), as globals and ctx.parseHTML; no browser rendering, no npm imports. limits: { timeoutMs 1000-120000 (default 30000), memoryMb 32-512 (default 128) }. console.* = logs (64 KB max), visible in functions.test, functions.logs and runs.get.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | |
code | string | yes | |
inputSchema | object | no | |
outputSchema | object | no | |
permissions | object | no | |
limits | object | no | |
workspace | string | no | Workspace id or name (default: active workspace) |
functions.delete
Deletes a function and all its versions (admin scope). Irreversible: confirm: true required. Workflows that use it (fn.<name>) will fail.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Function name |
confirm | boolean | no | |
workspace | string | no | Workspace id or name (default: active workspace) |
functions.get
Reads a function by name: latest version, or a fixed version if version is given.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Function name |
version | integer | no | |
workspace | string | no | Workspace id or name (default: active workspace) |
functions.list
Lists the workspace functions (latest version).
| Name | Type | Required | Description |
|---|---|---|---|
workspace | string | no | Workspace id or name (default: active workspace) |
functions.logs
Logs of function executions (workflow, page, test), most recent first: console logs, error, duration, originating run and step. Filters: name, runId, source, errorsOnly. Returns { items, hasMore, nextCursor }.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | no | Function name |
runId | string | no | |
source | string | no | One of: workflow, page, test. |
errorsOnly | boolean | no | |
cursor | string | no | |
limit | integer | no | |
workspace | string | no | Workspace id or name (default: active workspace) |
functions.restore
Restores a previous version (creates a new version with its content).
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Function name |
version | integer | yes | |
workspace | string | no | Workspace id or name (default: active workspace) |
functions.save
Creates a TypeScript function or, if the name exists, creates a new version of it (admin scope). Permissions: network domains, secrets, records, events. Code: export default async (input, \{ records, events, secrets, test \}) => output. Failure convention in a workflow (fn._ step): return \{ ok: false, error: "message" \} or throw: the step fails, is retried per its retry policy, then the run fails and the error appears in errors.list. test: true inside a test run (runs.start { test: true }, or a run inherited from one); records and events written by the function in a test run are marked test automatically. Declared secrets: secrets context key (and input.secrets if the input does not already have that field). Records SDK (permissions.records 'read': get, search; 'write': + upsert, update, transact, delete, merge): await records.get(id), records.search(object, \{filter, limit\}) (object = slug or uuid), records.upsert(\{objectId: slug or uuid, data, match\}) (returns {record, created}), records.update(id, data), records.transact(ops), records.delete(id) (trash), records.merge(keepId, [ids]); also as a global records. Events SDK (permissions.events 'read': events.list(\{type, recordId, from, to, cursor, limit\}); 'write': + events.push(\{type, recordId, payload, occurredAt, idempotencyKey\})). permissions.domains: hostnames or '_'= whole public internet (admin scope); private/loopback/link-local/cloud metadata IPs (RFC1918, 127/8, ::1, 169.254/16, 100.64/10, fc00::/7) are blocked after DNS resolution and on redirects. HTML:parseHTML(html)returns\{ document \}(linkedom: querySelectorAll, textContent, getAttribute) andnew DOMParser().parseFromString(html, 'text/html'), as globals and ctx.parseHTML; no browser rendering, no npm imports. limits: { timeoutMs 1000-120000 (default 30000), memoryMb 32-512 (default 128) }. console.* = logs (64 KB max), visible in functions.test, functions.logs and runs.get.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | |
code | string | yes | |
inputSchema | object | no | |
outputSchema | object | no | |
permissions | object | no | |
limits | object | no | |
workspace | string | no | Workspace id or name (default: active workspace) |
functions.test
Really runs a function, outside any workflow: returns output and logs. Without dryRun, its writes (records, events) and network calls happen. dryRun: true: real reads, records/events writes simulated (not made) and listed in writes [{ method, args }]; network calls still go out.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Function name |
input | object | no | |
version | integer | no | |
dryRun | boolean | no | |
workspace | string | no | Workspace id or name (default: active workspace) |
functions.update
Creates a new version of an existing function (admin scope). Code: export default async (input, \{ records, events, secrets, test \}) => output. Failure convention in a workflow (fn._ step): return \{ ok: false, error: "message" \} or throw: the step fails, is retried per its retry policy, then the run fails and the error appears in errors.list. test: true inside a test run (runs.start { test: true }, or a run inherited from one); records and events written by the function in a test run are marked test automatically. Declared secrets: secrets context key (and input.secrets if the input does not already have that field). Records SDK (permissions.records 'read': get, search; 'write': + upsert, update, transact, delete, merge): await records.get(id), records.search(object, \{filter, limit\}) (object = slug or uuid), records.upsert(\{objectId: slug or uuid, data, match\}) (returns {record, created}), records.update(id, data), records.transact(ops), records.delete(id) (trash), records.merge(keepId, [ids]); also as a global records. Events SDK (permissions.events 'read': events.list(\{type, recordId, from, to, cursor, limit\}); 'write': + events.push(\{type, recordId, payload, occurredAt, idempotencyKey\})). permissions.domains: hostnames or '_'= whole public internet (admin scope); private/loopback/link-local/cloud metadata IPs (RFC1918, 127/8, ::1, 169.254/16, 100.64/10, fc00::/7) are blocked after DNS resolution and on redirects. HTML:parseHTML(html)returns\{ document \}(linkedom: querySelectorAll, textContent, getAttribute) andnew DOMParser().parseFromString(html, 'text/html'), as globals and ctx.parseHTML; no browser rendering, no npm imports. limits: { timeoutMs 1000-120000 (default 30000), memoryMb 32-512 (default 128) }. console.* = logs (64 KB max), visible in functions.test, functions.logs and runs.get.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | |
code | string | yes | |
inputSchema | object | no | |
outputSchema | object | no | |
permissions | object | no | |
limits | object | no | |
workspace | string | no | Workspace id or name (default: active workspace) |
functions.versions
Lists the (immutable) versions of a function.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Function name |
workspace | string | no | Workspace id or name (default: active workspace) |