Skip to main content

hackerearth-mcp

License: MIT Python 3.10+ MCP Compatible Version PyPI Stars Tests

Give any AI assistant a code run button.

Unofficial community project. Not made by, endorsed by, or affiliated with HackerEarth. You bring your own free HackerEarth API key.

Why

AI assistants are great at writing code and terrible at knowing whether it works. They guess. This server plugs into any MCP-compatible assistant (Claude Desktop, Claude Code, Cursor, and more) and lets it actually run code in 24 programming languages on HackerEarth's sandboxed servers, then read the real output. No local toolchains to install. Nothing untrusted ever touches your machine.

Tools

Tool Description
run_code Sends code plus a language to HackerEarth, waits for it to run, and returns the printed output and any error messages.
list_languages Lists every language HackerEarth can run, with the exact identifiers to pass to run_code. Takes no inputs.

Quickstart

1. Get a free HackerEarth API key

Register a client in the HackerEarth developer dashboard to receive a client-secret. The free tier includes a generous request quota.

2. Install

No cloning needed:

uvx hackerearth-mcp

or with pip:

pip install hackerearth-mcp

From source instead:

git clone https://github.com/pratham-jain33/hackerearth-mcp
cd hackerearth-mcp
python -m venv .venv
.venv/bin/pip install -e .

3. Connect your assistant

Claude Desktop config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "hackerearth": {
      "command": "uvx",
      "args": ["hackerearth-mcp"],
      "env": {
        "HACKEREARTH_KEY": "paste-your-client-secret-here"
      }
    }
  }
}

From source, point at your checkout instead:

{
  "mcpServers": {
    "hackerearth": {
      "command": "/absolute/path/to/hackerearth-mcp/.venv/bin/python",
      "args": ["/absolute/path/to/hackerearth-mcp/server.py"],
      "env": {
        "HACKEREARTH_KEY": "paste-your-client-secret-here"
      }
    }
  }
}

Restart Claude Desktop, then try: "run this Python program and tell me what it prints: print(6 * 7)"

Configuration

Variable Required Description
HACKEREARTH_KEY Yes Your HackerEarth client-secret. Read from the environment, never hardcoded, never sent to the assistant in chat.

How it works

(This section is written by the project's author.)

  1. You ask the assistant to run some code.
  2. The assistant calls run_code with the code and the language.
  3. The server sends it to HackerEarth with your key and gets back a tracking token.
  4. The server polls HackerEarth until the run finishes.
  5. HackerEarth runs the code in a sealed sandbox on their machines.
  6. The server hands the output back to the assistant, which explains it to you.

Example session

You:    Is this Fibonacci function correct? Run it and show me the first 10 numbers.
        def fib(n):
            a, b = 0, 1
            for _ in range(n):
                print(a, end=" ")
                a, b = b, a + b
        fib(10)

Claude: [calls run_code with your function]
        It works. The output is: 0 1 1 2 3 5 8 13 21 34

Roadmap

  • v0.1 — code submission, status polling, output download, compile/runtime error reporting, 24-language list
  • v0.2 — PyPI packaging, install and run with a single uvx hackerearth-mcp command, server.json for the official MCP registry
  • Submission to the official MCP registry and community directories

Contributing

Issues and pull requests are welcome. If you add a tool, write its description the way you'd explain it to a smart friend who has never seen it — the assistant reads that text to decide when to use it.

License

MIT © Pratham Jain. See LICENSE.

Acknowledgments

Built on HackerEarth's code execution API and the Model Context Protocol. Thanks to HackerEarth for a genuinely developer-friendly free tier.

Release files for hackerearth-mcp 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hackerearth-mcp 0.2.0
File Size Uploaded
hackerearth_mcp-0.2.0.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hackerearth-mcp 0.2.0
File Interpreter ABI Platform
hackerearth_mcp-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / hackerearth_mcp-0.2.0.tar.gz

Download URL hackerearth_mcp-0.2.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2d6d0b3a4c3a6907ecba66f4d04fa502f438e953dc735d6e965d9fbfd57b64f6
BLAKE2b-256 checksum
How to use checksums
964d5b9633ded201b74e1de88325f3572701a526e77b557092c6129b630ab4ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / hackerearth_mcp-0.2.0-py3-none-any.whl

Download URL hackerearth_mcp-0.2.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d441307d97a7614732a70ec0dcb9fa4a462c299fd331dbd03ea171a3c0196571
BLAKE2b-256 checksum
How to use checksums
435befde483bacc795e694db01c6455847ab68fc21ebb3c3016d78eed36152e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.2.2

2 release files

0.2.1

2 release files

This release

0.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page