mcp-code-executor-server

mouadenna/mcp-code-executor-server

3.1

If you are the rightful owner of mcp-code-executor-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A robust Model Context Protocol (MCP) server that enables AI agents to execute code across multiple programming languages in a secure, isolated environment.

MCP Code Executor Server standardizes how AI models connect to various programming runtimes by exposing a unified MCP tool endpoint. It allows AI assistants to submit code in a supported language, execute it in a controlled, sandboxed environment, and receive output, including compilation or runtime errors. The server supports multiple programming languages and ensures secure execution through isolated containers with resource limits. It integrates seamlessly with MCP clients, providing automatic compilation and detailed error feedback. The architecture follows a client-server model, with sandboxed runtimes for each request, ensuring resource cleanup and execution timeouts.

Features

  • Multi-Language Support: Java, Python, JavaScript, TypeScript, and C++.
  • Secure Execution: Isolated containers with resource limits (CPU, memory, timeouts).
  • MCP Integration: Conformant MCP server for seamless client discovery.
  • Automatic Compilation: Handles compile-and-run for Java, C++, and TypeScript.
  • Detailed Error Feedback: Returns both compile-time and runtime error messages.

Usages

local setup

# Clone the repository
git clone https://github.com/yourusername/mcp-code-executor-server.git
cd mcp-code-executor-server

# Build the project
./mvnw clean package

# Start the server
./mvnw spring-boot:run

docker setup

# Build Docker image
docker build -t mcp-code-executor .

# Run container
docker run -p 8080:8080 mcp-code-executor

docker compose setup

# Run with Docker Compose
docker-compose up -d

mcp client connection

# Example MCP request
{
  "language": "python",
  "code": "print('Hello, world!')\nprint('hello again')"
}