loading…
Search for a command to run...
loading…
Enables AI-assisted clan analysis for Clash of Clans by reading official API data and applying customizable rubrics for war grading, promotion screening, and ca
Enables AI-assisted clan analysis for Clash of Clans by reading official API data and applying customizable rubrics for war grading, promotion screening, and carry-forward decisions.
A Model Context Protocol (MCP) server that lets Claude (or any MCP client) read your clan's data from the official Clash of Clans API and apply your clan's own rules to it — for war grading, elder promotion screening, and CWL carry-forward decisions.
Built for clan leaders who want AI-assisted clan analysis with reproducible, configurable rules.
Keywords: Clash of Clans, MCP, Model Context Protocol, Claude, Claude Desktop, clan war, CWL, Clan War League, clan management, elder promotion, war analysis, Supercell API.
Once connected to Claude Desktop (or another MCP client), you can ask things like:
"How did our last war go? Who didn't follow the rules?"
"Should I promote ankit176 to Elder? What's our policy bar?"
"Pull together a CWL carry-forward recommendation for next season."
"Who in the clan has the highest donation ratio this season?"
"Pull our capital raid loot for the last 5 weekends."
The MCP turns each question into the right API calls, applies your configurable rubric (in JSON, edit freely), and returns a leadership-ready answer.
After you run it on a finished war, you get something like:
# War Report — vs clash serious (Defeat)
Total attacks used: 26 · Missed: 4 · Avg ⭐/attack: 2.27 · Avg destruction: 83%
## 1. Attack Participation (2/2 expected)
- Used both attacks (12): Justin (#1), Slayer7 (#2), TURBO (#3), ...
- Used only 1 of 2 (2): M@NJ!T (#4), Laeo_Lol XD (#11)
- 🚨 Did not attack (1): Punjabi Pete (#15)
## 2. Rule Compliance
- Clean (3): Justin (#1), aNkiT (#6), joe (#10)
- Violations (12):
- Slayer7 (#2, TH18): 2nd attack didn't 3⭐ and only hit 80%
- M@NJ!T (#4, TH18): 1st attack hit base #10 (offset +6); rule = mirror or one down
- ankit176 (#8, TH17): 2nd attack target offset -3 (should hit lower bases for smart 3⭐)
- ...
## 3. Performance Leaderboard
| Rank | Name | Pos | TH | ⭐ Earned | Avg Dest % | Score | Grade |
| 1 | Justin | #1 | TH18 | 6 | 100% | 23 | A |
| 2 | Corrupt | #5 | TH17 | 6 | 100% | 20 | A |
...
## 4. Smart-Attack Honor Roll (clean 3⭐ on lower base)
- Justin (#1) → hit base #2 for 3⭐ 100%
- Corrupt (#5) → hit base #9 for 3⭐ 100%
API wrappers (read-only):
| Tool | Purpose |
|---|---|
clash_get_clan |
Clan-level details (name, level, war league, members count) |
clash_get_clan_members |
Roster with role, donations, war stars, trophies |
clash_get_warlog |
Past wars (summary only — see limitations) |
clash_get_current_war |
Current regular war with full per-attack data |
clash_get_cwl_group |
Current CWL group + war tags per round |
clash_get_cwl_war |
Individual CWL war by tag |
clash_get_player |
Player profile (heroes, troops, war stars, current clan) |
clash_api_get |
Generic GET passthrough for any endpoint not wrapped above (gold pass, capital raids, leagues, locations, clan search, etc.) |
Workflow tools (the leverage):
| Tool | Purpose |
|---|---|
clash_grade_war |
Apply your rubric to a war's attacks → per-player grades, scores, rule violations |
clash_war_report |
Markdown post-mortem answering: who attacked, who followed rules, performance leaderboard, smart-attack honor roll, and missed opportunities |
clash_missed_opportunities |
For each attack, check if a weaker undefeated base was sitting there at the time. The deeper version of the smart-attack rule. |
clash_carry_forward_recommendation |
Analyze all CWL rounds → keep / review / bench list for next season |
clash_promotion_candidates |
Screen Members against your elder bar (donation ratio, hero progress, war contribution) |
clash_snapshot_war |
Save current war (regular + CWL rounds) to local disk. Idempotent. Designed to run on a schedule. |
clash_snapshot_status |
Show what's in the snapshot store + identify gaps vs the warlog |
clash_player_war_history |
Pull a player's per-attack history across stored snapshots (attendance %, avg stars, trends) |
This MCP wraps the official Supercell API, which is free but requires a token tied to your IP address.
Click Login and sign in with your Supercell ID (the same one tied to your in-game account — you'll get an email code).
Once logged in, go to My Account → Create New Key.
Find your current public IP — easiest:
curl ifconfig.me
Fill in the form:
coc-mcp)MCP server for clan analysis)curl ifconfig.meClick Create Key. Copy the long JWT token that appears (starts with eyJ...).
🛡️ The token is IP-locked. If your IP changes (new ISP, VPN, coffee shop), regenerate the key with the new IP, OR run the MCP from a host with a fixed IP (a small VPS, a home server, etc.).
In-game, tap your clan name → look for the tag like #YV9JRULU. Note: clan tags use uppercase letters and digits only (no O, only 0).
git clone https://github.com/justinritchie/clash-of-clans-mcp.git
cd clash-of-clans-mcp
pip install -r requirements.txt
cp .env.example .env
Edit .env:
COC_API_TOKEN=eyJ0eXAiOiJKV1Q... # <-- paste your token
COC_DEFAULT_CLAN_TAG=#YV9JRULU # <-- your clan tag
The .env file is .gitignored, so your token won't accidentally get committed.
python coc_test.py
You should see green checkmarks for every endpoint:
✅ GET /clans/<tag>
Clan: Broken Arrow (level 27) — 44 members, 793W
✅ GET /clans/<tag>/members
✅ GET /clans/<tag>/warlog
✅ GET /clans/<tag>/currentwar/leaguegroup
✅ GET /clans/<tag>/currentwar
If you get ❌ HTTP 403, your IP doesn't match the token's whitelisted IP. Regenerate the token with your current IP (curl ifconfig.me).
If the CWL leaguegroup returns 404, that's fine — CWL only runs the first ~10 days of each month.
pip install pytest
pytest tests/ -v
Eight tests should pass. They run against fixture JSON, no API calls.
python run_war_report.py
This dumps the full markdown report for your most recent war (whatever state it's in).
python install_to_claude_desktop.py
This:
claude_desktop_config.json (timestamped)coc entry without touching any other MCPs.envThen restart Claude Desktop.
Add this to ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%/Claude/claude_desktop_config.json (Windows):
{
"mcpServers": {
"coc": {
"command": "python3",
"args": ["/absolute/path/to/coc-mcp/coc_mcp_server.py"],
"env": {
"COC_API_TOKEN": "eyJ0eXAi...",
"COC_DEFAULT_CLAN_TAG": "#YOURTAG"
}
}
}
}
Restart Claude Desktop. The coc_* tools will appear.
The MCP runs over stdio. Anything that supports stdio MCP servers will work — point it at coc_mcp_server.py with the env vars set.
The default rules live in config/rubric.default.json:
{
"war_attack_rubric": {
"first_attack": {
"acceptable_offsets": [0, 1], // mirror or one down
"min_stars_for_pass": 2
},
"second_attack": {
"preferred_offsets_min": 1, // must attack lower than your rank
"must_3_star": true // smart 3-star expected
},
"missed_attack_penalty": -10
},
"elder_promotion_rubric": {
"min_donation_ratio": 0.4,
"min_hero_progress_pct": 80,
"min_war_score_last_n": 50
},
"carry_forward_rubric": {
"min_attacks_used_pct": 100,
"min_avg_stars": 2.0,
"min_avg_destruction": 75
}
}
Two ways to customize:
Permanently — copy to config/rubric.local.json (gitignored), edit, then point to it:
COC_RUBRIC_PATH=./config/rubric.local.json
Per call — when invoking clash_grade_war or clash_war_report, pass rubric_overrides with just the fields you want to change. They're deep-merged onto the loaded rubric.
Example: relax the smart-3⭐ rule for one analysis:
{ "war_attack_rubric": { "second_attack": { "must_3_star": false } } }
inWar or warEnded). The /warlog endpoint returns summary only (result, totals — no per-attack data). To analyze past wars over time, snapshot /currentwar to disk while state is warEnded. (Future enhancement: a clash_snapshot_war tool.)coc-mcp/
├── coc_mcp_server.py # FastMCP entry — tool registrations
├── coc_mcp/
│ ├── client.py # Async COC API client
│ ├── grading.py # Rubric engine
│ ├── reporting.py # Markdown generators
│ └── config.py # Token + rubric loading
├── config/
│ └── rubric.default.json # Default rubric (edit freely)
├── tests/
│ ├── fixtures/ # Sample war JSON for tests
│ └── test_grading.py # Unit tests
├── coc_test.py # Live smoke-test script
├── run_war_report.py # CLI: dump war report for current war
├── install_to_claude_desktop.py # Safe installer (backs up first)
└── mcp_config_example.json # Drop-in for claude_desktop_config.json
PRs welcome — especially:
If you build something off this, drop a link — would love to see what other clans are doing.
MIT — see LICENSE.
This product uses data from the Clash of Clans API but is not affiliated with, endorsed, sponsored, or specifically approved by Supercell. Supercell is not responsible for it. For more information see Supercell's Fan Content Policy: supercell.com/fan-content-policy.
Run in your terminal:
claude mcp add clash-of-clans-mcp-server -- npx Security
Low riskAutomated heuristic from public metadata — not a security guarantee.