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"),
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'sandbox' which implies isolation and safety, but fails to detail critical aspects like execution limits, error handling, output format, or security constraints. This is inadequate for a code execution tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It is front-loaded with the core action and resource, making it immediately understandable without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool like code execution with 5 parameters and no output schema, the description is insufficient. It lacks details on return values, error conditions, sandbox limitations, and integration with sibling tools, leaving significant gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds no additional semantic context beyond what's in the schema, such as examples or usage notes. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Execute') and resource ('JavaScript code in a sandbox'), making the purpose unambiguous. However, it doesn't explicitly differentiate from its sibling 'run-python-code' beyond the language specification, which is implied but not stated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'run-python-code' or other execution-related tools. It lacks context about appropriate use cases, prerequisites, or exclusions, leaving the agent with minimal direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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