mcpField
M
Mcp Code Executor Server

Mcp Code Executor Server

Local
github.com/mouadennaDeveloper Tools2Updated 78w ago

About Mcp Code Executor Server

Mcp Code Executor Server lets AI agents run Java, Python, JavaScript, TypeScript, and C++ code in isolated environments. It compiles selected languages automatically and returns program output and errors through an MCP tool.

Key features

  1. 01Execution in five programming languages
  2. 02Isolated execution with resource limits
  3. 03Automatic compilation for Java, C++, and TypeScript
  4. 04Compile-time and runtime error output
  5. 05Temporary file cleanup and timeouts

Use cases

  1. 01Run code submitted by an AI agent
  2. 02Test snippets across supported languages
  3. 03Inspect compilation and runtime errors

MCP support

The server exposes a code-execution tool to MCP clients. Clients submit a language and code, then receive execution output or errors.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"code-executor-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"build"
]
}
}
}
Run commanddocker run -i --rm build

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
ocibuild

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

MCP Code Executor Server

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


🚀 Overview

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:

  1. Submit code in a supported language.
  2. Execute it in a controlled, sandboxed environment.
  3. Receive output, including compilation or runtime errors.

🔑 Key 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.
  • Resource Cleanup: Automatically deletes temporary files and enforces execution timeouts.

📐 Architecture

The MCP Code Executor Server follows a client-server model:

  • MCP Client: Protocol client that connects to this server.
  • MCP Server: This application, exposing code-execution tools.
  • Sandboxed Runtimes: Containers or isolated processes per request.

Code Execution Architecture


🏁 Getting Started

Prerequisites
  • Java 17+
  • Python 3.8+
  • Node.js & npm
  • g++ or another C++ compiler
Local Setup
  1. Clone the repository:

    git clone https://github.com/yourusername/mcp-code-executor-server.git
    cd mcp-code-executor-server
    
  2. Build & Run:

    # Build the project
    ./mvnw clean package
    
    # Start the server
    ./mvnw spring-boot:run
    

The server listens on port 8080 by default.

Using Docker

For isolation, run in Docker:

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

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

Or with Docker Compose:

docker-compose up -d

🛠️ Connecting MCP Clients

  1. Start your MCP-compatible AI client.
  2. Point it to http://localhost:8080.
  3. Discover and invoke the code-execution tool.

Example MCP request:

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

🤝 Contributing

Contributions are welcome!.


📄 License

Apache License 2.0. See the LICENSE file for details.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.