← Files Mintlify MCPARCHIVED FILE

SKILL.md

3.06 KB · Oct 2, 2026 · 00:05 UTC

↓ Download file

---
name: using-code-mode
description: Use when managing a Mintlify deployment beyond docs content — workflows, deployment settings, members, analytics — or whenever a task needs execute_code / search_code_operations on the Admin MCP.
---

# Using Code Mode

## Overview

`execute_code` runs a TypeScript/JavaScript script against the Admin MCP dashboard SDK in a sandboxed Cloudflare isolate. It needs **no checkout**, and writes apply **immediately to the live deployment** — there is no branch/PR safety net. Confirm with the user before destructive or customer-visible writes.

Available namespaces as top-level globals: `workflows`, `deployment`, `members`, `billing`, `integrations`, `analytics`, `deployments`, plus `console`. No outbound fetch, no secrets; each SDK call is gated by the OAuth scopes on the token. `deployment`, `analytics`, `workflows`, and `members` carry nearly all operations; `billing` and `integrations` are sparse or empty — enumerate with `search_code_operations { namespace: 'billing' }` before assuming a method exists. `members` operations are org-scoped, not per-deployment.

## Find the method first

`search_code_operations { query, namespace?, limit? }` is BM25 search over all SDK methods. Each hit includes the method's full JSON Schema `inputSchema`, so no extra lookup is needed. Pass `namespace` alone to enumerate everything in it (workflows, deployment, members, billing, integrations, analytics). Always search before writing a script — never guess method names or parameter shapes.

## Return semantics (the #1 footgun)

The script is wrapped in an async function; the value of the **last expression statement** becomes the result.

```
const summary = await analytics.getUsageSummary({ usageType: 'CHAT_MESSAGE' });
const insights = await analytics.getInsights({});
({ summary, insights });
```

- `await x.y();` alone on the last line works.
- A bare top-level `return X;` is **dropped**.
- `export default async function ...` returns the function object, not its result.

## Targeting deployments

Every namespace method takes an optional second argument `{ subdomain }`:

```
workflows.listWorkflows({}, { subdomain: 'acme' });
```

Omit it to use the token's default deployment. `deployments.list()` enumerates the org (requires `deployment:read`). Mixing subdomains in one run is fine.

## Result envelope

`{ ok: true, result, logs, truncated, durationMs }` or `{ ok: false, error: { code, message }, ... }`. Error codes: `unauthorized`, `invalid_json`, `invalid_request`, `misconfigured`, `timeout` (30s wall clock), `sandbox_error` (your script threw), `execution_failed` (worker plumbing). `truncated: true` = result/logs hit the size cap — narrow the query or page through.

## Common mistakes

- Using `return` at top level — result silently becomes undefined.
- Treating code-mode writes like session edits — they are live instantly; there is no `save`/`discard`.
- Guessing method signatures instead of calling `search_code_operations`.
- Calling `checkout` first — unnecessary for code mode.
- Trying `fetch` or Node APIs — the sandbox has neither.

SHA-256: b26c8bcf84b357bb087ca78e10c03977b6f50745a3aaee27c70ecd11ffa4ed98