mcp-server-leetcode
MCP 服务器 LeetCode
LeetCode 的模型上下文协议 (MCP) 服务器,使 AI 助手能够访问 LeetCode 问题、用户信息和竞赛数据。
特征
🚀 快速访问 LeetCode API
🔍 搜索问题、检索每日挑战并查看用户资料
🏆 查询比赛数据和排名
🧩 全面支持 MCP 工具和资源
📦提供 CLI 和可编程 API
Related MCP server: LeetCode MCP Server
安装
全局安装
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'
});可用工具
问题相关工具
工具名称 | 描述 | 参数 |
| 接受每日挑战 | 没有任何 |
| 获取特定问题的详细信息 |
|
| 根据标准搜索问题 |
|
用户相关工具
工具名称 | 描述 | 参数 |
| 获取用户信息 |
|
| 获取用户提交历史记录 |
|
| 获取用户竞赛排名 |
|
比赛相关工具
工具名称 | 描述 | 参数 |
| 获取比赛详情 |
|
可用资源
问题资源
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执照
麻省理工学院
相关项目
模型上下文协议- MCP 规范和文档
Claude for Desktop - 支持 MCP 的 AI 助手
致谢
该项目受到alfa-leetcode-api的启发
Available Tools
7 toolsget-contest-detailsD
| Name | Required | Description | Default |
|---|---|---|---|
| contestSlug | Yes | The URL slug of the contest |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get-daily-challengeD
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get-problemD
| Name | Required | Description | Default |
|---|---|---|---|
| titleSlug | Yes | The URL slug of the problem (e.g., 'two-sum') |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get-user-contest-rankingD
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | LeetCode username |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get-user-profileD
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | LeetCode username |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get-user-submissionsD
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | LeetCode username | |
| limit | No | Maximum number of submissions to return |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search-problemsD
| Name | Required | Description | Default |
|---|---|---|---|
| tags | No | Tags to filter by, separated by '+' (e.g., 'array+dynamic-programming') | |
| difficulty | No | Difficulty level | |
| limit | No | Maximum number of problems to return | |
| skip | No | Number of problems to skip |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v1.0.0- Changed
get-daily-challenge1 field changed- removed
Input schema / additionalPropertiesRemoved value: -false
7 tool updates
- First observed
get-contest-details - First observed
get-daily-challenge - First observed
get-problem - First observed
get-user-contest-ranking - First observed
get-user-profile - First observed
get-user-submissions - First observed
search-problems
TDQS
Scored across 7 tools
Each tool has a clearly distinct purpose targeting different LeetCode resources: contests, daily challenges, problems, user rankings, profiles, submissions, and problem search. There is no overlap in functionality, making tool selection straightforward for an agent.
All tool names follow a consistent verb_noun pattern using kebab-case (e.g., get-contest-details, search-problems). The naming is uniform throughout with no deviations in style or convention.
With 7 tools, the server is well-scoped for a LeetCode integration, covering key areas like problem access, user data, and contests. Each tool serves a specific, necessary function without bloat.
The tool set provides comprehensive read-only coverage for LeetCode data, including problems, user profiles, contests, and submissions. A minor gap exists in write operations (e.g., submitting solutions or managing account settings), but core retrieval needs are fully met.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for LeadDelta — manage LinkedIn connections and CRM data via AI assistants.
A Model Context Protocol server for Wix AI tools
MCP server that lets your AI assistant build and deploy apps, hosting each one at a live URL.
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.9169 npm155MIT
- FlicenseAqualityDmaintenanceAn MCP server that provides tools to interact with the LeetCode API, enabling problem fetching, code template generation, and solution execution/submission.71-
- FlicenseNot gradedqualityDmaintenanceAn MCP server that provides structured, AI-powered guidance for LeetCode problems, including approach analysis, hints, complexity breakdowns, and optimization directions without spoiling solutions.01-
- FlicenseNot gradedqualityDmaintenanceA tutorial and working MCP server that connects to your LeetCode profile, enabling AI assistants to check solved problems and recommend new ones by topic and difficulty.1-