Skip to main content
Glama

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 );

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