Skip to main content
Glama
ssdeanx

Node.js Sandbox MCP Server

sandbox_exec

Execute shell commands within an isolated Node.js sandbox container to run code or manage dependencies securely with controlled resource limits.

Instructions

Execute one or more shell commands inside a running sandbox container. Requires a sandbox initialized beforehand.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandsYes
container_idYes

Implementation Reference

  • The handler function that executes one or more shell commands inside a running sandbox Docker container using docker exec.
    export default async function execInSandbox({
      container_id,
      commands,
    }: {
      container_id: string;
      commands: string[];
    }): Promise<McpResponse> {
      if (!isDockerRunning()) {
        return {
          content: [textContent(DOCKER_NOT_RUNNING_ERROR)],
        };
      }
    
      const output: string[] = [];
      for (const cmd of commands) {
        output.push(
          execSync(
            `docker exec ${container_id} /bin/sh -c ${JSON.stringify(cmd)}`,
            {
              encoding: 'utf8',
            }
          )
        );
      }
      return { content: [textContent(output.join('\n'))] };
    }
  • Zod schema for input validation: container_id (string) and commands (array of non-empty strings).
    export const argSchema = {
      container_id: z.string(),
      commands: z.array(z.string().min(1)),
    };
  • src/server.ts:58-63 (registration)
    Registers the sandbox_exec tool with the MCP server, providing name, description, schema (execSchema), and handler (execInSandbox).
    server.tool(
      'sandbox_exec',
      'Execute one or more shell commands inside a running sandbox container. Requires a sandbox initialized beforehand.',
      execSchema,
      execInSandbox
    );
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the prerequisite. It lacks details on behavioral traits such as execution environment, error handling, output format, or security implications (e.g., destructive potential of shell commands). This is a significant gap for a tool that executes commands.

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 two sentences, front-loaded with the core action, and every word earns its place without redundancy. It's efficiently structured and appropriately sized for the tool's complexity.

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?

Given the complexity of executing shell commands in a container, no annotations, and no output schema, the description is incomplete. It misses critical details like what the tool returns, how errors are handled, or execution limits. This inadequately supports an AI agent in using the tool effectively.

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 0%, so the description must compensate, but it doesn't explain parameters beyond what the schema implies. It mentions 'shell commands' and 'sandbox container', which loosely map to 'commands' and 'container_id', but adds no syntax, format, or constraints. Baseline 3 is appropriate as the schema defines parameters clearly.

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 action ('Execute shell commands') and the target ('inside a running sandbox container'), which is specific and actionable. It distinguishes from siblings like 'sandbox_initialize' by focusing on execution rather than setup, though it doesn't explicitly contrast with 'run_js' tools.

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

Usage Guidelines4/5

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

It provides clear context by stating 'Requires a sandbox initialized beforehand', which implicitly guides when to use this tool versus 'sandbox_initialize'. However, it doesn't explicitly mention alternatives like 'run_js' for non-shell commands or exclusions for when not to use it.

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/ssdeanx/node-code-sandbox-mcp'

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