Skip to main content
Glama
DumplingAI

Dumpling AI MCP Server

Official
by DumplingAI

run-js-code

Execute JavaScript code in a sandbox environment to test scripts, process data, or run computations with configurable memory and timeout settings.

Instructions

Execute JavaScript code in a sandbox.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesJavaScript code
commandsNoNPM install commands
parseJsonNoParse output as JSON
timeoutNoExecution timeout in ms
memoryNoMemory allocation in MB

Implementation Reference

  • src/index.ts:989-1015 (registration)
    Registration of the 'run-js-code' tool using server.tool(), including name, description, schema, and handler function.
    server.tool( "run-js-code", "Execute JavaScript code in a sandbox.", { code: z.string().describe("JavaScript code"), commands: z.string().optional().describe("NPM install commands"), parseJson: z.boolean().optional().describe("Parse output as JSON"), timeout: z.number().optional().describe("Execution timeout in ms"), memory: z.number().optional().describe("Memory allocation in MB"), }, async ({ code, commands, parseJson, timeout, memory }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/run-js-code`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ code, commands, parseJson, timeout, memory }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );
  • Handler function that proxies the JavaScript code execution request to an external API endpoint at NWS_API_BASE/api/v1/run-js-code.
    async ({ code, commands, parseJson, timeout, memory }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/run-js-code`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ code, commands, parseJson, timeout, memory }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }
  • Zod schema defining the input parameters for the 'run-js-code' tool.
    { code: z.string().describe("JavaScript code"), commands: z.string().optional().describe("NPM install commands"), parseJson: z.boolean().optional().describe("Parse output as JSON"), timeout: z.number().optional().describe("Execution timeout in ms"), memory: z.number().optional().describe("Memory allocation in MB"), },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DumplingAI/mcp-server-dumplingai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server