Skip to content
CP-MCP
Get Support

How code mode works

CP-MCP publishes exactly one MCP tool, code_mode. Claude passes it the body of an async arrow function; the Worker runs that code in a sandboxed V8 isolate, and the value the function returns becomes the MCP response.

Cloudpath’s REST API spans three surfaces with hundreds of operations. Registering each as its own MCP tool would overwhelm Claude’s tool list and waste context on metadata the model rarely needs. Instead, the single code_mode tool gives Claude three namespaced objects it drives from code:

  • core — Cloudpath Core API (admin)
  • tenant — Tenant Portal API
  • property — Property Management API

Because the code runs in an isolate, Claude can plan, search, loop, and post-process across many calls without a tool-call round-trip per step. See The three API surfaces for what each object reaches.

Each of the three objects exposes the same six primitives:

PrimitiveWhat it does
list_tag_groupsHigh-level product areas within the surface
list_tagsEndpoint categories within a group, with operation counts
search_endpointsKeyword search over the spec index, ranked by relevance
list_endpoints_by_tagEnumerate operations under a known tag
get_endpoint_detailsFull parameters, request body, and response schema for one operation
callExecute an authenticated call against an endpoint on that surface

core carries two extra utilities on top of these six: generate_passphrase and generate_image.

A typical code_mode program follows the same shape you would with the docs open:

  1. Orient with core.list_tag_groups() / core.list_tags() (or the tenant / property equivalents) when you don’t know where to look.
  2. Discover with search_endpoints({ query, tag?, method? }) or list_endpoints_by_tag({ tag }).
  3. Inspect with get_endpoint_details({ method, path }) when you need the property table or examples.
  4. Execute with call({ method, path, pathParams?, query?, body? }). For the property surface, also pass propertyMgmtPortalGuid.

Search results usually carry enough detail that Claude calls call directly without a separate get_endpoint_details fetch.

The endpoint index is extracted once from the Cloudpath REST API User Guide PDF and bundled into the Worker, so search_endpoints and list_endpoints_by_tag run in memory with no I/O. The richer full spec — per-endpoint property tables and examples — is stored in object storage (Cloudflare R2) and lazy-loaded the first time get_endpoint_details needs it in a given isolate.

  • The code you pass must be under 20,000 characters.
  • Each code_mode invocation has a 20-second wall-clock budget; a program that exceeds it is aborted.

For the details of how call behaves — return shape, pagination, filtering, and error handling — see Calling conventions.