Harpy 🦅
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.
✨ Features
- 📑 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.
🚀 Quickstart
1. Installation
Option A: 1-Command Installer (Recommended — Zero Python needed, auto-configures PATH)
-
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
Option B: Via pip
pip install harpy-cp
Note: 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
2. Configure AI & Shell Completion (1-Command Setup)
# Auto-installs Antigravity skill & registers Harpy MCP server
harpy setup-ai
# Enable fast tab-completion for problem slugs and solutions
harpy completion install
3. Uninstallation
If 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
💻 CLI Usage
Initialize a DSA Workspace
In any folder where you want to practice problems (e.g. ~/dsa-prep):
mkdir -p ~/dsa-prep && cd ~/dsa-prep
harpy init
What harpy init sets up:
- Scaffolds a
problems/directory. - Configures
.tabignoreand.antigravityignoreso inline ghost AI suggestions don't distract you while solving problems.
Create & Scaffold Problems (1-Command Setup)
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"
Synthesize Additional Tests / Stress Test
# 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
Test Solutions Locally
# Auto-resolves problem slugs and files inside problems/
harpy test lexicographically-minimal-walk
# Or direct file paths
harpy test problems/two-sum/solution.cpp
Output:
⚡ 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 to CPH Extension
Push problem metadata and test cases to your active CPH listener in VS Code or Antigravity:
harpy push problems/maximum-subarray-sum
🛠️ IDE Setup Guide
Harpy 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 Compatibility Matrix
| 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) | ✔ | ✔ |
1. VS Code
CPH Extension Setup
- 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.
AI Assistant (Roo Code / Cline / GitHub Copilot Chat)
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"]
}
}
}
2. Google Antigravity IDE
Harpy has first-class native integration with Antigravity:
- Run the one-command installer:
harpy setup-aiThis automatically:- 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
3. Cursor
- 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`.
4. Windsurf (Codeium)
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.
5. Claude Desktop
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"]
}
}
}
6. Zed Editor
Zed supports context servers via ~/.config/zed/settings.json:
{
"context_servers": {
"harpy": {
"command": {
"path": "python3",
"args": ["-m", "harpy.mcp_server"]
}
}
}
}
7. Neovim & Terminal-First Workflow
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>
📁 Problem Structure
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.
🧪 Development & Testing
Run unit tests:
pytest -v
Build standalone package:
python3 -m build
📄 License
This project is licensed under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file harpy_cp-0.1.5.tar.gz.
File metadata
- Download URL: harpy_cp-0.1.5.tar.gz
- Upload date:
- Size: 43.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f96c10bc9c848b0b2c6c3466de7785250576d72bc2adbe810c2bcd5fda74132
|
|
| MD5 |
4d4e1dabecd81c3e143a470c046c9e7c
|
|
| BLAKE2b-256 |
ffe984edd4aa954abbc4431e5081fbf282cc3b63b308ba41bae57ac10de74ba5
|
Provenance
The following attestation bundles were made for harpy_cp-0.1.5.tar.gz:
Publisher:
release.yml on Seronic2001/harpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
harpy_cp-0.1.5.tar.gz -
Subject digest:
4f96c10bc9c848b0b2c6c3466de7785250576d72bc2adbe810c2bcd5fda74132 - Sigstore transparency entry: 2830085326
- Sigstore integration time:
-
Permalink:
Seronic2001/harpy@36b887de1f45e8a7478e9a0a0bdb75615715dc50 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/Seronic2001
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@36b887de1f45e8a7478e9a0a0bdb75615715dc50 -
Trigger Event:
push
-
Statement type:
File details
Details for the file harpy_cp-0.1.5-py3-none-any.whl.
File metadata
- Download URL: harpy_cp-0.1.5-py3-none-any.whl
- Upload date:
- Size: 36.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a7740975f2c3481e877711cb0594b8a16835060c74fe5a3e2e349d6b9ceb4cb
|
|
| MD5 |
aaaa4baa0fb098fff011eb7113b6a9ce
|
|
| BLAKE2b-256 |
d818688d8eea6ac9b1b06fbb1edb7297d01ac5dfecadcd23b69ad2d629e34d81
|
Provenance
The following attestation bundles were made for harpy_cp-0.1.5-py3-none-any.whl:
Publisher:
release.yml on Seronic2001/harpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
harpy_cp-0.1.5-py3-none-any.whl -
Subject digest:
8a7740975f2c3481e877711cb0594b8a16835060c74fe5a3e2e349d6b9ceb4cb - Sigstore transparency entry: 2830085367
- Sigstore integration time:
-
Permalink:
Seronic2001/harpy@36b887de1f45e8a7478e9a0a0bdb75615715dc50 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/Seronic2001
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@36b887de1f45e8a7478e9a0a0bdb75615715dc50 -
Trigger Event:
push
-
Statement type: