Server path:Documentation Index
Fetch the complete documentation index at: https://docs.pinkfish.ai/llms.txt
Use this file to discover all available pages before exploring further.
/code-execution | Type: Embedded | PCID required: No
Tools
| Tool | Description |
|---|---|
code-execution_execute | Execute JavaScript code in a sandboxed VM with access to MCP tools and file helpers. Available globals: - callTool(serverPath, toolName, toolArgs) — Call a configured MCP tool via HTTP. DO NOT pass PCID — connection is auto-injected from selection context. - codeExec.createArtifact(filename, content, fileType) — Create a file (uploads to platform, returns { success, id, url, filename, mimeType, size }). Supported types: csv, txt, json, html, xml, js, ts, md, py. This is a simplified file helper — for full artifact features, use the agent’s write_artifact tool. - codeExec.readArtifact(identifier) — Read a file by ID, filename, or URL (returns { success, content, size, filename, mimeType }). This is a simplified reader — for advanced features (search, pagination, smartGrepQuery), use the agent’s read_artifact tool after code execution returns. - console.log/error/warn(…args) — Captured to logs array returned in the response. - setTimeout/setInterval/clearTimeout/clearInterval — Standard timer functions (cleaned up after execution). EXAMPLES: // Call MCP tools (DO NOT pass PCID - connection is auto-injected from selection context): const emails = await callTool(“gmail”, “gmail_search_emails”, { query: “is:unread” }); // Create output files: const csv = emails.map(e => ${e.from},${e.subject}).join(‘\n’);await codeExec.createArtifact(‘emails.csv’, csv, ‘csv’); // Read an artifact from the conversation: const data = await codeExec.readArtifact(‘file_abc123’); console.log(data.content); // Return result to agent: return { count: emails.length }; LARGE RESULTS: If the returned value serializes to >200 bytes, an artifact is created automatically and the response includes an artifactId with a truncated preview. The agent can use read_artifact to access the full result. IMPORTANT — NO UNBOUNDED LOOPS: - NEVER write while(true), while(hasMore), or open-ended loops that call callTool() repeatedly. Each callTool() is an HTTP round-trip and loops will timeout. - If a tool doesn’t have a pagination parameter (e.g. “page”), do NOT attempt manual pagination — you will get the same page repeatedly. - If you need more data than one API call returns, return what you have and tell the user the tool’s page limit was reached. - Bounded loops (e.g. for(let i=0; i<items.length; i++)) over local data are fine. - Be suspicious of round numbers (30, 50, 100) — they usually mean you hit a perPage limit, not the actual total. Default timeout: 10 minutes (max 15 minutes). |
code-execution_execute
Execute JavaScript code in a sandboxed VM with access to MCP tools and file helpers. Available globals:- callTool(serverPath, toolName, toolArgs) — Call a configured MCP tool via HTTP. DO NOT pass PCID — connection is auto-injected from selection context.
- codeExec.createArtifact(filename, content, fileType) — Create a file (uploads to platform, returns { success, id, url, filename, mimeType, size }). Supported types: csv, txt, json, html, xml, js, ts, md, py. This is a simplified file helper — for full artifact features, use the agent’s write_artifact tool.
- codeExec.readArtifact(identifier) — Read a file by ID, filename, or URL (returns { success, content, size, filename, mimeType }). This is a simplified reader — for advanced features (search, pagination, smartGrepQuery), use the agent’s read_artifact tool after code execution returns.
- console.log/error/warn(…args) — Captured to logs array returned in the response.
- setTimeout/setInterval/clearTimeout/clearInterval — Standard timer functions (cleaned up after execution).
${e.from},${e.subject}).join(‘\n’);
await codeExec.createArtifact(‘emails.csv’, csv, ‘csv’);
// Read an artifact from the conversation:
const data = await codeExec.readArtifact(‘file_abc123’);
console.log(data.content);
// Return result to agent:
return { count: emails.length };
LARGE RESULTS: If the returned value serializes to >200 bytes, an artifact is created automatically and the response includes an artifactId with a truncated preview. The agent can use read_artifact to access the full result.
IMPORTANT — NO UNBOUNDED LOOPS:
- NEVER write while(true), while(hasMore), or open-ended loops that call callTool() repeatedly. Each callTool() is an HTTP round-trip and loops will timeout.
- If a tool doesn’t have a pagination parameter (e.g. “page”), do NOT attempt manual pagination — you will get the same page repeatedly.
- If you need more data than one API call returns, return what you have and tell the user the tool’s page limit was reached.
- Bounded loops (e.g. for(let i=0; i<items.length; i++)) over local data are fine.
- Be suspicious of round numbers (30, 50, 100) — they usually mean you hit a perPage limit, not the actual total.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
code | string | Yes | — | JavaScript code to execute in the sandbox. The code runs in an async context — use await for async operations. Return a value to send it back to the agent. Example: const collections = await callTool(“datastore-unstructured”, “datastore-unstructured_list_collections”, {}); const csv = collections.collections.map(c => c.name).join(‘\n’); await codeExec.createArtifact(‘collections.csv’, csv, ‘csv’); return { count: collections.collections.length }; |
timeout | number | No | 600000 | Timeout in milliseconds (default: 600000 = 10 minutes, min: 1000 = 1 second, max: 900000 = 15 minutes) |
connectionSelections | object | No | — | Optional mapping of service key to PCID for callTool() connection injection. Use this when the user has multiple connections for the same service and you need to select a specific one. Keys are service names (e.g., “gmail”, “slack”), values are PCIDs obtained from capabilities_discover. When omitted, connections are auto-selected (first connection per service). Code should NOT contain PCIDs — pass them here instead so code remains portable across users. |

