mcpField
M
MCP Server LeetCode

MCP Server LeetCode

本地服务
github.com/doggybee开发工具4482 周前更新

关于 MCP Server LeetCode

MCP Server LeetCode 是面向 LeetCode 的 MCP 服务,通过 GraphQL 提供题目、用户和竞赛数据的访问。它适合希望在 AI 助手中查询 LeetCode 信息的开发者,同时提供命令行与编程接口两种使用方式。

主要功能

  1. 01查询题目详情与每日一题
  2. 02按标签、难度搜索题目
  3. 03查询用户资料与提交记录
  4. 04获取竞赛详情与用户排名
  5. 05同时提供命令行与编程 API

适用场景

  1. 01在 AI 助手中查找符合条件的题目
  2. 02查看某位用户的提交历史或竞赛排名
  3. 03在脚本或应用中调用 LeetCode 数据

MCP 相关

该项目作为 MCP 服务运行,向客户端暴露 LeetCode 相关的工具与资源,例如 get-problem 和 search-problems,以及 leetcode://daily-challenge 等资源。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"leetcode": {
"command": "npx",
"args": [
"-y",
"@mcpfun/mcp-server-leetcode"
]
}
}
}
启动命令npx -y @mcpfun/mcp-server-leetcode

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@mcpfun/mcp-server-leetcode

工具

7

收录的工具列表 · 更新于 3 周前

此工具无需参数。

详细介绍

MCP Server LeetCode

npm version GitHub license Version smithery badge

一个用于 LeetCode 的模型上下文协议(MCP)服务,使 AI 助手能够访问 LeetCode 题目、用户信息和竞赛数据。

功能

  • 🚀 快速访问 LeetCode API
  • 🔍 搜索题目、获取每日挑战并查看用户资料
  • 🏆 查询竞赛数据和排名
  • 🧩 完整支持 MCP 工具和资源
  • 📦 同时提供 CLI 和可编程 API

安装

通过 Smithery 安装

通过 Smithery 为 Claude Desktop 自动安装 mcp-server-leetcode:

npx -y @smithery/cli install @doggybee/mcp-server-leetcode --client claude
全局安装
npm install -g @mcpfun/mcp-server-leetcode

安装完成后,可直接从命令行运行:

mcp-server-leetcode
本地安装
npm install @mcpfun/mcp-server-leetcode

使用方法

与 Claude for Desktop 集成

将以下内容添加到 Claude for Desktop 的 claude_desktop_config.json 文件中:

{
  "mcpServers": {
    "leetcode": {
      "command": "mcp-server-leetcode"
    }
  }
}

本地开发时:

{
  "mcpServers": {
    "leetcode": {
      "command": "node",
      "args": ["/path/to/dist/index.js"]
    }
  }
}
用作库
import { LeetCodeService } from '@mcpfun/mcp-server-leetcode';

// Initialize the service
const leetcodeService = new LeetCodeService();

// Get daily challenge
const dailyChallenge = await leetcodeService.getDailyChallenge();

// Search problems
const problems = await leetcodeService.searchProblems({
  difficulty: 'MEDIUM',
  tags: 'array+dynamic-programming'
});

可用工具

题目相关工具
工具名称描述参数
get-daily-challenge获取每日挑战无
get-problem获取指定题目的详细信息titleSlug(字符串)
search-problems根据条件搜索题目tags(可选)、difficulty(可选)、limit(默认 20)、skip(默认 0)
用户相关工具
工具名称描述参数
get-user-profile获取用户信息username(字符串)
get-user-submissions获取用户提交历史username(字符串)、limit(可选,默认 20)
get-user-contest-ranking获取用户竞赛排名username(字符串)
竞赛相关工具
工具名称描述参数
get-contest-details获取竞赛详情contestSlug(字符串)

可用资源

题目资源
  • leetcode://daily-challenge:每日挑战
  • leetcode://problem/{titleSlug}:题目详情
  • leetcode://problems{?tags,difficulty,limit,skip}:题目列表
用户资源
  • leetcode://user/{username}/profile:用户资料
  • leetcode://user/{username}/submissions{?limit}:用户提交记录
  • leetcode://user/{username}/contest-ranking:用户竞赛排名

本地开发

克隆仓库并安装依赖:

git clone https://github.com/doggybee/mcp-server-leetcode.git
cd mcp-server-leetcode
npm install

以开发模式运行:

npm run dev

构建项目:

npm run build

许可证

MIT

相关项目

致谢

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。