luogu-mcp

luogu-mcp

Fetches and structures programming problem data from Luogu, enabling AI tools to query problem details such as title, difficulty, tags, samples, and limits.

Category
访问服务器

README

洛谷题目 MCP 服务

洛谷题目 MCP(Model Context Protocol)服务,用于抓取和结构化洛谷编程题目信息,可与 Claude Desktop、Cursor、VS Code 等 AI 工具无缝集成。

在线演示

MCP 安装指南

本服务基于 Streamable HTTP 传输(JSON-RPC 2.0 over HTTP POST)运行,无需本地进程,直接配置远端 URL 即可使用。

MCP 端点地址:

https://workers-playground-steep-brook-cdfb.alphazhang689.workers.dev/mcp

Claude Desktop

编辑配置文件,加入以下内容:

  • macOS~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows%APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "luogu": {
      "url": "https://workers-playground-steep-brook-cdfb.alphazhang689.workers.dev/mcp"
    }
  }
}

保存后重启 Claude Desktop,在对话中即可直接让 Claude 查询洛谷题目。


Cursor

  1. 打开 SettingsCtrl+, / Cmd+,)→ 搜索 MCP
  2. 点击 Add new MCP server
  3. 填写:
    • Nameluogu
    • Typehttp
    • URLhttps://workers-playground-steep-brook-cdfb.alphazhang689.workers.dev/mcp

VS Code(GitHub Copilot Chat)

.vscode/mcp.json 中添加:

{
  "servers": {
    "luogu": {
      "url": "https://workers-playground-steep-brook-cdfb.alphazhang689.workers.dev/mcp"
    }
  }
}

其他 MCP 客户端(Cline、Continue 等)

所有支持 Streamable HTTPHTTP transport 的 MCP 客户端均可直接配置上方 URL。


可用工具

工具名 说明 参数
get_problem 获取洛谷题目完整信息(题面、格式、样例、难度、标签) problem_id:题目编号,如 P1001CF1234AAT_abc123_a

支持的题目编号格式:P(普通)、B(入门)、CF(Codeforces)、AT(AtCoder)、SP(SPOJ)、UVA 等。


REST API

除 MCP 外,还提供 REST API 接口:

方法 路径 说明
GET /api/problem/:id 通过题号获取题目,如 /api/problem/P1001
GET /api/fetch?url=<题目URL> 通过完整 URL 获取题目

返回数据格式

{
  "id": "P1001",
  "url": "https://www.luogu.com.cn/problem/P1001",
  "title": "A+B Problem",
  "difficultyNum": 1,
  "difficulty": "入门",
  "tags": ["模拟", "数学"],
  "description": "输入两个整数 a, b,输出它们的和",
  "inputFormat": "两个用空格分开的整数",
  "outputFormat": "一个整数",
  "samples": [
    { "input": "1 2", "output": "3" }
  ],
  "limit": "时间限制:1.0s  内存限制:128MB"
}

MCP 协议参考

本服务遵循 MCP 规范 2025-11-25,使用 JSON-RPC 2.0 格式:

// 初始化
{ "jsonrpc": "2.0", "id": 1, "method": "initialize",
  "params": { "protocolVersion": "2025-11-25", "capabilities": {} } }

// 列出工具
{ "jsonrpc": "2.0", "id": 2, "method": "tools/list" }

// 调用工具
{ "jsonrpc": "2.0", "id": 3, "method": "tools/call",
  "params": { "name": "get_problem", "arguments": { "problem_id": "P1001" } } }

本地开发 & 部署

# 安装依赖
npm install

# 本地开发(访问 http://localhost:8787)
npm run dev

# 运行测试
npm test

# 部署到 Cloudflare Workers
npm run deploy

许可证

本项目基于 MIT 许可证开源。

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选