The LeetCode MCP Server is a Model Context Protocol (MCP) server that provides seamless integration with LeetCode APIs, enabling advanced automation and intelligent interaction with LeetCode's programming problems, contests, solutions, and user data. - ๐ Multi-site Support: Supportโ both leetcode.com (Global) and leetcode.cn (China) platforms - ๐ Problem Data Retrieval: Obtain detailed problem d
Add this skill
npx mdskills install jinzcdev/leetcode-mcp-serverComprehensive LeetCode API integration with excellent tool coverage, clear documentation, and well-organized setup instructions
1# LeetCode MCP Server23[](https://www.npmjs.com/package/@jinzcdev/leetcode-mcp-server)4[](https://img.shields.io/github/license/jinzcdev/leetcode-mcp-server.svg)5[](https://smithery.ai/server/@jinzcdev/leetcode-mcp-server)6[](README_zh-CN.md)7[](https://github.com/jinzcdev/leetcode-mcp-server)89The LeetCode MCP Server is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) server that provides seamless integration with LeetCode APIs, enabling advanced automation and intelligent interaction with LeetCode's programming problems, contests, solutions, and user data.1011<a href="https://glama.ai/mcp/servers/@jinzcdev/leetcode-mcp-server">12 <img width="380" height="200" src="https://glama.ai/mcp/servers/@jinzcdev/leetcode-mcp-server/badge" alt="LeetCode Server MCP server" />13</a>1415## Features1617- ๐ **Multi-site Support**: Supportโ both leetcode.com (Global) and leetcode.cn (China) platforms18- ๐ **Problem Data Retrieval**: Obtain detailed problem descriptions, constraints, examples, official editorials, and โuser-submitted solutions19- ๐ค **User Data Access**: Retrieve user profiles, submission history, and contest performance20- ๐ **โPrivate Data Access**: Create and query user notes, track problem-solving progress, and analyze submission details (AC/WA analysis)21- ๐ **Advanced Search Capabilities**: Filter problems by tags, difficulty levels, categories, and keywords22- ๐ **Daily Challenge Access**: Easily access daily challenge problems2324## Prerequisites25261. Node.js (v20.x or above)272. (Optional) LeetCode session cookie for authenticated API access2829## Installation3031### Installing via Smithery3233To install leetcode-mcp-server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@jinzcdev/leetcode-mcp-server):3435```bash36npx -y @smithery/cli install @jinzcdev/leetcode-mcp-server --client claude37```3839### Manual Installation4041```bash42# Install from npm43npm install @jinzcdev/leetcode-mcp-server -g4445# Or run with Global site configuration46npx -y @jinzcdev/leetcode-mcp-server --site global4748# Run with authentication (for accessing private data)49npx -y @jinzcdev/leetcode-mcp-server --site global --session <YOUR_LEETCODE_SESSION_COOKIE>50```5152Alternatively, you can clone the repository and run it locally:5354```bash55# Clone the repository56git clone https://github.com/jinzcdev/leetcode-mcp-server.git5758# Navigate to the project directory59cd leetcode-mcp-server6061# Build the project62npm install && npm run build6364# Run the server65node build/index.js --site global66```6768## Usage6970### Visual Studio Code Integration7172Add the following JSON configuration to your User Settings (JSON) file. Access this by pressing `Ctrl/Cmd + Shift + P` and searching for `Preferences: Open User Settings (JSON)`.7374#### Option 1: Using Environment Variables7576```json77{78 "mcp": {79 "servers": {80 "leetcode": {81 "type": "stdio",82 "command": "npx",83 "args": ["-y", "@jinzcdev/leetcode-mcp-server"],84 "env": {85 "LEETCODE_SITE": "global",86 "LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"87 }88 }89 }90 }91}92```9394#### Option 2: Using Command Line Arguments9596```json97{98 "mcp": {99 "servers": {100 "leetcode": {101 "type": "stdio",102 "command": "npx",103 "args": [104 "-y",105 "@jinzcdev/leetcode-mcp-server",106 "--site",107 "global",108 "--session",109 "<YOUR_LEETCODE_SESSION_COOKIE>"110 ]111 }112 }113 }114}115```116117For LeetCode China site, modify the `--site` parameter to `cn`.118119> [!TIP]120>121> The server supports the following optional environment variables:122>123> - `LEETCODE_SITE`: LeetCode API endpoint ('global' or 'cn', default: 'global')124> - `LEETCODE_SESSION`: LeetCode session cookie for authenticated API access (default: empty)125>126> **Priority Note**:127> Command-line arguments take precedence over environment variables when both are specified. For example:128>129> - If `LEETCODE_SITE=cn` is set but you run `leetcode-mcp-server --site global`, the server will use `global`.130> - If `LEETCODE_SESSION` exists but you provide `--session "new_cookie"`, the command-line session value will be used.131132## Available Tools133134### Problems135136| Tool | Global | CN | Auth Required | Description |137| ----------------------- | :----: | :-: | :-----------: | ------------------------------------------------------------ |138| **get_daily_challenge** | โ | โ | โ | Retrieves today's LeetCode Daily Challenge problem |139| **get_problem** | โ | โ | โ | Retrieves details for a specific LeetCode problem |140| **search_problems** | โ | โ | โ | Searches for LeetCode problems with multiple filter criteria |141142### Users143144| Tool | Global | CN | Auth Required | Description |145| --------------------------------- | :----: | :-: | :-----------: | ------------------------------------------------------------ |146| **get_user_profile** | โ | โ | โ | Retrieves profile information for a LeetCode user |147| **get_user_contest_ranking** | โ | โ | โ | Obtains contest ranking statistics for a user |148| **get_recent_ac_submissions** | โ | โ | โ | Retrieves a user's recent accepted submissions |149| **get_recent_submissions** | โ | โ | โ | Retrieves a user's recent submissions history |150| **get_user_status** | โ | โ | โ | Retrieves current user's current status |151| **get_problem_submission_report** | โ | โ | โ | Provides detailed submission analysis for a specific problem |152| **get_problem_progress** | โ | โ | โ | Retrieves current user's problem-solving progress |153| **get_all_submissions** | โ | โ | โ | Retrieves current user's submission history |154155### Notes156157| Tool | Global | CN | Auth Required | Description |158| ---------------- | :----: | :-: | :-----------: | ----------------------------------------------------- |159| **search_notes** | โ | โ | โ | Searches for user notes with filtering options |160| **get_note** | โ | โ | โ | Retrieves notes for a specific problem by question ID |161| **create_note** | โ | โ | โ | Creates a new note for a specific problem |162| **update_note** | โ | โ | โ | Updates an existing note with new content |163164### Solutions165166| Tool | Global | CN | Auth Required | Description |167| -------------------------- | :----: | :-: | :-----------: | -------------------------------------------------------------- |168| **list_problem_solutions** | โ | โ | โ | Retrieves a list of community solutions for a specific problem |169| **get_problem_solution** | โ | โ | โ | Retrieves the complete content of a specific solution |170171## Tool Parameters172173### Problems174175- **get_daily_challenge** - Retrieves today's LeetCode Daily Challenge problem with complete details176177 - No parameters required178179- **get_problem** - Retrieves details about a specific LeetCode problem180181 - `titleSlug`: The URL slug/identifier of the problem (string, required)182183- **search_problems** - Searches for LeetCode problems based on multiple filter criteria184 - `category`: Problem category filter (string, optional, default: "all-code-essentials")185 - `tags`: List of topic tags to filter problems by (string[], optional)186 - `difficulty`: Problem difficulty level filter (enum: "EASY", "MEDIUM", "HARD", optional)187 - `searchKeywords`: Keywords to search in problem titles and descriptions (string, optional)188 - `limit`: Maximum number of problems to return (number, optional, default: 10)189 - `offset`: Number of problems to skip (number, optional)190191### Users192193- **get_user_profile** - Retrieves profile information about a LeetCode user194195 - `username`: LeetCode username (string, required)196197- **get_user_contest_ranking** - Retrieves a user's contest ranking information198199 - `username`: LeetCode username (string, required)200 - `attended`: Whether to include only the contests the user has participated in (boolean, optional, default: true)201202- **get_recent_submissions** - Retrieves a user's recent submissions on LeetCode Global203204 - `username`: LeetCode username (string, required)205 - `limit`: Maximum number of submissions to return (number, optional, default: 10)206207- **get_recent_ac_submissions** - Retrieves a user's recent accepted submissions208209 - `username`: LeetCode username (string, required)210 - `limit`: Maximum number of submissions to return (number, optional, default: 10)211212- **get_user_status** - Retrieves the current user's status213214 - No parameters required215216- **get_problem_submission_report** - Retrieves detailed information about a specific submission217218 - `id`: The numerical submission ID (number, required)219220- **get_problem_progress** - Retrieves the current user's problem-solving progress221222 - `offset`: Number of questions to skip (number, optional, default: 0)223 - `limit`: Maximum number of questions to return (number, optional, default: 100)224 - `questionStatus`: Filter by question status (enum: "ATTEMPTED", "SOLVED", optional)225 - `difficulty`: Filter by difficulty levels (string[], optional)226227- **get_all_submissions** - Retrieves paginated list of user's submissions228 - `limit`: Maximum number of submissions to return (number, default: 20)229 - `offset`: Number of submissions to skip (number, default: 0)230 - `questionSlug`: Optional problem identifier (string, optional)231 - `lang`: Programming language filter (string, optional, CN only)232 - `status`: Submission status filter (enum: "AC", "WA", optional, CN only)233 - `lastKey`: Pagination token for retrieving next page (string, optional, CN only)234235### Notes236237- **search_notes** - Searches for user notes on LeetCode China238239 - `keyword`: Search term to filter notes (string, optional)240 - `limit`: Maximum number of notes to return (number, optional, default: 10)241 - `skip`: Number of notes to skip (number, optional, default: 0)242 - `orderBy`: Sort order for returned notes (enum: "ASCENDING", "DESCENDING", optional, default: "DESCENDING")243244- **get_note** - Retrieves user notes for a specific LeetCode problem245 - `questionId`: The question ID of the LeetCode problem (string, required)246 - `limit`: Maximum number of notes to return (number, optional, default: 10)247 - `skip`: Number of notes to skip (number, optional, default: 0)248- **create_note** - Creates a new note for a specific LeetCode problem249250 - `questionId`: The question ID of the LeetCode problem (string, required)251 - `content`: The content of the note, supports markdown format (string, required)252 - `summary`: An optional short summary or title for the note (string, optional)253254- **update_note** - Updates an existing note with new content or summary255 - `noteId`: The ID of the note to update (string, required)256 - `content`: The new content for the note, supports markdown format (string, required)257 - `summary`: An optional new short summary or title for the note (string, optional)258259### Solutions260261- **list_problem_solutions** - Retrieves a list of community solutions for a specific problem262263 - `questionSlug`: The URL slug/identifier of the problem (string, required)264 - `limit`: Maximum number of solutions to return (number, optional, default: 10)265 - `skip`: Number of solutions to skip (number, optional)266 - `userInput`: Search term to filter solutions (string, optional)267 - `tagSlugs`: Array of tag identifiers to filter solutions (string[], optional, default: [])268 - `orderBy`: Sorting criteria for the returned solutions269 - Global: enum: "HOT", "MOST_RECENT", "MOST_VOTES", optional, default: "HOT"270 - CN: enum: "DEFAULT", "MOST_UPVOTE", "HOT", "NEWEST_TO_OLDEST", "OLDEST_TO_NEWEST", optional, default: "DEFAULT"271272- **get_problem_solution** - Retrieves the complete content of a specific solution273 - `topicId`: Unique topic ID of the solution (string, required, Global only)274 - `slug`: Unique slug/identifier of the solution (string, required, CN only)275276## Available Resources277278| Resource Name | Global | CN | Auth Required | Description |279| ---------------------- | :----: | :-: | :-----------: | ------------------------------------------------------------ |280| **problem-categories** | โ | โ | โ | A list of all problem classification categories |281| **problem-tags** | โ | โ | โ | A detailed collection of algorithmic and data structure tags |282| **problem-langs** | โ | โ | โ | A complete list of all supported programming languages |283| **problem-detail** | โ | โ | โ | Provides details about a specific problem |284| **problem-solution** | โ | โ | โ | Provides the complete content of a specific solution |285286## Resource URIs287288- **problem-categories** - A list of all problem classification categories289290 - URI: `categories://problems/all`291292- **problem-tags** - A detailed collection of algorithmic and data structure tags293294 - URI: `tags://problems/all`295296- **problem-langs** - A complete list of all programming languages supported by LeetCode297298 - URI: `langs://problems/all`299300- **problem-detail** - Provides details about a specific LeetCode problem301302 - URI: `problem://{titleSlug}`303 - Parameters:304 - `titleSlug`: Problem identifier as it appears in the LeetCode URL305306- **problem-solution** - Provides the complete content of a specific solution307 - Global URI: `solution://{topicId}`308 - Parameters:309 - `topicId`: Unique topic ID of the solution310 - CN URI: `solution://{slug}`311 - Parameters:312 - `slug`: Unique slug/identifier of the solution313314## Authentication315316User-specific data access requires LeetCode session authentication:3173181. Log in to LeetCode ([Global](https://leetcode.com) or [China](https://leetcode.cn) site)3192. Extract `LEETCODE_SESSION` cookie from browser developer tools3203. Configure server with `--session` flag or `LEETCODE_SESSION` environment variable321322## Response Format323324All tools return JSON-formatted responses with the following structure:325326```json327{328 "content": [329 {330 "type": "text",331 "text": "JSON_DATA_STRING"332 }333 ]334}335```336337The `JSON_DATA_STRING` contains either the requested data or an error message for failed requests.338339## License340341This project is licensed under the MIT License.342
Full transparency โ inspect the skill content before installing.