LeetCode MCP Server
Provides tools for interacting with LeetCode APIs on both leetcode.com and leetcode.cn, enabling problem search, daily challenges, problem details and editorials, user profiles, contest rankings, submission history, authenticated private data such as notes and problem lists, and running or submitting code.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LeetCode MCP Servershow me today's daily LeetCode challenge"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LeetCode MCP Server
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.
Features
π Multi-site Support: Supportβ both leetcode.com (Global) and leetcode.cn (China) platforms
π Dual Transport Modes: Run as a stdio process (default) or as a Streamable HTTP server for web-based integrations
π Problem Data Retrieval: Obtain detailed problem descriptions, constraints, examples, official editorials, and βuser-submitted solutions
π€ User Data Access: Retrieve user profiles, submission history, and contest performance
π βPrivate Data Access: Create and query user notes, manage problem lists, track problem-solving progress, and analyze submission details (AC/WA analysis)
π Advanced Search Capabilities: Filter problems by tags, difficulty levels, categories, and keywords
π Daily Challenge Access: Easily access daily challenge problems
Related MCP server: LeetCode MCP Server
Prerequisites
Node.js (v20.x or above)
(Optional) LeetCode session cookie for authenticated API access
Installation
# Install from npm
npm install @jinzcdev/leetcode-mcp-server -g
# Run with Global site configuration (stdio transport, default)
npx -y @jinzcdev/leetcode-mcp-server --site global
# Run with authentication (for accessing private data)
npx -y @jinzcdev/leetcode-mcp-server --site global --session <YOUR_LEETCODE_SESSION_COOKIE>
# Run as a Streamable HTTP server
npx -y @jinzcdev/leetcode-mcp-server --transport http --port 3000 --site globalAlternatively, you can clone the repository and run it locally:
# Clone the repository
git clone https://github.com/jinzcdev/leetcode-mcp-server.git
# Navigate to the project directory
cd leetcode-mcp-server
# Build the project
npm install && npm run build
# Run the server (stdio transport)
node build/index.js --site global
# Or run as a Streamable HTTP server
node build/index.js --transport http --port 3000 --site globalUsage
The server supports two transport modes:
Transport | Description |
| Standard input/output transport for local MCP clients |
| Streamable HTTP transport for web-based integrations and remote access |
Command-Line Options
Option | Alias | Default | Description |
|
|
| LeetCode API site: |
|
| β | LeetCode session cookie for authenticated requests |
|
|
| Transport mode: |
| β |
| HTTP server port (Streamable HTTP only) |
| β |
| HTTP server host (Streamable HTTP only) |
| β |
| HTTP endpoint path (Streamable HTTP only) |
MCP Client Configuration (stdio)
Add the following server entry to your MCP client configuration file:
Option 1: Using Environment Variables
{
"mcpServers": {
"leetcode": {
"command": "npx",
"args": ["-y", "@jinzcdev/leetcode-mcp-server"],
"env": {
"LEETCODE_SITE": "global",
"LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"
}
}
}
}Option 2: Using Command Line Arguments
{
"mcpServers": {
"leetcode": {
"command": "npx",
"args": [
"-y",
"@jinzcdev/leetcode-mcp-server",
"--site",
"global",
"--session",
"<YOUR_LEETCODE_SESSION_COOKIE>"
]
}
}
}For LeetCode China site, modify the --site parameter to cn.
The exact configuration file location and JSON structure may vary by MCP client. Some clients use an mcp.servers wrapper or a type field β refer to your client's documentation and adapt the example accordingly.
MCP Client Configuration (Streamable HTTP)
First, start the server in HTTP mode:
npx -y @jinzcdev/leetcode-mcp-server --transport http --port 3000 --site globalThen connect your MCP client to the running server:
{
"mcpServers": {
"leetcode": {
"type": "http",
"url": "http://127.0.0.1:3000/mcp"
}
}
}To use authenticated endpoints, pass the session cookie when starting the server:
npx -y @jinzcdev/leetcode-mcp-server --transport http --port 3000 --site global --session <YOUR_LEETCODE_SESSION_COOKIE>Some MCP clients use"type": "http" or "type": "streamableHttp" alongside the url field. Refer to your client's documentation for the exact HTTP transport configuration format.
The server supports the following optional environment variables:
LEETCODE_SITE: LeetCode API endpoint (globalorcn, default:global)LEETCODE_SESSION: LeetCode session cookie for authenticated API access (default: empty)LEETCODE_TRANSPORT: Transport mode (stdioorhttp, default:stdio)LEETCODE_HTTP_PORT: HTTP server port when using Streamable HTTP (default:3000)LEETCODE_HTTP_HOST: HTTP server host when using Streamable HTTP (default:127.0.0.1)LEETCODE_HTTP_ENDPOINT: HTTP endpoint path when using Streamable HTTP (default:/mcp)
Priority Note: Command-line arguments take precedence over environment variables when both are specified. For example:
If
LEETCODE_SITE=cnis set but you runleetcode-mcp-server --site global, the server will useglobal.If
LEETCODE_SESSIONexists but you provide--session "new_cookie", the command-line session value will be used.
Available Tools
Problems
Tool | Global | CN | Auth Required | Description |
get_daily_challenge | β | β | β | Retrieves today's LeetCode Daily Challenge problem |
get_problem | β | β | β | Retrieves details for a specific LeetCode problem |
search_problems | β | β | β | Searches for LeetCode problems with multiple filter criteria |
Users
Tool | Global | CN | Auth Required | Description |
get_user_profile | β | β | β | Retrieves profile information for a LeetCode user |
get_user_contest_ranking | β | β | β | Obtains contest ranking statistics for a user |
get_recent_ac_submissions | β | β | β | Retrieves a user's recent accepted submissions |
get_recent_submissions | β | β | β | Retrieves a user's recent submissions history |
get_user_status | β | β | β | Retrieves current user's current status |
get_problem_submission_report | β | β | β | Provides detailed submission analysis for a specific problem |
get_problem_progress | β | β | β | Retrieves current user's problem-solving progress |
get_all_submissions | β | β | β | Retrieves current user's submission history |
Submissions
Tool | Global | CN | Auth Required | Description |
run_code | β | β | β | Runs code for a problem and polls |
submit_solution | β | β | β | Submits code for a problem and polls |
Notes
Tool | Global | CN | Auth Required | Description |
search_notes | β | β | β | Searches for user notes with filtering options |
get_note | β | β | β | Retrieves notes for a specific problem by question ID |
create_note | β | β | β | Creates a new note for a specific problem |
update_note | β | β | β | Updates an existing note with new content |
Problem Lists
Tool | Global | CN | Auth Required | Description |
list_problem_lists | β | β | β | Lists the current user's problem lists (favorites) |
get_problem_list | β | β | β | Retrieves a problem list's metadata and its questions |
create_problem_list | β | β | β | Creates a new problem list, optionally with initial problems |
update_problem_list | β | β | β | Renames a problem list, edits its description or visibility |
add_problems_to_list | β | β | β | Adds problems to a problem list by slug or problem number |
remove_problems_from_list | β | β | β | Removes problems from a problem list |
reorder_problem_list | β | β | β | Reorders the problems inside a problem list |
Solutions
Tool | Global | CN | Auth Required | Description |
list_problem_solutions | β | β | β | Retrieves a list of community solutions for a specific problem |
get_problem_solution | β | β | β | Retrieves the complete content of a specific solution |
Tool Parameters
Problems
get_daily_challenge - Retrieves today's LeetCode Daily Challenge problem with complete details
No parameters required
get_problem - Retrieves details about a specific LeetCode problem
titleSlug: The URL slug/identifier of the problem (string, required)
search_problems - Searches for LeetCode problems based on multiple filter criteria
category: Problem category filter (string, optional, default: "all-code-essentials")tags: List of topic tags to filter problems by (string[], optional)difficulty: Problem difficulty level filter (enum: "EASY", "MEDIUM", "HARD", optional)searchKeywords: Keywords to search in problem titles and descriptions (string, optional)limit: Maximum number of problems to return (number, optional, default: 10)offset: Number of problems to skip (number, optional)
Users
get_user_profile - Retrieves profile information about a LeetCode user
username: LeetCode username (string, required)
get_user_contest_ranking - Retrieves a user's contest ranking information
username: LeetCode username (string, required)attended: Whether to include only the contests the user has participated in (boolean, optional, default: true)
get_recent_submissions - Retrieves a user's recent submissions on LeetCode Global
username: LeetCode username (string, required)limit: Maximum number of submissions to return (number, optional, default: 10)
get_recent_ac_submissions - Retrieves a user's recent accepted submissions
username: LeetCode username (string, required)limit: Maximum number of submissions to return (number, optional, default: 10)
get_user_status - Retrieves the current user's status
No parameters required
get_problem_submission_report - Retrieves detailed information about a specific submission
id: The numerical submission ID (number, required)
get_problem_progress - Retrieves the current user's problem-solving progress
offset: Number of questions to skip (number, optional, default: 0)limit: Maximum number of questions to return (number, optional, default: 100)questionStatus: Filter by question status (enum: "ATTEMPTED", "SOLVED", optional)difficulty: Filter by difficulty levels (string[], optional)
get_all_submissions - Retrieves paginated list of user's submissions
limit: Maximum number of submissions to return (number, default: 20)offset: Number of submissions to skip (number, default: 0)questionSlug: Optional problem identifier (string, optional)lang: Programming language filter (string, optional, CN only)status: Submission status filter (enum: "AC", "WA", optional, CN only)lastKey: Pagination token for retrieving next page (string, optional, CN only)
Submissions
run_code - Runs code for a specific problem and waits until finished (requires authentication)
titleSlug: The URL slug/identifier of the problem (string, required)lang: Programming language (string enum, required)typedCode: Source code to run (string, required)dataInput: Custom input to run (string, optional)timeoutMs: Polling timeout in milliseconds (number, optional, default: 120000)pollIntervalMs: Polling interval in milliseconds (number, optional, default: 1500)
submit_solution - Submits code for a specific problem and waits until finished (requires authentication)
titleSlug: The URL slug/identifier of the problem (string, required)lang: Programming language (string enum, required)typedCode: Source code to submit (string, required)timeoutMs: Polling timeout in milliseconds (number, optional, default: 120000)pollIntervalMs: Polling interval in milliseconds (number, optional, default: 1500)
Notes
search_notes - Searches for user notes on LeetCode China
keyword: Search term to filter notes (string, optional)limit: Maximum number of notes to return (number, optional, default: 10)skip: Number of notes to skip (number, optional, default: 0)orderBy: Sort order for returned notes (enum: "ASCENDING", "DESCENDING", optional, default: "DESCENDING")
get_note - Retrieves user notes for a specific LeetCode problem
questionId: The question ID of the LeetCode problem (string, required)limit: Maximum number of notes to return (number, optional, default: 10)skip: Number of notes to skip (number, optional, default: 0)
create_note - Creates a new note for a specific LeetCode problem
questionId: The question ID of the LeetCode problem (string, required)content: The content of the note, supports markdown format (string, required)summary: An optional short summary or title for the note (string, optional)
update_note - Updates an existing note with new content or summary
noteId: The ID of the note to update (string, required)content: The new content for the note, supports markdown format (string, required)summary: An optional new short summary or title for the note (string, optional)
Problem Lists
Problem lists are identified by their favoriteSlug, the path segment after /problem-list/ in the list URL.
list_problem_lists - Lists the current user's problem lists
includeCollected: Also return lists saved from other creators (boolean, optional, default: false)
get_problem_list - Retrieves a problem list's metadata and a page of its questions
favoriteSlug: The slug of the problem list (string, required)limit: Maximum number of questions to return (number, optional, default: 50)skip: Number of questions to skip (number, optional, default: 0)searchKeyword: Keyword to filter questions by title (string, optional)sortField: Sort field:CUSTOM(the order shown on the website),FRONTEND_ID,DIFFICULTY,AC_RATE,FREQUENCYorCONTEST_POINT(string, optional, default:CUSTOM)sortOrder:ASCENDINGorDESCENDING(string, optional, default:ASCENDING)
create_problem_list - Creates a new problem list
name: Display name of the list (string, required)description: Description of the list (string, optional, default: "")isPublic: Whether the list is publicly visible (boolean, optional, default: false)questionSlugs: Problem slugs to add right after creation (string[], optional)questionIds: Problem numbers to add right after creation, e.g.[1, 1143]; numbers that cannot be resolved are returned inunresolved((string | number)[], optional)
update_problem_list - Renames a problem list, changes its description or toggles its visibility (at least one optional field is required)
favoriteSlug: The slug of the problem list (string, required)name: New display name (string, optional)description: New description (string, optional)isPublic: New visibility (boolean, optional)
add_problems_to_list - Adds problems to a problem list (at least one of
questionSlugs/questionIdsis required; problems are appended in the given order, slugs first)favoriteSlug: The slug of the problem list (string, required)questionSlugs: Problem slugs to add, e.g.["two-sum"](string[], optional)questionIds: Problem numbers to add, e.g.[1, 1143]or["LCP 82"]; numbers that cannot be resolved are returned inunresolved((string | number)[], optional)
remove_problems_from_list - Removes problems from a problem list
favoriteSlug: The slug of the problem list (string, required)questionSlugs: Problem slugs to remove (string[], required)
reorder_problem_list - Reorders the problems inside a problem list (exactly one of
sortField/questionSlugsis required; one problem is
This server cannot be deployed
Maintenance
Related MCP Connectors
Search Luogu problems, fetch statements, explore problem sets and get practice recommendations.
Search Codeforces problems and inspect public problem metadata through the official Codeforces API.
Access the GitHub API, enabling file operations, repository management, search functionality, andβ¦
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceEnables automated access to programming problems, contests, solutions, notes, and submission data on both leetcode.com and leetcode.cn, with optional session-cookie authentication for user-specific features like progress tracking, code running, and solution submission.-
- FlicenseNot gradedqualityAmaintenanceEnables automated access to programming problems, contests, official editorials, user-submitted solutions, and user profiles on both leetcode.com and leetcode.cn. Optional session-cookie authentication unlocks private features such as notes, submission history, progress tracking, and code running or submission.-
- FlicenseNot gradedqualityAmaintenanceEnables automated access to LeetCode problems, solutions, contests, and public user data across leetcode.com and leetcode.cn, with optional authentication for private features like notes, progress, submissions, and code execution.-
- FlicenseNot gradedqualityAmaintenanceEnables automated access to LeetCode problems, contests, solutions, and user data across leetcode.com and leetcode.cn, with optional authentication for private features like notes, progress, and submissions. Supports retrieval, search, daily challenges, code execution, and submission workflows.-