Skip to main content
Glama

CodeChef Contest MCP Server

An AI-powered competitive programming assistant implementing the Model Context Protocol (MCP). This server allows AI agents (like Claude Desktop or Cursor) to participate in CodeChef contests: fetching problems, generating/testing solutions in a secure sandbox, managing retry states, submitting answers, and tracking contest progress.


πŸš€ Features

  • Contest Management: Open contests, retrieve problem lists, and track solved vs. remaining problems.

  • Browser Automation: Playwright-based logins, problem-statement scraping, submission uploads, and verdict polling.

  • Secure Sandbox: Docker-isolated compilation and execution (supports C++, Python, Java, Go, Rust) with no internet access, limited CPU/memory, and execution timeouts.

  • Validation & Retry: Custom edge-case generator, confidence evaluator, and self-repair engine to analyze verdicts and repair failing solutions iteratively.


Related MCP server: Online Judge MCP Server

πŸ“‚ Project Structure

MCP_Chef/
β”‚
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ browser/       # Playwright-based browser automation (login, submit, poll)
β”‚   β”œβ”€β”€ models/        # SQLAlchemy database schema (SQLite)
β”‚   β”œβ”€β”€ retry_engine/  # Diagnosis & self-repair pipeline
β”‚   β”œβ”€β”€ sandbox/       # Secure Docker runner configuration & language setup
β”‚   β”œβ”€β”€ solver/        # Sequential contest solver state (Q1 β†’ Q5)
β”‚   β”œβ”€β”€ tools/         # Exposed MCP tool decorators
β”‚   β”œβ”€β”€ utils/         # Structured logger and cache layer
β”‚   β”œβ”€β”€ main.py        # Streamable HTTP ASGI app
β”‚   └── mcp_server.py  # FastMCP server instantiation
β”‚
β”œβ”€β”€ tests/             # Automated test suite
β”œβ”€β”€ Dockerfile         # Multi-stage container definition
β”œβ”€β”€ docker-compose.yml # Compose configuration (App, Redis)
β”œβ”€β”€ run_server.py      # Unified server CLI entrypoint (STDIO & HTTP)
└── .env               # Local configuration file (not tracked in Git)

πŸ› οΈ Local Setup

Prerequisites

  • Python 3.10+

  • Docker (Required for sandbox execution)

  • Node.js (Optional, for localtunnel testing)

Step 1: Install Dependencies

Create a virtual environment and install dependencies:

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
playwright install chromium

Step 2: Configure Environment

Copy the example environment file and add your CodeChef credentials:

cp .env.example .env

Open .env and set your CodeChef username and password.

Step 3: Run Tests

Verify your local installation:

python -m pytest tests/ -v

πŸ’» Running the Server

1. STDIO Transport (For Claude Desktop)

To run the server locally over Standard Input/Output:

python run_server.py

Add the configuration to your Claude Desktop config (e.g., ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "codechef": {
      "command": "/Users/ayushkumarsingh/Downloads/MCP_Chef/venv/bin/python",
      "args": ["/Users/ayushkumarsingh/Downloads/MCP_Chef/run_server.py"]
    }
  }
}

2. HTTP Transport (For Cursor/Web Clients)

To run the server over HTTP/SSE:

python run_server.py --http --port 8000

Then configure your client to connect to: http://localhost:8000/mcp


☁️ Deployment

We have configured deployment setups for both container and VM platforms:

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to execute C++ code, test solutions against multiple test cases, analyze performance, and generate test cases using OnlineGDB's online compiler. Perfect for solving competitive programming problems with iterative self-correction capabilities.
      2
      MIT
    • F
      license
      A
      quality
      C
      maintenance
      Enables coding agents to discover unsolved Codeforces practice problems, analyze tag performance, and inspect submissions, profiles, rating history, and upcoming contests through MCP-compatible clients.
      6
      -
    • A
      license
      A
      quality
      B
      maintenance
      Connects AI assistants to the Repovive competitive-programming platform, enabling them to browse problems and contests, judge and submit code for real verdicts, track ratings, communicate with users, and author verified problems and rounds.
      102
      MIT