Back to MCP directory
publicPublicdnsLocal runtime

leetcode

一个为LeetCode提供MCP服务的服务器,支持访问题目、用户信息和竞赛数据。

article

README

🚀 MCP 服务器 LeetCode

一个为 LeetCode 设计的模型上下文协议(MCP)服务器,让 AI 助手能够轻松访问 LeetCode 问题、用户信息和比赛数据,为开发者和用户提供便捷服务。

NPM 版本 GitHub 许可证 版本 smithery 徽章

✨ 主要特性

  • 🚀 可快速访问 LeetCode API。
  • 🔍 支持搜索问题、获取每日挑战以及查看用户资料。
  • 🏆 能够查询比赛数据和排名。
  • 🧩 完全支持 MCP 工具和资源。
  • 📦 通过 NPM 包提供,安装和使用都很方便。

📦 安装指南

方法一:通过 Smithery 安装

# 使用指定版本进行安装
smithery install @doggybee/mcp-server-leetcode@1.0.1

方法二:全局安装

npm install -g @mcpfun/mcp-server-leetcode

方法三:本地安装

npm install --save-dev @mcpfun/mcp-server-leetcode

💻 使用示例

基础用法

在终端(CLI)中使用

# 启动 MCP 服务器
mcp-server-leetcode start

# 停止 MCP 服务器
mcp-server-leetcode stop

# 查看 MCP 服务器状态
mcp-server-leetcode status

在程序中集成使用

const { Server } = require('@mcpfun/mcp-server-leetcode');

// 初始化服务器并指定配置文件路径
const server = new Server({
  configPath: './config.json'
});

// 启动服务器
server.start();

// 停止服务器
server.stop();

高级用法

针对 Claude Desktop 的配置

  1. 将 MCP 服务器添加为插件:
claude plugin add https://github.com/doggybee/mcp-server-leetcode
  1. config.json 中进行如下配置:
{
  "mcpServer": {
    "enable": true,
    "port": 3001,
    "host": "localhost"
  }
}

📚 详细文档

可用工具

MCP 工具列表

| 工具名称 | 描述 | 示例命令或语法 | | ---- | ---- | ---- | | mcp-server-leetcode | 启动和管理 MCP 服务器 | mcp-server-leetcode start
mcp-server-leetcode stop | | mcp-client | 控制 LeetCode 操作 | mcp-client search "二分查找" |

资源列表

| 资源名称 | 描述 | 示例 URL 结构 | | ---- | ---- | ---- | | /api/problems | 获取所有问题 | http://localhost:3001/api/problems | | /api/problem/<id> | 获取特定问题 | http://localhost:3001/api/problem/123 | | /api/users/<username> | 获取用户资料 | http://localhost:3001/api/users/username |

本地开发

克隆仓库

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

安装依赖

npm install

启动开发服务器

npm run dev

📄 许可证

MIT License

🔗 相关项目

🙏 致谢

此项目灵感来源于 alfa-leetcode-api

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client