This is the platform MCP server for managing CNAP resources. For the documentation MCP server used to search docs, see Documentation MCP.
Why Code Mode
Most MCP servers register one tool per API endpoint —list-clusters, get-install, create-product, and so on. As the API grows, the tool list explodes, eating context window tokens and requiring constant maintenance.
Code Mode (also called programmatic tool calling) replaces hundreds of individual tools with just two:
search— discover endpoints by querying the OpenAPI specexecute— call endpoints by writing JavaScript against a typed API client
execute call can fan out dozens of internal API requests in parallel, aggregate results, and return a summary. Less token overhead, fewer round trips, and zero maintenance when the API evolves.
Inspired by CodeAct, this works because LLMs are better at writing code than making individual tool calls — they have seen millions of lines of real-world code but only contrived tool-calling examples.
CodeAct
Apple ML research on LLM code generation for tool use
Code Mode
Cloudflare’s introduction of the pattern
PTC
Anthropic’s recommended approach
cnap-tech/codemode library.
How It Works
Tools
search
Discover available API endpoints by querying the OpenAPI spec. The agent writes a JavaScript function that receives the full spec as spec:
execute
Call API endpoints by writing JavaScript that uses cnap.request(). The agent discovers endpoints with search first, then calls them:
Authentication is handled automatically — the agent cannot set or read the
Authorization header. All requests run inside a sandboxed V8 isolate.Kubernetes Access
The API includes a transparent Kubernetes proxy and a command execution endpoint, giving agents direct access to cluster resources — pod logs, resource listing, API discovery, and running commands.Kubernetes Access Guide
Learn how agents use the kube proxy and exec endpoints with full examples
Resources & Prompts
The MCP server also exposes resources and prompts:| Type | Name | Description |
|---|---|---|
| Resource | cnap://user/profile | Current authenticated user info |
| Prompt | infrastructure-overview | Analyze clusters, installs, and products in a workspace |
| Prompt | deployment-status | Check deployment health and identify issues |
workspaceId argument.
Security
- No auth access — the sandbox cannot read or set the
Authorizationheader; auth is injected server-side - Memory limit — 64 MB per isolate
- CPU timeout — 30 seconds
- Request limit — 50 API calls per execution
- Response limit — 10 MB max response size
- In-process routing — requests never leave the server