Skip to main content
Glama

Execute Cumulocity API Call

execute

Execute 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 query and 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

TableJSON Schema
NameRequiredDescriptionDefault
codeYesAn async JavaScript function expression. The top-level binding `cumulocity` is available automatically. Return the final result. `await` is supported.
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It reveals: the marker line in results, missing-auth error when no active tenant, potential 404 from uninstalled services, blocked execution due to policy, and return format (Toon on success, plain text on failure). All key behaviors are transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but well-organized with clear sections (e.g., 'Read first.', 'Execution strategy:', 'Examples:'). Critical warnings are front-loaded. Every sentence adds necessary information, though some redundancy exists in the strategy section. It is structured for easy scanning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (executing arbitrary code against an API) and lack of output schema, the description is remarkably complete. It covers input requirements, execution environment, error conditions, result format, prerequisites, and best practices. No obvious gaps remain.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema coverage is 100% with a basic description of the 'code' parameter. The description adds substantial value: it specifies the exact structure (async function returning final value), provides the full CumulocityRequestOptions type and cumulocity object definition, includes examples, and elaborates on execution constraints. This goes well beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the tool as executing JavaScript code against the Cumulocity API. It distinguishes from sibling tools (query, set-active-tenant, status) by explaining that query is used to find endpoints first, and that status/set-active-tenant handle tenant setup. The verb 'execute' and resource 'JavaScript code' are explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides comprehensive guidance: when to use (after using query, with active tenant), when not to use (if no active tenant, call status/set-active-tenant first), and alternatives (query for discovery). It also explains execution strategy, error handling, and the marker line requirement. The 'Read first.' emphasis ensures critical info is not missed.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/schplitt/mc8yp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server