Skip to main content
Glama

Node Code Sandbox MCP

by mozicim
exec.ts861 B
import { z } from 'zod'; import { execSync } from 'node:child_process'; import { type McpResponse, textContent } from '../types.ts'; import { DOCKER_NOT_RUNNING_ERROR, isDockerRunning } from '../utils.ts'; export const argSchema = { container_id: z.string(), commands: z.array(z.string().min(1)), }; 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'))] }; }

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

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