Execute Cumulocity API Call
executeRun custom JavaScript code to query and manipulate the Cumulocity IoT platform API using the cumulocity.request() method.
Instructions
Execute JavaScript code against the Cumulocity API. First use the query tool to find the right endpoint, then write an async JavaScript function expression that uses cumulocity.request().
This MCP currently exposes the release (latest) bundled core OpenAPI snapshot together with the other bundled product specs for the query tool. Bundled specs on this connection: core (release), dtm (release). Enabled bundled OpenAPI parts for execute policy: core, dtm.
Use coreSpec for the main Cumulocity REST surface such as inventory, alarms, events, measurements, identity, device control, users, tenants, audit, and the broader platform APIs.
Use dtmSpec for Digital Twin Manager work such as schema definitions, asset models, linked series, and DTM asset or definition APIs.
Available in your module:
type CumulocityRequestOptions = { method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' path: string body?: unknown headers?: Record<string, string> }
declare const cumulocity: { request<T = unknown>(options: CumulocityRequestOptions): Promise }
Your code must evaluate to a function. The top-level binding cumulocity is available automatically. The sandbox assigns your function to a local variable, invokes it, and returns its result.
Recommended shape:
async () => { ... }
Inside that function, call await cumulocity.request({ method, path, ... }) and return the final value you want.
Internally the sandbox classifies execution as success, blocked, or failed.
Tool output behavior:
On success, the actual function result is returned in Toon format.
On blocked or failed execution, the tool returns a plain text message.
The current MCP connection may deny certain method/path combinations and may also use an allow list.
The query tool does not annotate or filter visible operations inside a spec for that policy, and cumulocity.request(...) will reject blocked calls before sending them.
When that happens, the tool returns a plain text connection-policy message. That is not a Cumulocity API failure and retrying the same operation through the same connection will not help.
This MCP can access multiple tenants. Use list-credentials first if the tenant is unclear, then pass the chosen tenantUrl to this tool.
Examples: async () => { return await cumulocity.request({ method: 'GET', path: '/inventory/managedObjects?pageSize=5', }) }
async () => { const alarms = await cumulocity.request({ method: 'GET', path: '/alarm/alarms?pageSize=10&withTotalPages=true', })
return alarms }
async () => { const asset = await cumulocity.request({ method: 'GET', path: '/assets?pageSize=5', })
return asset }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | An async JavaScript function expression. The top-level binding `cumulocity` is available automatically. Return the final result from that function. `await` is supported. | |
| tenantUrl | Yes | The Cumulocity tenant URL against which the operation is executed. |