Luogu MCP Server

io.github.Kaiserunix由 GitHub 账号 Kaiserunix 发布v0.2.1更新于 Oct 24, 2026

Search Luogu problems, fetch statements, explore problem sets and get practice recommendations.

已验证Streamable HTTP可网页运行网页搜索与抓取知识与记忆

概览

AI 生成的概览

面向洛谷的只读 MCP 服务器:搜索算法题、获取题面与样例、浏览题单,并获得练习推荐。

可以做什么
  • 按关键词、主题、标题片段、题目编号或标签搜索题目,并把粘贴的链接或编号解析为题目
  • 获取题目的题面、格式、样例、标签、难度与链接
  • 搜索并获取洛谷训练题单,涵盖官方题单与用户分享题单
  • 按主题或学生痛点查找相关练习与推荐,支持别名与标签扩展
  • 列出算法主题、按 uid 获取公开用户资料,并报告哪些功能可用
适用场景
适合让助手协助洛谷刷题:查找某主题的题目、把题面与样例取入上下文、整理练习题单,或针对具体困惑推荐后续题目。
运行要求
可使用托管的 Streamable HTTP 端点(无需安装),或通过 npx 或 node 运行本地 npm 包,需要 Node.js。需要能访问洛谷的公开网页端点。公开只读工具无需账号或 API 密钥。
安装前请注意
所列工具均为只读,提交代码与运行代码工具未启用。服务器依赖洛谷的纯内容网页端点,这些端点并非稳定的接口约定,站点变动可能导致结果失效。自建私有部署可能要求 bearer 令牌与允许来源设置。请求会以你的名义发往洛谷。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Luogu MCP Server,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。

交给智能体安装

把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。

阅读 https://sourceweft.com/mcp/io.github.Kaiserunix%2Fluogu-mcp-server/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。

查看智能体所依据的安装指南

其他 MCP 客户端

把它添加到你客户端的 mcpServers 配置中。

{
  "mcpServers": {
    "luogu": {
      "type": "http",
      "url": "https://luogu-mcp-server.lantangtang54.workers.dev/mcp"
    }
  }
}

README

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:

json
{  "mcpServers": {    "luogu": {      "url": "https://luogu-mcp.ksrnyx.top/mcp"    }  }}

To keep the server on your machine, use the published luogu-mcp-server package:

json
{  "mcpServers": {    "luogu": {      "command": "npx",      "args": ["-y", "luogu-mcp-server"]    }  }}

Then ask:

text
Search Luogu for five beginner binary-tree problems.Fetch Luogu P1305 with its statement and samples.Find related practice for traversal-order confusion.

Tools

ToolPurpose
luogu_search_problemsSearch Luogu problems by keyword, topic, title fragment, problem id, and optional Luogu tag ids.
luogu_fetch_problemFetch one Luogu problem statement, formats, samples, tags, difficulty, and URL by pid.
luogu_resolve_problemResolve a Luogu URL, problem id, or title fragment, then fetch the problem.
luogu_find_related_problemsMix topic/pain-point recommendations with live keyword search to find related practice.
luogu_list_algorithm_topicsList canonical algorithm topics, aliases, and known tag ids.
luogu_find_topic_problemsFind topic practice problems using aliases, tag ids, deduplication, and match reasons.
luogu_search_problem_setsSearch Luogu training/problem sets by keyword. Supports `type: "all"
luogu_fetch_problem_setFetch one Luogu training/problem set and problem summaries by id.
luogu_recommend_problemsReturn seed recommendations from a topic or student pain point.
luogu_get_user_profileFetch public Luogu user profile data by uid.
luogu_get_capabilitiesReport which LeetCode-style route features are available, auth-required, or planned.

All tools are read-only.

Availability

  • Hosted MCP: https://luogu-mcp.ksrnyx.top/mcp
  • Health: https://luogu-mcp.ksrnyx.top/health
  • Official MCP Registry: io.github.Kaiserunix/luogu-mcp-server, described by server.json

Other Ways To Run

From source:

powershell
git clone https://github.com/kaiserunix/luogu-mcp-server.gitcd luogu-mcp-servercmd /c npm installcmd /c npm run build

Use node directly from a source checkout:

json
{  "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:

json
{  "keyword": "二叉树",  "page": 1,  "limit": 5}

Search problems with a Luogu tag filter:

json
{  "keyword": "二叉树",  "tagIds": [11],  "limit": 5}

Fetch a problem:

json
{  "pid": "P1305",  "maxStatementChars": 5000}

Recommend from a pain point:

json
{  "topic": "binary_tree",  "painPoint": "traversal_order_confusion",  "limit": 3}

Resolve a pasted URL:

json
{  "query": "https://www.luogu.com.cn/problem/P1305",  "maxStatementChars": 5000}

Find related practice:

json
{  "topic": "binary_tree",  "painPoint": "traversal_order_confusion",  "query": "二叉树 遍历",  "limit": 5}

Find topic practice with alias expansion:

json
{  "topic": "Treap",  "limit": 5,  "excludeProblemIds": ["P3369"]}

Fetch a public user profile:

json
{  "uid": 1}

Search training/problem sets:

json
{  "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

powershell
cmd /c npm testcmd /c npm run build

Cloudflare Worker Deployment

This package also includes a stateless Streamable HTTP MCP entrypoint for Cloudflare Workers.

powershell
cmd /c npm testcmd /c npm run smoke:cfcmd /c npx wrangler logincmd /c npm run deploy:cf:drycmd /c npm run deploy:cf

The Worker exposes the same read-only tools at /mcp, with a health endpoint at / or /health.

json
{  "mcpServers": {    "luogu": {      "url": "https://<your-worker-name>.<your-workers-subdomain>.workers.dev/mcp"    }  }}

Verify a deployed Worker:

powershell
cmd /c npm run smoke:cf -- https://<your-worker-name>.<your-workers-subdomain>.workers.dev

For 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:

powershell
cmd /c npm run smoke:live

The 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:

powershell
cmd /c npm run smoke:topics

The 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:

powershell
cmd /c npm run download:topics

Test a MiMo agent loop that asks the model to choose MCP tools, then executes those calls through the local stdio MCP server:

powershell
cmd /c npm run smoke:mimo

smoke: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.

来源:README.md,提交 00d89a4

工具

0
SourceWeft 尚未读取此服务器的工具。

版本历史

1
  1. v0.2.1最新Sep 16, 2026

评分

已满足适用检查项的 85%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通必需25 分
  • 已声明认证方式必需10 分
  • 已列出工具必需15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分