Get the FREE Ultimate OpenClaw Setup Guide →

mcp-code-executor

dedicated isolated environment for your AI agent

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio mouadenna-mcp-code-executor-server docker run -p 8080:8080 mcp-code-executor \
  --env JAVA_OPTS="Default JVM options" \
  --env SPRING_PROFILES_ACTIVE="production"

How to use

The MCP Code Executor Server provides a unified, MCP-compliant endpoint to execute code across multiple languages in isolated runtimes. It accepts code submissions in supported languages (Java, Python, JavaScript, TypeScript, and C++), runs them inside sandboxed containers with resource limits, and returns both compilation and runtime outputs or errors. Client tools can discover the server and invoke the code-execution capability via the MCP tooling protocol. Typical usage involves sending a request containing the language and code, and receiving a structured response that includes stdout, stderr, and any exit status. This server is designed for AI agents to test or prototype code execution scenarios in a controlled environment, while automatically cleaning up temporary artifacts after each run.

To use the server, point your MCP-compatible client to the provided endpoint (default port 8080). The server exposes a code-execution tool that handles compilation when needed (e.g., Java, C++, TypeScript) and then runs the resulting artifacts. Outputs are captured and returned so agents can reason about results, errors, and execution time. If you’re building complex workflows, you can compose multiple tool invocations (compile, run, and then analyze results) in a single session.

Key capabilities include automatic compilation for Java, C++, and TypeScript, secure sandboxing with resource limits, detailed error feedback (compile-time and runtime), and automatic cleanup of temporary files and containers after each request.

How to install

Prerequisites:

  • Java 17+ installed on the host (or ensure Docker images provide a JRE/JDK runtime)
  • Python 3.8+ (if you intend to run any Python-based tooling outside Docker)
  • Node.js & npm (if you plan to build or test client tooling; not required for the server itself)
  • Docker installed and running (for the recommended containerized deployment)

Installation steps:

  1. Clone the repository

    git clone https://github.com/yourusername/mcp-code-executor-server.git cd mcp-code-executor-server

  2. Build the project (if you prefer running locally without Docker)

    ./mvnw clean package

  3. Run the server locally (without Docker)

    ./mvnw spring-boot:run

    The server listens on port 8080 by default.

  4. Docker deployment (recommended for isolation)

    Build Docker image locally

    docker build -t mcp-code-executor .

    Run the container and expose port 8080

    docker run -p 8080:8080 mcp-code-executor

  5. Optional: Docker Compose

    docker-compose up -d

Prerequisites for Docker-based deployment are already listed; ensure you have network access and appropriate resource limits configured for your environment.

Additional notes

Notes and tips:

  • The server supports multiple languages: Java, Python, JavaScript, TypeScript, and C++. Each request is executed in an isolated environment with resource limits to prevent abuse.
  • If you encounter compilation errors, verify that the correct compiler is installed in the runtime (e.g., g++ for C++, javac for Java).
  • Ensure the MCP client discovers the server at the correct base URL and uses the code-execution tool identifier exposed by the MCP API.
  • When running in Docker, consider adjusting memory limits and CPU shares if you observe timeouts or resource throttling.
  • If you need to pass environment-specific configuration, use the container’s environment variables (e.g., JAVA_OPTS, SPRING_PROFILES_ACTIVE) to tailor behavior.
  • For production deployments, monitor logs and configure proper health checks and restart policies for resilience.

Related MCP Servers

Sponsor this space

Reach thousands of developers