LeetCode MCP Server
The LeetCode MCP Server enables programmatic interaction with LeetCode APIs to access problems, user data, and solutions for automation and analysis.
Retrieve daily challenges and detailed problem information (descriptions, constraints, examples)
Search problems using filters (categories, difficulty, tags, keywords)
Access user profiles, contest rankings, and submission histories
View community solutions and their content
Manage authenticated user data (problem-solving progress, submissions, notes)
Utilize pagination and filtering capabilities for efficient data retrieval
Support for both LeetCode Global (leetcode.com) and China (leetcode.cn) platforms
Provides tools for accessing LeetCode problems, user data, search capabilities, and submission tracking across both leetcode.com and leetcode.cn platforms. Enables retrieval of detailed problem descriptions, user profiles, submission history, and contest performance statistics.
Click on "Install 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 Serverget today's daily challenge problem"
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, 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: Linear 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 |
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)
Solutions
list_problem_solutions - Retrieves a list of community solutions for a specific problem
questionSlug: The URL slug/identifier of the problem (string, required)limit: Maximum number of solutions to return (number, optional, default: 10)skip: Number of solutions to skip (number, optional)userInput: Search term to filter solutions (string, optional)tagSlugs: Array of tag identifiers to filter solutions (string[], optional, default: [])orderBy: Sorting criteria for the returned solutionsGlobal: enum: "HOT", "MOST_RECENT", "MOST_VOTES", optional, default: "HOT"
CN: enum: "DEFAULT", "MOST_UPVOTE", "HOT", "NEWEST_TO_OLDEST", "OLDEST_TO_NEWEST", optional, default: "DEFAULT"
get_problem_solution - Retrieves the complete content of a specific solution
topicId: Unique topic ID of the solution (string, required, Global only)slug: Unique slug/identifier of the solution (string, required, CN only)
Available Resources
Resource Name | Global | CN | Auth Required | Description |
problem-categories | β | β | β | A list of all problem classification categories |
problem-tags | β | β | β | A detailed collection of algorithmic and data structure tags |
problem-langs | β | β | β | A complete list of all supported programming languages |
problem-detail | β | β | β | Provides details about a specific problem |
problem-solution | β | β | β | Provides the complete content of a specific solution |
Resource URIs
problem-categories - A list of all problem classification categories
URI:
categories://problems/all
problem-tags - A detailed collection of algorithmic and data structure tags
URI:
tags://problems/all
problem-langs - A complete list of all programming languages supported by LeetCode
URI:
langs://problems/all
problem-detail - Provides details about a specific LeetCode problem
URI:
problem://{titleSlug}Parameters:
titleSlug: Problem identifier as it appears in the LeetCode URL
problem-solution - Provides the complete content of a specific solution
Global URI:
solution://{topicId}Parameters:
topicId: Unique topic ID of the solution
CN URI:
solution://{slug}Parameters:
slug: Unique slug/identifier of the solution
Authentication
User-specific data access requires LeetCode session authentication:
Extract
LEETCODE_SESSIONcookie from browser developer toolsConfigure server with
--sessionflag orLEETCODE_SESSIONenvironment variable
Response Format
All tools return JSON-formatted responses with the following structure:
{
"content": [
{
"type": "text",
"text": "JSON_DATA_STRING"
}
]
}The JSON_DATA_STRING contains either the requested data or an error message for failed requests.
License
This project is licensed under the MIT License.
Available Tools
1 toolget_problem_solutionA
Retrieves full content of a community solution article (read-only, no auth). Requires topicId from list_problem_solutions. Returns article text, author, and metadata as JSON. Use list_problem_solutions first to discover solutions and obtain topicId.
| Name | Required | Description | Default |
|---|---|---|---|
| topicId | Yes | Solution topicId from list_problem_solutions response |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description fully covers behavioral traits: read-only, no authentication, and return format (JSON with text, author, metadata).
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?
Three concise sentences, front-loaded with purpose and safety, no wasted words.
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?
Complete for a simple retrieval tool with one parameter and no output schema; mentions return fields and prerequisite step. Could specify error cases, but not required.
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?
Schema coverage is 100%, baseline 3. The description adds value by explaining the topicId's origin from list_problem_solutions, which is not in the schema.
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?
The description clearly states 'Retrieves full content of a community solution article' with specific verb and resource. It is unambiguous and needs no sibling differentiation.
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?
Explicitly instructs to first use list_problem_solutions to obtain topicId, providing clear prerequisite and sequential usage guidance.
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. Dates show when Glama detected each change.
2 tool updates
v1.4.0- Added
get_problem_solution - Removed
get_user_contest_ranking
9 tool updates
v1.4.0- Removed
get_daily_challenge - Removed
get_problem - Removed
get_problem_solution - Removed
get_recent_ac_submissions - Removed
get_recent_submissions - Changed
get_user_contest_ranking2 fields changed- changed
Input schema / properties / attended / descriptionPrevious value: -"Whether to include only the contests the user has participated in (true) or all contests (false); defaults to true"New value: +"true = only contests the user attended (default); false = include all contests in history" - changed
Input schema / properties / username / descriptionPrevious value: -"LeetCode username to retrieve contest ranking information for"New value: +"LeetCode username whose contest ranking to fetch"
- Removed
get_user_profile - Removed
list_problem_solutions - Removed
search_problems
1 tool update
v1.0.0- Changed
get_daily_challenge1 field changed- removed
Input schema / additionalPropertiesRemoved value: -false
9 tool updates
- First observed
get_daily_challenge - First observed
get_problem - First observed
get_problem_solution - First observed
get_recent_ac_submissions - First observed
get_recent_submissions - First observed
get_user_contest_ranking - First observed
get_user_profile - First observed
list_problem_solutions - First observed
search_problems
TDQS
Only one tool exists, so there is no ambiguity with other tools. However, the tool's dependency on a missing listing tool could cause confusion for agents trying to use it.
With a single tool, naming is trivially consistent. The pattern 'get_problem_solution' follows verb_noun convention.
A single tool for a LeetCode server is far too few. Expected operations (list problems, get problem details, submit solutions, etc.) are missing, making the surface extremely limited.
The only tool requires a topicId from a non-existent list_problem_solutions tool, rendering it unusable. The surface is severely incomplete.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yoβ¦
A Model Context Protocol server for Wix AI tools
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Model Context Protocol server for Studex tools, notifications, and profile integrations
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceServer that enhances the capabilities of the Cline coding agent. It provides intelligent code suggestions, reduces hallucinations, and documents the knowledge base by leveraging your project's documentation and detecting the technologies used in your codebase.15MIT
- AlicenseAqualityCmaintenanceA Model Context Protocol server that enables large language models to interact with Linear's issue tracking system, allowing management of issues, projects, teams, and other Linear resources.19241MIT
- AlicenseCqualityFmaintenanceA Model Context Protocol (MCP) server for LeetCode that enables AI assistants to access LeetCode problems, user information, and contest data.72443MIT
- FlicenseNot gradedqualityNot gradedmaintenanceModel Context Protocol server that enables interaction with GitHub repositories, issues, pull requests, and search functionality through natural language.1-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jinzcdev/leetcode-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server