Execute Cumulocity API Call
executeExecute custom JavaScript code against the Cumulocity platform API. Use async functions with cumulocity.request() to perform CRUD operations.
Instructions
Read first. Every result starts with an Executed against tenant: <url> marker line followed by a blank line. Verify it matches the tenant you intend to mutate before reporting the result. The active tenant is global to this CLI session and can be flipped between calls by set-active-tenant. If no tenant is active execute fails with a missing-auth error — call status and set-active-tenant to connect first.
An endpoint visible in query may still return 404 from execute when the service is not actually installed on the current tenant.
Execute JavaScript code against the Cumulocity API. Use the query tool first to find the right endpoint, then write an async function that calls cumulocity.request().
This MCP exposes a bundled Cumulocity core OpenAPI snapshot. Use coreSpec for inventory, alarms, events, measurements, users, tenants, and the broader Cumulocity REST surface. Bundled and discovered microservice APIs available on the current tenant are exposed via serviceSpecs (keyed by contextPath). Prefer endpoint-native parameters (filters, expansions, paging, sorting) over manual multi-call traversal when they can express the request.
Available in your function:
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<T>
}Your code must evaluate to an async function. Return the final value you want.
Execution strategy:
First inspect endpoint parameters with
queryand choose the lowest-call approach.Read relevant tag documentation to discover domain query language/features before writing custom control flow.
Prefer native API filters/expansions/selectors over manual traversal loops when both satisfy the request.
Use manual traversal only when endpoint-native options cannot express the needed result shape.
On success the result is returned in Toon format. On a blocked or failed execution a plain text message is returned. A blocked message means the operation was denied by connection policy — retrying through the same connection will not help.
Examples:
async () => {
return await cumulocity.request({ method: 'GET', path: '/inventory/managedObjects?pageSize=5' })
}
async () => {
return await cumulocity.request({
method: 'GET',
path: '/alarm/alarms?pageSize=10&type=myAlarmType',
})
}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. `await` is supported. |