Skip to main content
Server path: /restricted/code-execution | Type: Embedded | PCID required: No Run JavaScript in a sandboxed Node.js VM with access to MCP tools, artifact creation, and artifact reading. For a guided walkthrough, see the Code Execution guide.

Tools

ToolDescription
code-execution_executeExecute JavaScript code in a sandboxed environment

code-execution_execute

Execute JavaScript code with access to MCP tools, artifact reading, and artifact creation. Code is wrapped in an async function — use await and return directly. Available functions inside the sandbox:
FunctionDescription
callTool(serverPath, toolName, args)Call any MCP tool. serverPath is the endpoint path (e.g. "/gmail"), toolName is the full tool name (e.g. "gmail_search_emails"). External integrations require a PCID in args.
readArtifact(identifier)Read an existing artifact by file ID, filename, or URL. Returns { success, content, size, filename, mimeType, error }.
createArtifact(filename, content, fileType)Create a new artifact file. fileType is one of: csv, json, txt, md, html, js, ts, py, xml. Returns { success, filename, url, id, mimeType, size, error }. Requires X-Chat-Id header on the request.
console.log() / warn() / error()Debug output, captured in the logs array.
setTimeout / setIntervalTimer functions (cleaned up after execution).
Parameters:
ParameterTypeRequiredDescription
codestringYesJavaScript code to execute. Should be a function body that returns a value.
timeoutnumberNoTimeout in milliseconds. Default: 600000 (10 min). Max: 900000 (15 min).
Response fields:
FieldTypeDescription
resultanyWhatever the code returns
executionTimenumberExecution time in milliseconds
logsstring[]Console output (only present if non-empty)
createdArtifactsobject[]Files created with createArtifact() (only present if non-empty)
Example:
curl -s -X POST "https://mcp.app.pinkfish.ai/restricted/code-execution" \
  -H "Authorization: Bearer $PINKFISH_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "code-execution_execute",
      "arguments": {
        "code": "return { message: \"hello world\", timestamp: new Date().toISOString() };"
      }
    },
    "id": 1
  }'
Response:
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "structuredContent": {
      "result": {
        "message": "hello world",
        "timestamp": "2026-02-15T07:30:00.000Z"
      },
      "executionTime": 12
    }
  }
}