MCP Code Executor Server logo

MCP Code Executor Server

by mouadenna

A robust Model Context Protocol (MCP) server that enables AI agents to execute code across multiple programming languages in a secure, isolated environment. It standardizes how AI models connect to various programming runtimes by exposing a unified MCP tool endpoint.

View on GitHub

Last updated: N/A

What is MCP Code Executor Server?

The MCP Code Executor Server is an MCP-compliant server that allows AI models to execute code in a secure, sandboxed environment across multiple programming languages. It provides a unified MCP tool endpoint for AI assistants to submit code, execute it, and receive output, including compilation or runtime errors.

How to use MCP Code Executor Server?

To use the server, first ensure you have the prerequisites (Java 17+, Python 3.8+, Node.js & npm, g++). Then, clone the repository, build the project using ./mvnw clean package, and start the server with ./mvnw spring-boot:run. Alternatively, you can use Docker to build and run the server. Finally, point your MCP-compatible AI client to http://localhost:8080 to discover and invoke the code-execution tool.

Key features of MCP Code Executor Server

  • 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

Use cases of MCP Code Executor Server

  • Enabling AI agents to execute code for problem-solving

  • Providing a secure environment for AI to test code snippets

  • Integrating code execution capabilities into AI-powered applications

  • Automating code testing and debugging processes

FAQ from MCP Code Executor Server

What programming languages are supported?

The server supports Java, Python, JavaScript, TypeScript, and C++.

How is code execution secured?

Code is executed in isolated containers with resource limits to prevent malicious code from harming the system.

What is MCP?

MCP stands for Model Context Protocol, a standard for AI models to connect to various tools and services.

How do I connect my AI client to the server?

Point your MCP-compatible AI client to the server's address (e.g., http://localhost:8080) and discover the code-execution tool.

What kind of error feedback is provided?

The server returns both compile-time and runtime error messages to help debug code issues.