luogu-mcp-server
A read-only MCP server for discovering, searching, and fetching problems and resources from the Luogu competitive programming platform, designed for AI tutoring and practice agents.
Search Problems (
luogu_search_problems): Search by keyword, topic, title fragment, or problem ID, with optional tag ID filters.Fetch Problem (
luogu_fetch_problem): Retrieve a full problem statement, input/output formats, sample cases, tags, difficulty, and source URL by problem ID (e.g.,P1305).Resolve Problem (
luogu_resolve_problem): Resolve a Luogu URL, problem ID, or title fragment and automatically fetch the corresponding problem details.Find Related Problems (
luogu_find_related_problems): Discover related practice problems by combining topic/pain-point recommendations with keyword search.List Algorithm Topics (
luogu_list_algorithm_topics): List all canonical algorithm topics, their aliases, and known Luogu tag IDs.Find Topic Problems (
luogu_find_topic_problems): Find practice problems for a specific algorithm topic (e.g., Treap, SPFA, 动态规划) using alias expansion and tag IDs.Search Problem Sets (
luogu_search_problem_sets): Search Luogu training/problem sets by keyword.Fetch Problem Set (
luogu_fetch_problem_set): Fetch a specific training/problem set and its problem summaries by set ID.Recommend Problems (
luogu_recommend_problems): Get seed problem recommendations based on an algorithm topic or student pain point.Get User Profile (
luogu_get_user_profile): Fetch public profile data for a Luogu user by their user ID.Get Capabilities (
luogu_get_capabilities): Report which route features are currently available, require authentication, or are planned.
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
A small MCP server for searching Luogu problems, reading statements and training sets, and finding related practice. It can run locally through npm or as a hosted Streamable HTTP server.
Quick Start
Use the hosted read-only server without installing anything:
{
"mcpServers": {
"luogu": {
"url": "https://luogu-mcp.ksrnyx.top/mcp"
}
}
}To keep the server on your machine, use the published luogu-mcp-server package:
{
"mcpServers": {
"luogu": {
"command": "npx",
"args": ["-y", "luogu-mcp-server"]
}
}
}Then ask:
Search Luogu for five beginner binary-tree problems.
Fetch Luogu P1305 with its statement and samples.
Find related practice for traversal-order confusion.Related MCP server: LeetCode MCP Server
Tools
Tool | Purpose |
| Search Luogu problems by keyword, topic, title fragment, problem id, and optional Luogu tag ids. |
| Fetch one Luogu problem statement, formats, samples, tags, difficulty, and URL by |
| Resolve a Luogu URL, problem id, or title fragment, then fetch the problem. |
| Mix topic/pain-point recommendations with live keyword search to find related practice. |
| List canonical algorithm topics, aliases, and known tag ids. |
| Find topic practice problems using aliases, tag ids, deduplication, and match reasons. |
| Search Luogu training/problem sets by keyword. Supports `type: "all" |
| Fetch one Luogu training/problem set and problem summaries by id. |
| Return seed recommendations from a topic or student pain point. |
| Fetch public Luogu user profile data by uid. |
| Report which LeetCode-style route features are available, auth-required, or planned. |
All tools are read-only.
Availability
Hosted MCP:
https://luogu-mcp.ksrnyx.top/mcpHealth:
https://luogu-mcp.ksrnyx.top/healthOfficial 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
cmd /c npm install
cmd /c 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 Calls
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
}Recommend from a pain point:
{
"topic": "binary_tree",
"painPoint": "traversal_order_confusion",
"limit": 3
}Resolve a pasted URL:
{
"query": "https://www.luogu.com.cn/problem/P1305",
"maxStatementChars": 5000
}Find related practice:
{
"topic": "binary_tree",
"painPoint": "traversal_order_confusion",
"query": "二叉树 遍历",
"limit": 5
}Find topic practice with alias expansion:
{
"topic": "Treap",
"limit": 5,
"excludeProblemIds": ["P3369"]
}Fetch a public user profile:
{
"uid": 1
}Search training/problem sets:
{
"keyword": "网络流",
"type": "select",
"limit": 5
}type: "all" is the default. It combines title-filtered official sets with selected user-shared set search. Use type: "official" for the public official index, or type: "select" for selected user-shared sets.
Luogu Route Parity
This project mirrors the useful shape of richer LeetCode MCP servers while respecting what Luogu exposes publicly:
Available now: problem search, problem fetch, URL/id/title resolution, related problem discovery, training set search/fetch, public user profile fetch.
Auth-required in live probes: recent submissions, public solution pages, and discussion pages.
Planned but intentionally not enabled: solution submission/run-code tools. Those require authenticated session handling and explicit write-tool safety gates.
Development
cmd /c npm test
cmd /c npm run buildCloudflare Worker Deployment
This package also includes a stateless Streamable HTTP MCP entrypoint for Cloudflare Workers.
cmd /c npm test
cmd /c npm run smoke:cf
cmd /c npx wrangler login
cmd /c npm run deploy:cf:dry
cmd /c npm run deploy:cfThe Worker exposes the same read-only tools at /mcp, with a health endpoint at / or /health.
{
"mcpServers": {
"luogu": {
"url": "https://<your-worker-name>.<your-workers-subdomain>.workers.dev/mcp"
}
}
}Verify a deployed Worker:
cmd /c npm run smoke:cf -- https://<your-worker-name>.<your-workers-subdomain>.workers.devFor private deployments, set LUOGU_MCP_TOKEN with wrangler secret put and configure your MCP client to send an Authorization: Bearer <token> header where supported. 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 release checklist.
Run broad live checks against Luogu's current website responses:
cmd /c npm run smoke:liveThe live smoke starts the MCP server through a real stdio client, then compares problem fetches, problem searches, training searches, training fetches, URL/id resolution, related recommendations, public user profiles, and route capabilities against Luogu content-only page responses. It is intentionally separate from unit tests because it depends on Luogu network availability and current site behavior.
Run the 100-topic algorithm coverage smoke:
cmd /c npm run smoke:topicsThe topic smoke starts the real MCP server and probes 100 algorithm categories across high-level topic search and training-set search. It fails if fewer than 98 topic searches return Luogu results.
Download one representative problem per catalog topic into a local ignored folder:
cmd /c npm run download:topicsTest a MiMo agent loop that asks the model to choose MCP tools, then executes those calls through the local stdio MCP server:
cmd /c npm run smoke:mimosmoke:mimo reads MIMO_API_KEY from the environment, or from C:\Users\qwerf\.continue\.env on this machine.
Notes
Luogu endpoints used here are content-only web endpoints, not a formal stability contract.
The server keeps outputs compact and structured for model context control.
Browser automation is intentionally not the default path. A Playwright fallback can be added later for pages that cannot be read through lightweight HTTP.
For broad topic discovery, Luogu training-set search is often cleaner than raw problem title search; raw keyword search follows Luogu's website ordering and can include title-level noise.
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.9625 npm155MIT
- 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.1031 npm3MIT
- AlicenseNot gradedqualityCmaintenanceRead-only MCP server for accessing AtCoder problem statements and samples, enabling problem retrieval and search without contest interference.MIT