A CLI toolkit and Model Context Protocol (MCP) server for competitive programming. Converts problem statements into decoupled C++ templates, runs brute-force differential testing to eliminate AI test-case hallucination, and synchronizes test cases directly with CPH and local compilers.
- π Decoupled Code Templates: Converts problem descriptions into clean, typed
solve(...)function templates with fast I/O inmain(), separating I/O parsing from core algorithmic logic. - β‘ Instant Scaffolding & Background Test Synthesis: Scaffolds starter code, problem specifications, and CPH files in
<200ms, while synthesizing and verifying edge/stress test cases in the background via detached processes (--async). - π― Brute-Force Differential Testing & Batch Oracle: Eliminates AI test-case hallucination. Runs a simple brute-force Python script locally across edge cases, boundary conditions (
$N=0, 1$ , negative numbers), and randomized stress tests to generate 100% verified expected outputs in a single batched process. - β‘ Competitive Programming Helper (CPH) Sync:
- Live HTTP dispatch to VS Code / Antigravity CPH extension on port
27121. - Generates native
.cph/.probfiles directly for offline use.
- Live HTTP dispatch to VS Code / Antigravity CPH extension on port
- π§ͺ Fast Local Test Runner (
harpy test):- Compiles C++ (
g++ -O3 -std=c++17), Python, and Java. - Formats results with color-coded tables, execution time, and side-by-side failure diffs.
- Compiles C++ (
- π€ Universal Model Context Protocol (MCP) Server:
- Exposes deterministic tools (
setup_problem,oracle_generate_tests,sync_cph,test_solution) for coding agents in VS Code, Antigravity, Cursor, Windsurf, Claude Desktop, and Zed.
- Exposes deterministic tools (
- π Distraction-Free Workspace: Auto-configures
.tabignoreto silence intrusive inline AI autocomplete while you code algorithms.
-
Linux & macOS:
curl -fsSL https://raw.githubusercontent.com/Seronic2001/harpy/master/install.sh | bash -
Windows (PowerShell):
irm https://raw.githubusercontent.com/Seronic2001/harpy/master/install.ps1 | iex
pip install harpy-cpNote: If
harpyis not recognized immediately in your terminal due to PATH settings, you can run any Harpy command directly using:python -m harpy setup-ai # or 'py -m harpy setup-ai' on Windows
To upgrade Harpy:
pip install --upgrade harpy-cp# Auto-installs Antigravity skill & registers Harpy MCP server
harpy setup-ai
# Enable fast tab-completion for problem slugs and solutions
harpy completion installIf you ever need to remove Harpy:
-
Linux & macOS:
curl -fsSL https://raw.githubusercontent.com/Seronic2001/harpy/master/uninstall.sh | bash -
Windows (PowerShell):
irm https://raw.githubusercontent.com/Seronic2001/harpy/master/uninstall.ps1 | iex
-
Via pip:
pip uninstall harpy-cp
In any folder where you want to practice problems (e.g. ~/dsa-prep):
mkdir -p ~/dsa-prep && cd ~/dsa-prep
harpy initWhat harpy init sets up:
- Scaffolds a
problems/directory. - Configures
.tabignoreand.antigravityignoreso inline ghost AI suggestions don't distract you while solving problems.
Create a categorized problem workspace, run reference oracle test verification, and sync to CPH in a single command:
# Instant scaffolding (<0.2s) with detached background test synthesis
harpy create -s spec.json --async
# Or wait synchronously for test generation and verification
harpy create -s spec.json --sync
# Or pipe specification directly via stdin
cat spec.json | harpy create - --async
# Quick flag-based setup
harpy create --title "Two Sum" --category "sorting-and-searching" --difficulty "Easy"# Run algorithmic test generator and verify with reference oracle
harpy generate-tests problems/two-sum
# Or run in the background with alias
harpy stress problems/two-sum -b# Auto-resolves problem slugs and files inside problems/
harpy test lexicographically-minimal-walk
# Or direct file paths
harpy test problems/two-sum/solution.cppOutput:
β‘ Harpy Test Runner: Testing solution.cpp (cpp)
Test Results
ββββββββββ³βββββββββ³βββββββββ³βββββββββ
β Case # β Type β Status β Time β
β‘ββββββββββββββββββββββββββββββββββββ©
β 01 β sample β β PASS β 2.7 ms β
β 02 β sample β β PASS β 3.0 ms β
β 03 β edge β β PASS β 2.9 ms β
β 04 β stress β β PASS β 5.1 ms β
ββββββββββ΄βββββββββ΄βββββββββ΄βββββββββ
β¨ All 4 test cases passed!
Push problem metadata and test cases to your active CPH listener in VS Code or Antigravity:
harpy push problems/maximum-subarray-sumHarpy connects to any editor via two open standards:
- Model Context Protocol (MCP): Lets AI assistants formulate problems, run brute-force differential testing, and execute test runners.
- CPH Protocol &
.cph/Files: Integrates directly with the Competitive Programming Helper extension.
| IDE / Editor | AI Assistant (MCP) | CPH GUI Test Runner | Integrated CLI | Autocomplete Mute (.tabignore) |
|---|---|---|---|---|
| VS Code | β (Roo Code / Cline / Copilot) | β (CPH Extension) | β | β |
| Google Antigravity | β (Native 1-Command) | β (CPH Extension) | β | β |
| Cursor | β (Native Composer MCP) | β (CPH via Open VSX/Marketplace) | β | β |
| Windsurf | β (Native Cascade MCP) | β (CPH Extension) | β | β |
| Zed | β (Context Servers) | β (Uses CLI harpy test) |
β | β |
| Claude Desktop | β (Native MCP) | β (Uses CLI harpy test) |
β | β |
| Neovim / JetBrains | β (Terminal / LLM plugins) | β (Competitive Companion / CLI) | β | β |
- Install the Competitive Programming Helper (cph) extension from the VS Code Marketplace:
ext install divyanshuaggarwal.competitive-programming-helper - When you push a problem using
harpy push <slug>, it opens directly in the CPH sidebar with all test cases preloaded. - Offline support: Harpy automatically creates
.cph/.<slug>.cpp_<hash>.probfiles so tests load even without an active network connection.
Add Harpy to your MCP settings file (e.g. cline_mcp_settings.json or .vscode/mcp.json):
{
"mcpServers": {
"harpy": {
"command": "python3",
"args": ["-m", "harpy.mcp_server"]
}
}
}Harpy has first-class native integration with Antigravity:
- Run the one-command installer:
This automatically:
harpy setup-ai
- Registers the MCP server in
~/.gemini/config/mcp_config.json. - Installs the multimodal
harpy-cpskill globally in~/.gemini/config/skills/harpy-cp/SKILL.md.
- Registers the MCP server in
- Open any folder (
harpy init), drop a screenshot of a problem or contest into chat, and say:"Set this problem up."
- Antigravity automatically:
- Formulates
problem.md. - Writes
<slug>.cppwith typed LeetCodesolve(...)signature. - Runs the brute-force Python script to verify sample, edge, and stress cases.
- Syncs with CPH and gives you a clickable file link to your code.
- Formulates
- Open Cursor Settings (
Cmd+,orCtrl+,) β Features β MCP. - Click + Add New MCP Server:
- Name:
harpy - Type:
command - Command:
python3 -m harpy.mcp_server
- Name:
- Alternatively, create a
.cursor/mcp.jsonfile in your workspace:{ "mcpServers": { "harpy": { "command": "python3", "args": ["-m", "harpy.mcp_server"] } } } - Add to your
.cursorrules(optional, for optimal prompt alignment):When asked to set up a competitive programming or algorithm problem: 1. Use the `harpy_setup_problem` tool. 2. Leave the body of `solve(...)` empty for the user with pre-filled typed parameters from `main()`. 3. Write a brute-force Python script and use `harpy_oracle_generate_tests`. 4. Sync to CPH using `harpy_sync_cph`.
Windsurf supports MCP via Cascade:
- Open or create
~/.codeium/windsurf/mcp_config.json(or workspace.windsurf/mcp.json):{ "mcpServers": { "harpy": { "command": "python3", "args": ["-m", "harpy.mcp_server"] } } } - Restart Cascade. Harpy tools will appear with a green indicator in the tools list.
In ~/.config/Claude/claude_desktop_config.json (Linux/macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"harpy": {
"command": "python3",
"args": ["-m", "harpy.mcp_server"]
}
}
}Zed supports context servers via ~/.config/zed/settings.json:
{
"context_servers": {
"harpy": {
"command": {
"path": "python3",
"args": ["-m", "harpy.mcp_server"]
}
}
}
}For Neovim, tmux, and terminal-first users:
- Interactive Testing: Run
harpy test <slug>in a side tmux pane, floating terminal, or Neovim terminal (:terminal harpy test <slug>). - Watch Mode: Use with
entrornodemonto automatically test whenever you save your solution:ls problems/<slug>/*.cpp | entr -c harpy test <slug>
- Tab Completion: Auto-completes subcommands, problem slugs, and solution files:
harpy test lexi<TAB>
Harpy automatically organizes problems by algorithmic topic into standard CSES category subfolders:
problems/<category>/<slug>/
βββ problem.md # LeetCode-style specification with LaTeX constraints
βββ problem.json # Structured problem metadata & test cases
βββ <slug>.cpp # Starter template with pre-filled typed solve(...)
βββ tests/
β βββ in_01.txt # Input for test case 1
β βββ out_01.txt # Verified expected output for test case 1
β βββ ...
βββ .cph/
βββ .<slug>.cpp_<hash>.prob # Native CPH offline test file
Supported CSES categories include dynamic-programming, graph-algorithms, tree-algorithms, sorting-and-searching, greedy-algorithms, range-queries, mathematics, string-algorithms, geometry, bit-manipulation, introductory-problems, and advanced-techniques.
Run unit tests:
pytest -vBuild standalone package:
python3 -m buildThis project is licensed under the MIT License.