HUB
Sign inSign up
code-execution-mcp logo

hackerdogs/code-execution-mcp

By hackerdogs

•Updated 5 months ago

Code Execution MCP Server

Image
0

682

hackerdogs/code-execution-mcp repository overview

Hackerdogs
hackerdogs ⁠

⁠Code Execution MCP Server

MCP server wrapper for Code Execution — execute Python snippets in a sandboxed subprocess and return stdout, stderr, and exit code.

⁠What is Code Execution?

Code Execution is a self-contained Python sandbox that runs user-supplied code in a temporary directory subprocess with no outbound network access and no persistent filesystem writes. It returns structured JSON with stdout, stderr, and exit_code and enforces a configurable timeout (default 30 s, max 120 s).

No API keys required — Code Execution runs entirely inside the Docker container.

Tools:

  • run_python — Execute a Python code string in a sandboxed subprocess with an optional timeout_seconds parameter.

⁠Tools Reference

⁠run_python

Execute Python code in a sandboxed subprocess and return structured output.

ParameterTypeRequiredDefaultDescription
codestringYes—Python source code to execute
timeout_secondsintegerNo30Max seconds to allow (1–120)

⁠Example Prompts

Here are example prompts you can use with Claude (or any MCP client) when this tool is connected:

  • "Run this Python snippet and show me the output: import math; print(math.sqrt(144))"
  • "Execute the following data-parsing script and return stdout and stderr."
  • "Run a Python script that reads a CSV string and computes column averages."
  • "Use the code execution sandbox to test this regular expression against sample input."
  • "Run this Python function and tell me the exit code and any error messages."
  • "Execute a quick benchmark loop in Python and report elapsed time."

⁠Deploy

docker-compose up -d
⁠Docker Run (stdio mode)
docker run -i --rm hackerdogs/code-execution-mcp:latest
⁠Docker Run (HTTP streamable mode)
docker run -d -p 8376:8376 \
  -e MCP_TRANSPORT=streamable-http \
  -e MCP_PORT=8376 \
  hackerdogs/code-execution-mcp:latest

⁠MCP Client Configuration

⁠Stdio mode (default)

Add to your Claude Desktop or Cursor MCP config:

{
  "mcpServers": {
    "code-execution-mcp": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT", "hackerdogs/code-execution-mcp:latest"],
      "env": {
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}
⁠HTTP mode (streamable-http)

First, start the server using Docker Compose or docker run with HTTP mode (see Deploy⁠ above), then point your MCP client at the running server:

{
  "mcpServers": {
    "code-execution-mcp": {
      "url": "http://localhost:8376/mcp"
    }
  }
}

When to use HTTP mode: HTTP mode is ideal for shared/remote deployments, multi-user setups, and Hackerdogs⁠ scheduled prompts. The server runs as a long-lived process and accepts connections from multiple MCP clients concurrently.

⁠Environment Variables

VariableDefaultDescription
MCP_TRANSPORTstdioTransport mode: stdio or streamable-http
MCP_PORT8376HTTP port (only used with streamable-http)

⁠Installing in Hackerdogs

The fastest way to get started is through Hackerdogs⁠:

  1. Log in to your Hackerdogs account.
  2. Go to the Tools Catalog.
  3. Search for the tool by name (e.g. "nuclei", "naabu", "julius").
  4. Expand the tool card and click Install — you're ready to go.

Give it a couple of minutes to go live. Then start querying by asking Hackerdogs to use the tool explicitly (e.g. "Use naabu to scan example.com"). If you don't specify, Hackerdogs will automatically choose the best tool for the job — it may choose this one on its own.

  1. Vendor API key required? Add your key in the config environment variable field before clicking Install. Your key will be encrypted at rest.
  2. Enable / Disable the tool anytime from the Enabled Tools page.
  3. Need to update a key or parameter? Go to My Tools → toggle Show Decrypted Values → edit → Save.

Want to contribute or chat with the team? Join our Discord⁠.

⁠Build

docker build -t hackerdogs/code-execution-mcp:latest .

⁠Testing

⁠Automated tests
./test.sh
⁠Test directly with Docker

1. Start the server in HTTP mode:

docker run -d --rm --name code-execution-mcp-test -p 8376:8376 \
  -e MCP_TRANSPORT=streamable-http \
  hackerdogs/code-execution-mcp:latest

2. Initialize the MCP session:

SESSION_ID=$(curl -s -D - -X POST http://localhost:8376/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"0.1"}}}' \
  2>&1 | grep -i mcp-session-id | awk '{print $2}' | tr -d '\r\n')

curl -s -X POST http://localhost:8376/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "mcp-session-id: $SESSION_ID" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'

3. Call a tool:

curl -s -X POST http://localhost:8376/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "mcp-session-id: $SESSION_ID" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"run_code_execution","arguments":{"arguments":"--help"}}}'

4. Clean up:

docker stop code-execution-mcp-test

⁠Running the tool directly (bypassing MCP)

You can run the Code Execution CLI in the same container by overriding the entrypoint without starting the MCP server.

Show help:

docker run -i --rm --entrypoint code-execution hackerdogs/code-execution-mcp:latest --help

Tag summary

Content type

Image

Digest

sha256:9c3e97109…

Size

74.8 MB

Last updated

5 months ago

docker pull hackerdogs/code-execution-mcp