codechef-mcp
This MCP server turns CodeChef user profiles into compact structured JSON for LLMs, avoiding raw HTML.
Fetch a user's profile: name, stars, country, role, organisation, current/highest rating, division, global/country rank, problems solved, contest count, latest contest, and recent form.
Retrieve newest-first contest rating history with rating, rating change delta, and rank.
Summarize submission activity over a time window: total submissions, active days, average per active day, busiest day, and monthly totals (with daily detail for windows of 60 days or less).
List recent contests with problems solved in each, plus rank and rating change where available.
Return unique solved problem names with their contest and the profile's reported total solved count.
Compare 2–5 CodeChef handles side-by-side on rating, stars, ranks, problems solved, and contest count.
Provides tools for retrieving structured CodeChef user profile data, including ratings, rating history, contest results, submission activity, solved problems, and side-by-side profile comparisons for multiple handles.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codechef-mcp Show me aryanc403's CodeChef profile and recent contest ratings."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
codechef-mcp
An MCP server that turns CodeChef user profiles into structured JSON for LLMs — no more dumping 180 KB of HTML into the context window and hoping the model finds the rating.
Written in plain Node.js (ESM). No build step.
Why
A CodeChef profile page is ~180 KB of markup. Most of the useful data is actually already machine-readable inside it, just buried:
Data | Where it lives |
Contest rating history |
|
Submission heat map |
|
Name, stars, country, role, organisation |
|
Rating, division, global/country rank |
|
Problems solved total |
|
Per-contest solved problems |
|
This server extracts those into typed fields, normalizes dates/numbers, computes deltas, and returns compact JSON (a few KB) instead of raw HTML.
Related MCP server: mcp-codeforces
Tools
OpenCode prefixes tool names with the server name, so a server named codechef exposes them as
codechef_get_profile, codechef_get_rating_history, and so on.
Tool | Returns |
| Name, stars, country, role, organisation, current/highest rating, division, global rank, country rank, problems solved, contest count, latest contest, best rating, last 5 contests |
| Newest-first contest list with |
| Submission heat map summary: total submissions, active days, average per active day, busiest day, monthly totals (daily detail when |
| Recent contests with the problems solved in each, merged with rank and rating delta |
| Unique problem names with their contest, plus the profile's reported total |
| Compact side-by-side profiles for 2–5 handles |
All tools take a handle (CodeChef username, e.g. gennady.korotkevich).
Install
npx codechef-mcpOr globally:
npm install -g codechef-mcpWiring it into OpenCode (V2)
Config uses mcp.servers. Either run:
opencode mcp add codechef --global -- npx -y codechef-mcpor add it by hand to ~/.config/opencode/opencode.jsonc:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"codechef": {
"type": "local",
"command": ["npx", "-y", "codechef-mcp"]
}
}
}
}Then check it with opencode mcp list. Under Code Mode the tools appear as
tools.codechef.get_profile(...).
Claude Desktop
claude_desktop_config.json:
{
"mcpServers": {
"codechef": {
"command": "npx",
"args": ["-y", "codechef-mcp"]
}
}
}On Windows, if the client cannot find npx, use the shell form:
{
"mcpServers": {
"codechef": {
"command": "cmd",
"args": ["/c", "npx", "-y", "codechef-mcp"]
}
}
}Run from source
git clone https://github.com/sarthaksec/codechef-mcp.git
cd codechef-mcp
npm install
npm start # speaks MCP over stdioPoint your MCP client at src/server.js inside the clone, or call the scraper directly:
node test/smoke.js aryanc403Development
npm install
npm run test:unit # offline parser + security tests
npm run test:live # live CodeChef scraper checks
npm run test:mcp # end-to-end MCP client handshake
npm test # all threetest:unit is fully offline and runs in CI on Node 20, 22 and 24. The live suites
depend on CodeChef being reachable and are not run in CI.
Releasing
Releases are published from GitHub Actions using trusted publishing (OIDC) — there is
no NPM_TOKEN secret and no long-lived npm credential.
npm version patch # or minor / major
git push --follow-tagsPushing the tag (for example v0.1.1) triggers .github/workflows/publish.yml, which:
checks that the tag matches
package.json's version,installs with
npm ciand runs the offline tests,runs
npm publishauthenticated by a short-lived OIDC token,publishes provenance attestations automatically (public package, public repo).
One-time trusted publisher setup
On npmjs.com → package Settings → Trusted publishing → Add trusted publisher → GitHub Actions:
Field | Value |
Organization or user |
|
Repository |
|
Workflow filename |
|
Environment name | (leave blank) |
Allowed actions | ✅ Allow npm publish (and optionally Allow npm dist-tag) |
Newer configurations default to stage-only publishing. If Allow npm publish is not
selected, the workflow's npm publish step is rejected; either enable it or change the
workflow to npm stage publish and approve each release manually with 2FA.
The first publish must succeed within 2 days of creating the configuration, otherwise it expires and has to be recreated.
Verifying provenance
npm audit signaturesOr open the package on npmjs.com — a Provenance badge links the published tarball to the exact commit and workflow run that built it.
Behavior
Cache: parsed pages are cached for 10 minutes per handle (max 200 entries).
Throttle: at least 800 ms between outbound requests.
Retries: up to 3 attempts with backoff on
403,429,5xxand Cloudflare challenges.Errors: typed codes —
INVALID_HANDLE,USER_NOT_FOUND,BLOCKED,UNPARSEABLE,FETCH_FAILED— returned withisError: trueso the model can react instead of retrying blindly.User-Agent: identifies the client; requests are one profile page at a time.
Security
Outbound HTTPS only, to
www.codechef.com. Responses redirected to any other host are rejected.TLS verification is on (Node's default
fetch; norejectUnauthorized: falseanywhere).Bounded resources: 5 MB response cap (streamed, aborts mid-body), 25 s timeout, 3 retries, 200-entry cache.
No
eval, nonew Function, no child processes, no filesystem or environment access.No credentials are read, stored, or sent — requests are anonymous.
Handle whitelisting: handles must match
^[A-Za-z0-9._-]{1,64}$and are URL-encoded, so a handle cannot alter the request path.Null-prototype maps for page-derived keys, so a crafted label cannot touch
Object.prototype.Publishing is limited by the
filesfield: onlysrc/+ docs ship to npm.Releases use OIDC trusted publishing, not a long-lived npm token, and ship with provenance attestations from GitHub Actions.
Caveats
Unofficial. CodeChef's HTML is not a contract. If they change markup,
test/unit.jsandtest/smoke.jswill tell you which field broke.Cloudflare. CodeChef fronts the site with Cloudflare. A burst of requests can get a "Just a moment..." challenge; the server detects it and reports
BLOCKEDrather than returning garbage. Wait a minute and retry.robots.txt./users/*is not disallowed, which is what this server reads. The/rankings/*leaderboard is disallowed, so global/country rank are taken from the profile page instead of scraping rankings.Counts can differ.
get_solved_problems.uniqueProblemsSolved(from the per-contest list) can be lower thanreportedTotalSolved, because the profile only lists problems for the contests it renders.No login-only data (submissions, code, unsolved problems) — that needs a session and is out of scope.
Layout
src/server.js MCP entry point (stdio)
src/tools.js tool registration + schemas
src/api.js derived data (deltas, summaries)
src/parse.js HTML/embedded-JSON parsing
src/http.js fetch, cache, throttle, retries
test/unit.js offline parser tests
test/smoke.js live scraper test
test/mcp.js end-to-end MCP client handshakeLicense
MIT © Sarthak Agnihotri (sarthaksec). Not affiliated with or endorsed by CodeChef.
Available Tools
6 toolscompare_usersCompare CodeChef usersARead-only
Fetch compact side-by-side profiles for 2-5 CodeChef handles: rating, stars, ranks, problems solved and contest count. Handy for 'who is better' or team-selection questions.
Inputs: handles (required).
get_activityGet CodeChef submission activityARead-only
Summarize a user's submission heat map over a time window: total submissions, active days, average per active day, busiest day and monthly totals. Answers 'how active is X' without loading the heat map image or HTML.
Inputs: handle (required), days.
get_contestsGet CodeChef contest resultsARead-only
List a user's contests (newest first) with the problems solved in each, plus rank and rating change where available. Use this for 'what has X solved recently' or per-contest performance.
Inputs: handle (required), limit.
get_profileGet CodeChef profileARead-only
Fetch a CodeChef user's profile as compact structured JSON: name, star rating, current and highest rating, division, global rank, country rank, problems solved, contests participated, latest contest and recent form. Prefer this over downloading and parsing the profile HTML page.
Inputs: handle (required).
get_rating_historyGet CodeChef rating historyARead-only
Return a user's contest rating history (newest first) with rating after each contest, rating change (delta) and rank. Useful for trends, streaks and 'how has X improved' questions.
Inputs: handle (required), limit.
get_solved_problemsGet CodeChef solved problemsARead-only
Return the unique problem names a user has solved (as listed on their profile), with the contest each came from, plus their reported total solved count. Capped by 'limit' to protect context size.
Inputs: handle (required), limit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Most tools target distinct facets of a CodeChef user, but get_profile overlaps with compare_users, get_rating_history, and get_contests because it bundles rating, solved counts, contests, and recent form. get_solved_problems and get_contests also both expose solved-problem information, though their descriptions clarify the difference.
All tool names use consistent snake_case with a clear verb_noun pattern: five get_* tools plus compare_users. The convention is predictable and easy for an agent to parse.
Six tools is well-scoped for a CodeChef user-analytics server. Each tool covers a distinct area: profile, solved problems, comparison, ratings, activity, and contests.
The surface covers the main user-centric workflows: profile lookup, solved problems, rating history, contest performance, activity, and user comparison. Minor gaps remain around individual submission/verdict details, problem metadata, and contest-level standings, but core analytics are covered.
Maintenance
Related MCP Connectors
Public web data as clean JSON for AI agents: Google, Amazon, TikTok, Instagram, YouTube, LinkedIn, Google Maps, Reddit, Zillow and hundreds more websites. One API key, pay per call, failed calls are free.
Company profiles, site audits and page-to-JSON extraction for AI agents.
Public web data for AI agents: scrape any page, plus Google, TikTok, Instagram and Amazon as JSON.
Fetch any RSS/Atom feed as clean JSON or extract article text from any URL. Built for AI agents.
Related MCP Servers
- AlicenseAqualityDmaintenanceA complete, all-in-one MCP server for Codeforces, enabling AI assistants to access user profiles, compare users, search problems, get practice recommendations, and more.83MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to access Codeforces public data (users, contests, problems, etc.) via natural language or direct tool calls through Pipeworx gateway.298 npmMIT
- FlicenseAqualityCmaintenanceEnables 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-
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to interact with GitHub data and Codeforces competitive programming analytics, including profiles, repositories, commits, PRs, issues, contest history, weak-topic analysis, and problem recommendations.MIT