luogu-mcp-server
This is a read-only Luogu MCP server for discovering and reading public competitive-programming content.
Search Luogu problems by keyword, title fragment, problem ID, or tag IDs.
Fetch full problem details: statement, input/output formats, samples, tags, difficulty, and URL.
Resolve a Luogu URL, problem ID, or title fragment into a fetched problem.
Explore 100 algorithm topics with bilingual aliases, Luogu tag IDs, template prioritization, exclusions, and match reasons.
List canonical algorithm topics, aliases, and known Luogu tag IDs.
Find related practice problems by topic, pain point, query, or current problem ID.
Recommend curated beginner seed problems for targeted pain-point buckets.
Search official and user-shared Luogu training/problem sets (
题单).Fetch a training/problem set and its problem summaries.
Fetch public Luogu user profile data by UID.
Report available, auth-required, or intentionally disabled route capabilities.
All operations are strictly read-only; no login, code submission, or remote execution.
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., "@luogu-mcp-server search for problems about binary trees"
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.
Luogu MCP Server | 洛谷 MCP Server
简体中文 | Product Strategy & Roadmap | Multi-OJ Monorepo (ketherworks)
The 11-tool Luogu Deep Pedagogy & Topic-Discovery MCP Server — search Luogu problems, read context-safe statements and samples, explore 100 algorithm topics with bilingual alias expansion & 【模板】 template prioritization, search official + user-shared training sets (题单), and get beginner pain-point recommendations. Runs zero-install over Streamable HTTP or locally via npm (npx -y luogu-mcp-server).
All 11 tools are strictly read-only (public Luogu problems, training sets, recommendations, and public user profiles; no account login or code submission).
Which Luogu / OJ MCP Repo Should I Use?
Repository | Edition & Tools | Best For | Connection |
| Luogu Deep Pedagogy Edition ( | 100-topic bilingual alias catalog, official + selected training sets ( | Hosted HTTP |
Unified Multi-OJ Contract Suite ( | Multi-platform agents needing one typed | Hosted HTTP + local |
Related MCP server: LeetCode MCP Server
Quick Start
Option 1: Zero-Install Hosted Streamable HTTP
Cursor / Windsurf / Clients using "mcpServers":
{
"mcpServers": {
"luogu": {
"url": "https://luogu-mcp.ksrnyx.top/mcp"
}
}
}VS Code (.vscode/mcp.json, uses "servers" + "type": "http"):
{
"servers": {
"luogu": {
"type": "http",
"url": "https://luogu-mcp.ksrnyx.top/mcp"
}
}
}Option 2: Local stdio via npm (Recommended for Claude Desktop or Avoiding Remote Egress Limits)
Requires Node.js >= 20. Uses the published luogu-mcp-server package:
macOS / Linux:
{
"mcpServers": {
"luogu": {
"command": "npx",
"args": ["-y", "luogu-mcp-server"]
}
}
}Windows (wrap npx via cmd /c if your MCP host reports spawn npx ENOENT):
{
"mcpServers": {
"luogu": {
"command": "cmd",
"args": ["/c", "npx", "-y", "luogu-mcp-server"]
}
}
}Try Asking Your AI Client
Search Luogu for five beginner binary-tree problems.
Fetch Luogu P1305 with its statement and samples.
Find Treap topic practice problems excluding P3369.
Search Luogu training sets for 网络流.
Find related practice for traversal-order confusion.Why This Server Stands Out
100-Topic Bilingual Alias & Template-Prioritized Discovery (
luogu_find_topic_problems): Expands OI shorthand (Treap,SPFA,状压,割边) into canonical topics & Luogu tag IDs, boosts【模板】template problems and approachable difficulties, and is verified by a 100-topic live smoke test (>=98/100hit threshold).Hybrid Official + Community Training-Set Search (
luogu_search_problem_sets): Fetches Luogu's official training index and communityselectsets in parallel, normalizes title filtering across both, and deduplicates results undertype: "all".Context-Safe Statement Trimming: Normalizes Luogu's multi-schema content payloads and bounds long stories via
maxStatementChars(default5000) so LLM context windows stay clean.Offline 100-Topic Markdown Pack: Run
npm run download:topicsto export one representative problem per algorithm topic as clean local Markdown cards.
Tools (11 Read-Only Tools)
Tool | Purpose |
| Primary 100-topic discovery engine: finds topic practice using bilingual aliases, Luogu tag IDs, template prioritization, deduplication, and match reasons. |
| List all 100 canonical algorithm topics, aliases, and known Luogu tag IDs. |
| Search Luogu problems by keyword, topic, title fragment, problem ID, and optional Luogu tag IDs. |
| Fetch one Luogu problem statement, input/output formats, samples, tags, difficulty, and URL by |
| Resolve a Luogu URL, problem ID, or title fragment, then fetch the problem (for |
| Search Luogu training/problem sets ( |
| Fetch one Luogu training/problem set and its problem summaries by ID. |
| Combine topic/pain-point recommendations with live keyword search to find related practice. |
| Return curated beginner seed recommendations for 6 targeted pain-point buckets ( |
| Fetch public Luogu user profile data by |
| Report which LeetCode-style route features are available, auth-required, or intentionally not enabled. |
Availability
Hosted MCP:
https://luogu-mcp.ksrnyx.top/mcpHealth Check:
https://luogu-mcp.ksrnyx.top/healthnpm Package:
luogu-mcp-serverOfficial MCP Registry:
io.github.Kaiserunix/luogu-mcp-server, described byserver.json
Other Ways To Run (From Source)
git clone https://github.com/Kaiserunix/luogu-mcp-server.git
cd luogu-mcp-server
npm install
npm run buildUse node directly from a source checkout:
{
"mcpServers": {
"luogu": {
"command": "node",
"args": [
"C:\\path\\to\\luogu-mcp-server\\dist\\index.js"
],
"cwd": "C:\\path\\to\\luogu-mcp-server"
}
}
}Example Tool Payloads
Search problems:
{
"keyword": "二叉树",
"page": 1,
"limit": 5
}Search problems with a Luogu tag filter:
{
"keyword": "二叉树",
"tagIds": [11],
"limit": 5
}Fetch a problem:
{
"pid": "P1305",
"maxStatementChars": 5000
}Resolve a pasted URL:
{
"query": "https://www.luogu.com.cn/problem/P1305",
"maxStatementChars": 5000
}Find topic practice with alias expansion:
{
"topic": "Treap",
"limit": 5,
"excludeProblemIds": ["P3369"]
}Recommend from a beginner pain point:
{
"topic": "binary_tree",
"painPoint": "traversal_order_confusion",
"limit": 3
}Find related practice:
{
"topic": "binary_tree",
"painPoint": "traversal_order_confusion",
"query": "二叉树 遍历",
"limit": 5
}Fetch a public user profile:
{
"uid": 1
}Search training/problem sets (type: "all" is the default; use "official" for official index only or "select" for user-shared sets):
{
"keyword": "网络流",
"type": "select",
"limit": 5
}Luogu Route Parity & Scope
This project mirrors the useful ergonomics of mature LeetCode MCP servers while strictly respecting what Luogu exposes publicly:
Available now: problem search, problem fetch, URL/ID/title resolution, 100-topic & related problem discovery, training-set search/fetch, public user profile fetch.
Auth-required in live probes (not enabled): recent submissions, public solution pages, and discussion pages.
Intentionally not enabled: solution submission / remote code execution (requires authenticated sessions and explicit write-tool safety gates).
Development & Smoke Verification
npm test
npm run buildOptional live verification scripts (depend on live Luogu network availability):
Command | Purpose |
| End-to-end stdio MCP verification against live Luogu content responses |
| Probes all 100 algorithm categories across topic & training-set search (fails if |
| Exports one representative problem per topic into a local gitignored Markdown folder |
| Runs an agent tool-calling smoke loop against the local stdio MCP server (reads |
Cloudflare Worker Deployment & Egress Caveat
Upstream Egress Blocking Caveat: Luogu (www.luogu.com.cn) frequently blocks or rate-limits shared Cloudflare Worker egress IPs on real problem/search reads even when /health and MCP handshakes succeed. For reliable self-hosted reads, prefer local npx -y luogu-mcp-server (stdio) or a Node 22 container behind HTTPS / private tunnel (see ketherworks/competitive-programming-mcp).
This package includes a stateless Streamable HTTP MCP Worker entrypoint (src/worker.ts) if your egress route can reach Luogu reliably:
npm test
npm run smoke:cf
npx wrangler login
npm run deploy:cf:dry
npm run deploy:cfVerify a deployed Worker (be sure to test a real read tool, not only /health):
npm run smoke:cf -- https://<your-worker-name>.<your-workers-subdomain>.workers.devFor private deployments, set LUOGU_MCP_TOKEN with wrangler secret put and send Authorization: Bearer <token> (or X-Luogu-Mcp-Token). Browser Origin requests are rejected by default; set LUOGU_MCP_ALLOWED_ORIGINS to a comma-separated origin list if browser access is needed. See docs/cloudflare-deployment.md for the full checklist.
Notes
Luogu endpoints used here are public content-only web endpoints, not a formal OpenAPI stability contract.
Outputs stay compact and structured to preserve model context budget.
Browser automation is intentionally not on the default path.
For broad topic discovery, Luogu training-set search (
luogu_search_problem_sets) and topic discovery (luogu_find_topic_problems) are generally cleaner than raw problem title search.
Available Tools
11 toolsluogu_fetch_problemFetch Luogu ProblemARead-onlyInspect
Fetch a Luogu problem statement, formats, samples, tags, difficulty, and source URL by pid.
Inputs: pid (required), maxStatementChars.
luogu_fetch_problem_setFetch Luogu Training SetARead-onlyInspect
Fetch a Luogu training/problem set and its problem summaries by id.
Inputs: id (required), limit.
luogu_find_topic_problemsFind Luogu Topic ProblemsARead-onlyInspect
Find Luogu practice problems for an algorithm topic using aliases, known Luogu tag ids, deduplication, and match reasons.
Inputs: topic (required), limit, excludeProblemIds.
luogu_get_capabilitiesGet Luogu Route CapabilitiesARead-onlyInspect
Report which LeetCode-style route capabilities are available, auth-required, or planned for Luogu.
Inputs: no named parameters.
luogu_get_user_profileGet Luogu User ProfileARead-onlyInspect
Fetch public Luogu user profile data by uid.
Inputs: uid (required).
luogu_list_algorithm_topicsList Luogu Algorithm TopicsARead-onlyInspect
List canonical algorithm topics, aliases, and known Luogu tag ids used by the high-level topic search route.
Inputs: no named parameters.
luogu_recommend_problemsRecommend Luogu ProblemsARead-onlyInspect
Recommend seed Luogu problems from a topic or student pain point, with search hints for further exploration.
Inputs: topic, painPoint, currentProblemId, limit.
luogu_resolve_problemResolve Luogu ProblemARead-onlyInspect
Resolve a Luogu problem from a URL, problem id, or title fragment, then fetch the problem details.
Inputs: query (required), maxStatementChars.
luogu_search_problemsSearch Luogu ProblemsARead-onlyInspect
Search Luogu problems by keyword. Use this before fetching a problem when you only know a topic or partial title.
Inputs: keyword (required), page, limit, tagIds.
luogu_search_problem_setsSearch Luogu Training SetsBRead-onlyInspect
Search Luogu training/problem sets by keyword.
Inputs: keyword (required), page, limit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Most tools have distinct purposes, but luogu_find_related_problems and luogu_recommend_problems overlap in recommending problems, and luogu_fetch_problem vs luogu_resolve_problem serve similar fetching roles with different inputs, which may cause minor confusion.
All tools follow a consistent 'luogu_verb_noun' pattern using snake_case, with clear verb choices that describe the action (fetch, search, find, etc.). No mixing of conventions.
11 tools is within the ideal 3-15 range, covering problem retrieval, search, recommendation, problem sets, user profile, algorithm topics, and capabilities. The scope is well-balanced.
The tool set covers problem discovery, retrieval, and user profiles comprehensively, but lacks tools for submissions, authentication, or contest data. However, given the apparent focus on problem exploration, it is reasonably complete.
Related MCP Connectors
Read-only MCP server for ClassQuill, a tutoring-business-management platform.
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
Read-only MCP server for The Quiet Protocol's engines, benchmarks, proof, and business data.
Related MCP Servers
- AlicenseAqualityBmaintenanceA Model Context Protocol server that provides integration with LeetCode APIs, enabling automated interaction with programming problems, contests, solutions, and user data across both leetcode.com and leetcode.cn platforms.9343 npm163MIT
- FlicenseAqualityDmaintenanceAn MCP server that provides tools to interact with the LeetCode API, enabling problem fetching, code template generation, and solution execution/submission.71-
- AlicenseAqualityDmaintenanceUnofficial MCP server for searching and recommending Baekjoon (BOJ) problems using the solved.ac API.103MIT
- AlicenseNot gradedqualityCmaintenanceRead-only MCP server for accessing AtCoder problem statements and samples, enabling problem retrieval and search without contest interference.MIT