CharlieKerfoot/code-execution-mcp
If you are the rightful owner of code-execution-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Model Context Protocol (MCP) server that enables AI models to execute code in various programming languages using a secure, remote environment.
Code Executer MCP
A Model Context Protocol (MCP) server which allows AI models to run code. The user prompts the model with code of a specified language and the model will execute it, displaying the stdout, stderr, and exit code.
Implementation
The server uses the piston api to execute code in a secure, remote enviornment and then returns the output to the AI model.
Information on MCP servers and how to implement them can be found here.
Installation
This MCP was used and tested with Claude for Desktop, but it should work for other LLMs and AI tools. This guide will only cover Claude Desktop though.
-
Clone the repo
-
Install the dependencies
npm i
- Run
npm run build
-
After installing Claude for Desktop, open the file
~/Library/Application Support/Claude/claude_desktop_config.json -
Paste the following JSON
{
"mcpServers": {
"code_execution": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/PARENT/FOLDER/code-execution-mcp/build/index.js"]
}
}
}
- Save the file and launch Claude.
There should be a slider icon under the prompt bar. When clicked, the code_exection MCP should be toggleable.
Usage
Try using the MCP with prompts like
run this python code:
import random
print("Random Numbers:", [random.randint(1, 100) for _ in range(5)])
print("Random Choice:", random.choice(['apple', 'banana', 'cherry', 'date']))
print("Random Float:", round(random.random() * 100, 2))
for i in range(3):
print(f"Line {i+1}: {'*' * random.randint(3, 10)}")
print("Done!")
or
Generate random C code (that prints to the stdout) and run it