Skip to main content
Glama
ssdeanx

Node.js Sandbox MCP Server

sandbox_stop

Terminate and remove a running Node.js sandbox container to clean up resources after script execution or service completion.

Instructions

Terminate and remove a running sandbox container. Should be called after finishing work in a sandbox initialized with sandbox_initialize.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
container_idYes

Implementation Reference

  • The handler function stopSandbox that terminates and removes the Docker container using 'docker rm -f', updates the activeSandboxContainers registry, handles Docker not running and errors, returning appropriate MCP responses.
    export default async function stopSandbox({
      container_id,
    }: {
      container_id: string;
    }): Promise<McpResponse> {
      if (!isDockerRunning()) {
        return {
          content: [textContent(DOCKER_NOT_RUNNING_ERROR)],
        };
      }
    
      try {
        // Directly use execSync for removing the container as expected by the test
        execSync(`docker rm -f ${container_id}`);
        activeSandboxContainers.delete(container_id);
        // console.log(
        //   `[stopSandbox] Removed container ${container_id} from registry.`
        // );
    
        return {
          content: [textContent(`Container ${container_id} removed.`)],
        };
      } catch (error) {
        // Handle any errors that occur during container removal
        const errorMessage = error instanceof Error ? error.message : String(error);
        console.error(
          `[stopSandbox] Error removing container ${container_id}: ${errorMessage}`
        );
    
        // Still remove from our registry even if Docker command failed
        activeSandboxContainers.delete(container_id);
    
        return {
          content: [
            textContent(
              `Error removing container ${container_id}: ${errorMessage}`
            ),
          ],
        };
      }
    }
  • Zod input schema defining the required 'container_id' string argument.
    export const argSchema = { container_id: z.string() };
  • src/server.ts:75-80 (registration)
    Registration of the 'sandbox_stop' tool on the MCP server, specifying name, description, input schema (stopSchema), and handler (stopSandbox).
    server.tool(
      'sandbox_stop',
      'Terminate and remove a running sandbox container. Should be called after finishing work in a sandbox initialized with sandbox_initialize.',
      stopSchema,
      stopSandbox
    );
Behavior3/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 clearly indicates destructive behavior ('Terminate and remove'), which is helpful. However, it lacks details on potential side effects (e.g., data loss, cleanup processes), error conditions, or confirmation requirements, leaving gaps for a mutation 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 two sentences with zero waste—each sentence adds critical information (action and usage context). It is appropriately sized and front-loaded with the core purpose, making it highly efficient.

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

Completeness4/5

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

Given the tool's complexity (destructive operation with one parameter), no annotations, and no output schema, the description is reasonably complete. It covers purpose and usage well but could improve by addressing behavioral aspects like data persistence or error handling, which are relevant for a cleanup tool.

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

Parameters4/5

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

The schema has 0% description coverage, so the description must compensate. It doesn't explicitly mention the 'container_id' parameter, but the context ('a running sandbox container') implicitly clarifies what this parameter refers to. Since there's only one parameter, the baseline is high, but the lack of explicit parameter discussion slightly reduces the score.

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

Purpose5/5

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

The description clearly states the specific action ('Terminate and remove') and resource ('a running sandbox container'), distinguishing it from sibling tools like sandbox_initialize and sandbox_exec. It precisely defines what the tool does without being vague or tautological.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool ('after finishing work in a sandbox initialized with sandbox_initialize') and implies when not to use it (e.g., while still working in the sandbox). It provides clear context and references a specific alternative/sibling tool for setup.

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