Skip to content

Commit dc81539

Browse files
committed
Prepare for npm publish as @mcpfun/mcp-server-leetcode
1 parent 7cdd89e commit dc81539

File tree

4 files changed

+156
-89
lines changed

4 files changed

+156
-89
lines changed

README.md

Lines changed: 110 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,154 @@
1-
# LeetCode MCP Server
1+
# MCP Server LeetCode
22

3-
A Model Context Protocol (MCP) server for LeetCode that interacts with the LeetCode API using GraphQL queries.
3+
[![npm version](https://img.shields.io/npm/v/@mcpfun/mcp-server-leetcode.svg)](https://www.npmjs.com/package/@mcpfun/mcp-server-leetcode)
4+
[![license](https://img.shields.io/npm/l/@mcpfun/mcp-server-leetcode.svg)](https://github.com/doggybee/mcp-server-leetcode/blob/main/LICENSE)
45

5-
## Features
6+
一个基于 Model Context Protocol (MCP) 的 LeetCode 服务器,让你的 AI 助手能够访问 LeetCode 的问题、用户信息和竞赛数据。
67

7-
- Access LeetCode problems, user information, and contest data
8-
- Structured access through MCP tools and resources
9-
- Comprehensive error handling
10-
- Modular architecture
8+
## 特点
119

12-
## Available Tools
10+
- 🚀 快速访问 LeetCode API
11+
- 🔍 搜索问题、获取每日挑战、查看用户信息
12+
- 🏆 查询竞赛数据和排名
13+
- 🧩 完整支持 MCP 工具和资源
14+
- 📦 提供命令行接口和可编程 API
1315

14-
### Problem-related Tools
15-
- `get-daily-challenge`: Retrieve the daily challenge problem
16-
- `get-problem`: Get detailed information about a specific problem by its slug
17-
- `search-problems`: Search for problems based on difficulty, tags, and other criteria
16+
## 安装
1817

19-
### User-related Tools
20-
- `get-user-profile`: Retrieve profile information for a LeetCode user
21-
- `get-user-submissions`: Get submission history for a user
22-
- `get-user-contest-ranking`: Retrieve contest ranking information for a user
18+
### 全局安装
2319

24-
### Contest-related Tools
25-
- `get-contest-details`: Get information about a specific contest
26-
- `get-user-contest-ranking`: Retrieve a user's performance in contests
20+
```bash
21+
npm install -g @mcpfun/mcp-server-leetcode
22+
```
23+
24+
然后可以直接使用命令行运行:
25+
26+
```bash
27+
mcp-server-leetcode
28+
```
2729

28-
## Resources
30+
### 本地安装
2931

30-
### Problem Resources
31-
- `leetcode://daily-challenge`: Current daily challenge problem
32-
- `leetcode://problem/{titleSlug}`: Detailed information about a specific problem
33-
- `leetcode://problems{?tags,difficulty,limit,skip}`: List of problems matching query parameters
32+
```bash
33+
npm install @mcpfun/mcp-server-leetcode
34+
```
3435

35-
### User Resources
36-
- `leetcode://user/{username}/profile`: User profile information
37-
- `leetcode://user/{username}/submissions{?limit}`: User's submission history
38-
- `leetcode://user/{username}/contest-ranking`: User's contest ranking data
36+
## 使用方法
3937

40-
## Usage Examples
38+
### 与 Claude for Desktop 集成
4139

42-
### Problem Search
40+
在 Claude for Desktop 的 `claude_desktop_config.json` 文件中添加:
4341

42+
```json
43+
{
44+
"mcpServers": {
45+
"leetcode": {
46+
"command": "mcp-server-leetcode"
47+
}
48+
}
49+
}
4450
```
45-
What are the top 5 easy array problems on LeetCode?
51+
52+
对于本地开发:
53+
54+
```json
55+
{
56+
"mcpServers": {
57+
"leetcode": {
58+
"command": "node",
59+
"args": ["/path/to/dist/index.js"]
60+
}
61+
}
62+
}
4663
```
4764

48-
This will use the `search-problems` tool with parameters for difficulty level "EASY" and the "array" tag.
65+
### 作为库使用
4966

50-
### Problem Details
67+
```javascript
68+
import { LeetCodeService } from '@mcpfun/mcp-server-leetcode';
5169

52-
```
53-
Show me details of the "two-sum" problem on LeetCode.
70+
// 初始化服务
71+
const leetcodeService = new LeetCodeService();
72+
73+
// 获取每日挑战
74+
const dailyChallenge = await leetcodeService.getDailyChallenge();
75+
76+
// 搜索问题
77+
const problems = await leetcodeService.searchProblems({
78+
difficulty: 'MEDIUM',
79+
tags: 'array+dynamic-programming'
80+
});
5481
```
5582

56-
This will use the `get-problem` tool with the titleSlug "two-sum" to retrieve comprehensive information about the problem.
83+
## 可用工具
5784

58-
### User Profile
85+
### 问题相关工具
5986

60-
```
61-
What is the LeetCode profile information for user "username123"?
62-
```
87+
| 工具名 | 描述 | 参数 |
88+
|--------|------|------|
89+
| `get-daily-challenge` | 获取每日挑战 ||
90+
| `get-problem` | 获取指定问题详情 | `titleSlug` (字符串) |
91+
| `search-problems` | 搜索满足条件的问题 | `tags` (可选), `difficulty` (可选), `limit` (默认20), `skip` (默认0) |
6392

64-
This will use the `get-user-profile` tool to retrieve statistics and profile data for the specified user.
93+
### 用户相关工具
6594

66-
### Daily Challenge
95+
| 工具名 | 描述 | 参数 |
96+
|--------|------|------|
97+
| `get-user-profile` | 获取用户信息 | `username` (字符串) |
98+
| `get-user-submissions` | 获取用户提交历史 | `username` (字符串), `limit` (可选, 默认20) |
99+
| `get-user-contest-ranking` | 获取用户竞赛排名 | `username` (字符串) |
67100

68-
```
69-
What is today's LeetCode daily challenge?
70-
```
101+
### 竞赛相关工具
71102

72-
This will use the `get-daily-challenge` tool to retrieve the current day's challenge problem.
103+
| 工具名 | 描述 | 参数 |
104+
|--------|------|------|
105+
| `get-contest-details` | 获取竞赛详情 | `contestSlug` (字符串) |
73106

74-
## Quick Start
107+
## 可用资源
75108

76-
### Install Dependencies
77-
```bash
78-
npm install
79-
```
109+
### 问题资源
80110

81-
### Build the Project
82-
```bash
83-
npm run build
84-
```
111+
- `leetcode://daily-challenge`: 每日挑战
112+
- `leetcode://problem/{titleSlug}`: 问题详情
113+
- `leetcode://problems{?tags,difficulty,limit,skip}`: 问题列表
114+
115+
### 用户资源
116+
117+
- `leetcode://user/{username}/profile`: 用户资料
118+
- `leetcode://user/{username}/submissions{?limit}`: 用户提交
119+
- `leetcode://user/{username}/contest-ranking`: 用户竞赛排名
120+
121+
## 本地开发
122+
123+
克隆仓库并安装依赖:
85124

86-
### Run the Server
87125
```bash
88-
npm start
126+
git clone https://github.com/doggybee/mcp-server-leetcode.git
127+
cd mcp-server-leetcode
128+
npm install
89129
```
90130

91-
### Development Mode
131+
以开发模式运行:
132+
92133
```bash
93134
npm run dev
94135
```
95136

96-
## Integration Guide
97-
98-
Connect to this server using Claude for Desktop or other MCP-compatible clients.
137+
构建项目:
99138

100-
### Configuration Example (Claude for Desktop)
101-
102-
Add the following to your Claude for Desktop `claude_desktop_config.json` file:
103-
104-
```json
105-
{
106-
"mcpServers": {
107-
"leetcode": {
108-
"command": "node",
109-
"args": ["/path/to/leetcode-mcp-server/dist/index.js"]
110-
}
111-
}
112-
}
139+
```bash
140+
npm run build
113141
```
114142

115-
## Clean Installation
143+
## 许可证
116144

117-
For a fresh setup, you can use the provided script:
145+
MIT
118146

119-
```bash
120-
./clean-install.sh
121-
```
147+
## 相关项目
148+
149+
- [Model Context Protocol](https://modelcontextprotocol.io) - MCP 规范和文档
150+
- [Claude for Desktop](https://claude.ai/download) - 支持 MCP 的 AI 助手
122151

123-
This script will remove existing node_modules and dist directories, install dependencies, and build the project.
152+
## 致谢
124153

125-
## References
126-
- Inspired by [alfa-leetcode-api](https://github.com/alfaarghya/alfa-leetcode-api)
127-
- Implemented using the [Model Context Protocol](https://modelcontextprotocol.io) specification
154+
- 这个项目受到 [alfa-leetcode-api](https://github.com/alfaarghya/alfa-leetcode-api) 的启发

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
export * from './dist/index.js';

package.json

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
{
2-
"name": "leetcode-mcp-server",
2+
"name": "@mcpfun/mcp-server-leetcode",
33
"version": "1.0.0",
44
"description": "Model Context Protocol server for LeetCode using GraphQL",
55
"type": "module",
6-
"main": "dist/index.js",
6+
"main": "index.js",
7+
"bin": {
8+
"mcp-server-leetcode": "./dist/index.js"
9+
},
10+
"files": [
11+
"dist",
12+
"index.js",
13+
"README.md",
14+
"LICENSE"
15+
],
716
"scripts": {
8-
"build": "tsc",
17+
"build": "tsc && chmod +x dist/index.js",
918
"start": "node dist/index.js",
1019
"dev": "tsc-watch --onSuccess \"node dist/index.js\"",
1120
"lint": "eslint src --ext .ts",
12-
"test": "jest"
21+
"test": "jest",
22+
"prepublishOnly": "npm run build",
23+
"prepare": "npm run build"
1324
},
1425
"dependencies": {
1526
"@modelcontextprotocol/sdk": "^1.7.0",
@@ -24,10 +35,34 @@
2435
"@types/node": "^20.11.27",
2536
"@typescript-eslint/eslint-plugin": "^7.3.1",
2637
"@typescript-eslint/parser": "^7.3.1",
27-
"eslint": "^9.0.0-alpha.2",
38+
"eslint": "^8.56.0",
2839
"jest": "^29.7.0",
2940
"ts-jest": "^29.1.2",
3041
"tsc-watch": "^6.0.4",
3142
"typescript": "^5.4.3"
43+
},
44+
"keywords": [
45+
"leetcode",
46+
"mcp",
47+
"model-context-protocol",
48+
"ai",
49+
"tools",
50+
"llm"
51+
],
52+
"author": "",
53+
"license": "MIT",
54+
"repository": {
55+
"type": "git",
56+
"url": "https://github.com/doggybee/mcp-server-leetcode.git"
57+
},
58+
"bugs": {
59+
"url": "https://github.com/doggybee/mcp-server-leetcode/issues"
60+
},
61+
"homepage": "https://github.com/doggybee/mcp-server-leetcode#readme",
62+
"publishConfig": {
63+
"access": "public"
64+
},
65+
"engines": {
66+
"node": ">=18"
3267
}
3368
}

tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"strict": true,
99
"esModuleInterop": true,
1010
"skipLibCheck": true,
11-
"forceConsistentCasingInFileNames": true
11+
"forceConsistentCasingInFileNames": true,
12+
"declaration": true,
13+
"sourceMap": true,
14+
"resolveJsonModule": true
1215
},
1316
"include": ["src/**/*"],
1417
"exclude": ["node_modules", "dist"]

0 commit comments

Comments
 (0)