Skip to content

Commit 031d837

Browse files
Merge pull request #27 from SPerekrestova/feat/skills
Feat/skills
2 parents a64162c + 639b879 commit 031d837

9 files changed

Lines changed: 443 additions & 6 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "interactive-leetcode-mcp",
3+
"owner": {
4+
"name": "SPerekrestova"
5+
},
6+
"metadata": {
7+
"description": "Interactive LeetCode MCP server plugin for Claude Code"
8+
},
9+
"plugins": [
10+
{
11+
"name": "interactive-leetcode-mcp",
12+
"source": ".",
13+
"description": "Interactive LeetCode practice with learning-guided hints, solution submission, and AI-driven authentication via MCP server",
14+
"version": "3.2.0",
15+
"homepage": "https://github.com/SPerekrestova/interactive-leetcode-mcp",
16+
"keywords": ["leetcode", "mcp", "practice", "coding-interview"],
17+
"category": "learning"
18+
}
19+
]
20+
}

.claude-plugin/plugin.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "interactive-leetcode-mcp",
3+
"description": "Interactive LeetCode practice with learning-guided hints, solution submission, and AI-driven authentication via MCP server",
4+
"version": "3.2.0",
5+
"author": {
6+
"name": "SPerekrestova"
7+
},
8+
"homepage": "https://github.com/SPerekrestova/interactive-leetcode-mcp",
9+
"repository": "https://github.com/SPerekrestova/interactive-leetcode-mcp",
10+
"license": "MIT",
11+
"keywords": ["leetcode", "mcp", "practice", "coding-interview", "learning"]
12+
}

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,29 @@ To activate learning mode, tell Claude you want to practice with guidance — fo
261261
- LeetCode may be experiencing high traffic - wait and retry
262262
- Check your internet connection
263263

264+
## Skills & Plugins
265+
266+
This repo also ships an **agent skill** that teaches Claude (and other AI agents) how to use the MCP server correctly — including session flow, prompt invocations, learning mode, and authentication.
267+
268+
### Claude Code Plugin
269+
270+
Install the skill directly as a Claude Code plugin:
271+
272+
```
273+
/plugin marketplace add SPerekrestova/interactive-leetcode-mcp
274+
/plugin install interactive-leetcode-mcp@interactive-leetcode-mcp
275+
```
276+
277+
Then start a practice session with:
278+
279+
```
280+
/interactive-leetcode-mcp:interactive-leetcode-mcp
281+
```
282+
283+
### ClawHub (OpenClaw / Clawbot)
284+
285+
The skill is also published on [ClawHub](https://clawhub.ai/SPerekrestova/interactive-leetcode) for use with OpenClaw-compatible agents.
286+
264287
## Acknowledgements
265288

266289
Forked from [Leetcode mcp](https://github.com/jinzcdev/leetcode-mcp-server))
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
name: interactive-leetcode-mcp
3+
description: Use when the user wants to practice LeetCode problems, submit solutions, or set up LeetCode integration. Covers MCP server installation, learning-guided practice flow, solution submission, and authentication.
4+
homepage: https://github.com/SPerekrestova/interactive-leetcode-mcp
5+
disable-model-invocation: true
6+
metadata:
7+
clawdbot:
8+
requires:
9+
bins: [npx]
10+
config: [~/.leetcode-mcp/credentials.json]
11+
credentials:
12+
stores: ~/.leetcode-mcp/credentials.json
13+
contents: csrftoken, LEETCODE_SESSION, createdAt timestamp
14+
permissions: "0600"
15+
---
16+
17+
# Interactive LeetCode MCP
18+
19+
MCP server for LeetCode practice with learning-guided hints, solution submission, and AI-driven authentication.
20+
21+
## Prerequisite: Ensure MCP Server Is Connected
22+
23+
Before anything else, check whether the `get_started` tool is available. If it is, the server is connected — skip to the next section.
24+
25+
**If `get_started` is NOT available**, the MCP server needs to be installed. **Ask the user for confirmation before proceeding** — explain that this will download and run an npm package.
26+
27+
The npm package is [`@sperekrestova/interactive-leetcode-mcp`](https://www.npmjs.com/package/@sperekrestova/interactive-leetcode-mcp) (source: [GitHub](https://github.com/SPerekrestova/interactive-leetcode-mcp)). It runs over stdio transport. Requires Node.js >= 20.
28+
29+
After the user confirms, add to the client's MCP configuration (the exact file varies by client):
30+
31+
```json
32+
{
33+
"mcpServers": {
34+
"leetcode": {
35+
"command": "npx",
36+
"args": ["-y", "@sperekrestova/interactive-leetcode-mcp@3.2.0"]
37+
}
38+
}
39+
}
40+
```
41+
42+
For Claude Code specifically, you can also run:
43+
44+
```bash
45+
claude mcp add --transport stdio leetcode -- npx -y @sperekrestova/interactive-leetcode-mcp@3.2.0
46+
```
47+
48+
**Pin a specific version** (shown above) rather than using `@latest` to avoid executing untested code. Users can check for newer versions at the [npm page](https://www.npmjs.com/package/@sperekrestova/interactive-leetcode-mcp) or [GitHub releases](https://github.com/SPerekrestova/interactive-leetcode-mcp/releases) and update the pinned version after reviewing the changelog.
49+
50+
After adding the server, tell the user to restart their session so the MCP tools become available. Do not proceed with the session flow until `get_started` is accessible.
51+
52+
## First Action: Always Call get_started
53+
54+
At the START of every LeetCode session, call the `get_started` tool. It returns the full usage guide: prompt invocation rules, session flow, learning mode rules, auth flow, and language map.
55+
56+
**Do not skip this** — it is a single fast call, not redundant with tool descriptions. The server has MCP prompts that must be explicitly invoked — they are NOT auto-active. The `get_started` response tells you exactly when and how.
57+
58+
## Session Flow (Critical)
59+
60+
```
61+
1. Call get_started <-- FIRST, every session
62+
2. Invoke leetcode_learning_mode <-- BEFORE any problem discussion
63+
3. User picks a problem
64+
4. Invoke leetcode_problem_workflow(problemSlug, difficulty)
65+
5. Invoke leetcode_workspace_setup(language, problemSlug, codeTemplate)
66+
6. Guide user with progressive hints (4 levels)
67+
7. submit_solution when ready
68+
```
69+
70+
Steps 2, 4, and 5 are MCP prompt invocations. Invoke them via the Skill tool or equivalent prompt mechanism. All three must happen BEFORE the user starts coding.
71+
72+
**Step 2 is non-negotiable.** If you skip `leetcode_learning_mode`, you will bypass the progressive hint system and may show solutions prematurely. Invoke it before searching for or discussing any problem.
73+
74+
## Prompt Invocation Rules
75+
76+
| Prompt | When | Params |
77+
| ------------------------------- | --------------------------------------- | ----------------------------------- |
78+
| `leetcode_learning_mode` | START of session, before any problem | none |
79+
| `leetcode_problem_workflow` | After user selects a problem | problemSlug, difficulty |
80+
| `leetcode_workspace_setup` | Before user starts coding | language, problemSlug, codeTemplate |
81+
| `leetcode_authentication_guide` | On auth need, 401 errors, expired creds | none |
82+
83+
## Learning Mode Rules
84+
85+
- Never show a full solution without working through hint levels 1 → 2 → 3
86+
- Level 1: Guiding questions ("What pattern do you see?")
87+
- Level 2: General approaches ("Consider using a hash map...")
88+
- Level 3: Specific hints ("Iterate once, tracking seen values...")
89+
- Level 4: Pseudocode or partial implementation
90+
- Only show complete solutions when explicitly requested AFTER earlier hints
91+
- `get_problem_solution` returns full community solutions — Level 4 or explicit request only
92+
93+
## Tool Quick Reference
94+
95+
| Tool | Purpose | Auth? |
96+
| ------------------------------- | -------------------------------- | ------- |
97+
| `get_daily_challenge` | Today's challenge | No |
98+
| `get_problem` | Problem by slug | No |
99+
| `search_problems` | Find by tags/difficulty/keywords | No |
100+
| `list_problem_solutions` | Solution metadata (topicIds) | No |
101+
| `get_problem_solution` | Full solution — **Level 4 only** | No |
102+
| `submit_solution` | Submit code | No\* |
103+
| `get_user_profile` | Any user's stats | No |
104+
| `get_recent_submissions` | Recent submissions | No |
105+
| `get_recent_ac_submissions` | Accepted submissions | No |
106+
| `get_user_contest_ranking` | Contest ranking | No |
107+
| `start_leetcode_auth` | Start auth flow | No |
108+
| `save_leetcode_credentials` | Validate + save creds | No |
109+
| `check_auth_status` | Check credential state | No |
110+
| `get_user_status` | Current user info | **Yes** |
111+
| `get_problem_submission_report` | Submission detail | **Yes** |
112+
| `get_problem_progress` | Progress with filters | **Yes** |
113+
| `get_all_submissions` | All submissions | **Yes** |
114+
115+
\*`submit_solution` requires saved credentials to succeed.
116+
117+
## Auth Flow
118+
119+
1. Before auth-sensitive actions → call `check_auth_status`
120+
2. If not authenticated or expired → **ask the user if they want to authenticate.** Explain that this will store LeetCode session cookies locally at `~/.leetcode-mcp/credentials.json` (owner-read/write only). Do not proceed without consent.
121+
3. After consent → invoke `leetcode_authentication_guide` prompt
122+
4. Call `start_leetcode_auth` → the prompt will guide the user through providing credentials → call `save_leetcode_credentials` with the values the user provides
123+
5. On success → retry original action
124+
6. On 401 from any tool → repeat from step 1
125+
126+
**Always delegate auth guidance to the `leetcode_authentication_guide` prompt.** Do not improvise your own auth instructions — the prompt handles browser-specific guidance, error recovery, and troubleshooting.
127+
128+
**Credential storage:** The MCP server stores credentials locally at `~/.leetcode-mcp/credentials.json` with file permissions `0o600` (owner-read/write only). Only `csrftoken`, `LEETCODE_SESSION`, and a `createdAt` timestamp are stored. Credentials are never transmitted to any third party — they are used exclusively for direct LeetCode API calls. Typical credential lifetime is 7-14 days.
129+
130+
## Submission Language Map
131+
132+
| User says | Pass to submit_solution |
133+
| ----------------- | ----------------------- |
134+
| Python / Python 3 | `python3` |
135+
| Python 2 | `python` |
136+
| Java | `java` |
137+
| C++ | `cpp` |
138+
| JavaScript | `javascript` |
139+
| TypeScript | `typescript` |
140+
141+
Default: "Python" without version → `python3`.
142+
143+
## Resources (Read-Only Lookups)
144+
145+
| Resource URI | What it provides |
146+
| --------------------------- | ------------------------------------------------ |
147+
| `categories://problems/all` | All problem categories |
148+
| `tags://problems/all` | All 60+ topic tags |
149+
| `langs://problems/all` | All supported submission languages |
150+
| `problem://{titleSlug}` | Problem detail |
151+
| `solution://{topicId}` | Solution detail (same learning-mode rules apply) |
152+
153+
## Common Mistakes
154+
155+
- Jumping to problem search before invoking `leetcode_learning_mode`
156+
- Showing full solutions without progressing through hint levels 1 → 2 → 3
157+
- Not invoking `leetcode_workspace_setup` — code should live in a file, not only in chat
158+
- Guiding auth manually instead of invoking `leetcode_authentication_guide`
159+
- Passing `"Python"` to `submit_solution` instead of `"python3"`
160+
- Not calling `check_auth_status` before auth-sensitive operations
161+
- Skipping `get_started` and assuming tool descriptions are sufficient

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@sperekrestova/interactive-leetcode-mcp",
33
"description": "Interactive LeetCode MCP server with authorization and submission capabilities for seamless problem-solving with Claude",
4-
"version": "3.1.0",
4+
"version": "3.2.0",
55
"mcpName": "io.github.SPerekrestova/interactive-leetcode-mcp",
66
"author": "SPerekrestova",
77
"main": "./build/index.js",
@@ -31,7 +31,7 @@
3131
"dev": "tsc-watch --onSuccess \"node build/index.js\"",
3232
"format": "prettier --write .",
3333
"prepare": "husky",
34-
"sync-version": "node -e \"const pkg=require('./package.json');const server=require('./server.json');server.version=pkg.version;server.packages[0].version=pkg.version;require('fs').writeFileSync('server.json',JSON.stringify(server,null,4)+'\\n')\"",
34+
"sync-version": "node scripts/sync-version.cjs",
3535
"prepublishOnly": "npm run sync-version && npm run build"
3636
},
3737
"bin": {

scripts/sync-version.cjs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Syncs the version from package.json to:
5+
* - server.json (MCP registry metadata)
6+
* - .claude-plugin/plugin.json (Claude Code plugin manifest)
7+
* - All SKILL.md files (pinned npm package version in install instructions)
8+
*
9+
* Run: npm run sync-version
10+
* Runs automatically before publish via prepublishOnly hook.
11+
*/
12+
13+
const fs = require("fs");
14+
const path = require("path");
15+
16+
const ROOT = path.resolve(__dirname, "..");
17+
const pkg = require(path.join(ROOT, "package.json"));
18+
const version = pkg.version;
19+
20+
// --- server.json ---
21+
const serverPath = path.join(ROOT, "server.json");
22+
const server = JSON.parse(fs.readFileSync(serverPath, "utf-8"));
23+
server.version = version;
24+
server.packages[0].version = version;
25+
fs.writeFileSync(serverPath, JSON.stringify(server, null, 4) + "\n");
26+
27+
// --- .claude-plugin/plugin.json ---
28+
const pluginPath = path.join(ROOT, ".claude-plugin", "plugin.json");
29+
if (fs.existsSync(pluginPath)) {
30+
const plugin = JSON.parse(fs.readFileSync(pluginPath, "utf-8"));
31+
plugin.version = version;
32+
fs.writeFileSync(pluginPath, JSON.stringify(plugin, null, 2) + "\n");
33+
}
34+
35+
// --- .claude-plugin/marketplace.json ---
36+
const marketplacePath = path.join(ROOT, ".claude-plugin", "marketplace.json");
37+
if (fs.existsSync(marketplacePath)) {
38+
const marketplace = JSON.parse(fs.readFileSync(marketplacePath, "utf-8"));
39+
for (const p of marketplace.plugins || []) {
40+
p.version = version;
41+
}
42+
fs.writeFileSync(
43+
marketplacePath,
44+
JSON.stringify(marketplace, null, 2) + "\n"
45+
);
46+
}
47+
48+
// --- SKILL.md files (update pinned @version in install instructions) ---
49+
const skillPaths = [
50+
"skills/interactive-leetcode-mcp/SKILL.md",
51+
".claude/skills/using-interactive-leetcode-mcp/SKILL.md",
52+
"clawhub-skill/interactive-leetcode-mcp/SKILL.md",
53+
];
54+
55+
const versionPattern =
56+
/@sperekrestova\/interactive-leetcode-mcp@[\w.-]+/g;
57+
const versionReplacement = `@sperekrestova/interactive-leetcode-mcp@${version}`;
58+
59+
for (const rel of skillPaths) {
60+
const fullPath = path.join(ROOT, rel);
61+
if (!fs.existsSync(fullPath)) continue;
62+
const content = fs.readFileSync(fullPath, "utf-8");
63+
const updated = content.replace(versionPattern, versionReplacement);
64+
if (updated !== content) {
65+
fs.writeFileSync(fullPath, updated);
66+
}
67+
}
68+
69+
console.log(`Synced version ${version} to all targets.`);

server.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"url": "https://github.com/SPerekrestova/interactive-leetcode-mcp",
77
"source": "github"
88
},
9-
"version": "3.1.0",
9+
"version": "3.2.0",
1010
"packages": [
1111
{
1212
"registryType": "npm",
1313
"identifier": "@sperekrestova/interactive-leetcode-mcp",
14-
"version": "3.1.0",
14+
"version": "3.2.0",
1515
"transport": {
1616
"type": "stdio"
1717
},

0 commit comments

Comments
 (0)