LeetCode MCP Server is a Model Context Protocol (MCP) server designed to provide seamless integration with LeetCode APIs, enabling advanced automation and intelligent interaction with LeetCode programming problems, contests, solutions, and user data.
Main capabilities
- Multi-site support: supports both the leetcode.com (global) and leetcode.cn (China) platforms.
- Dual transport modes: can run as a stdio process (default), or as a Streamable HTTP server, facilitating web-based integration.
- Problem data retrieval: fetch detailed problem descriptions, constraints, examples, official solutions, 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 level, category, and keywords.
- Daily challenge access: easily access the daily challenge problem.
Usage Runtime requirements: Node.js (v20.x or above); optional: LeetCode session Cookie for authenticated API access. You can also clone the repository and run it locally.
The server supports two transport modes:
Command-line options Environment variables:
- LEETCODE_SITE: LeetCode API endpoint (global or cn, default: global)
- LEETCODE_SESSION: LeetCode session Cookie for authenticated API access (default: empty)
- LEETCODE_TRANSPORT: transport mode (stdio or http, 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: when both are specified, command-line arguments take precedenceover environment variables. For example: if LEETCODE_SITE=cn is set but leetcode-mcp-server --site global is run, the server will use global; if LEETCODE_SESSION exists but --session "new_cookie" is provided, the command-line session value will be used.
MCP client configuration (stdio): add a server entry in the MCP client configuration file. For LeetCode China, change 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—please refer to the client documentation and adjust the example accordingly.
MCP client configuration (Streamable HTTP): first start the server in HTTP mode, then connect the MCP client to the running server. To use authenticated endpoints, pass the session Cookie when starting the server. Some MCP clients use "type": "http" or "type": "streamableHttp" along with a url field. Please refer to the client documentation for the exact HTTP transport configuration format.
Available tools
- get_daily_challenge: get today's LeetCode daily challenge problem with full details. No parameters.
- get_problem: get the details of a specific LeetCode problem. Parameters: titleSlug (the problem's URL slug/identifier, string, required).
- search_problems: search LeetCode problems based on multiple filter conditions. Parameters: category (problem category filter, string, optional, default "all-code-essentials"), tags (list of topic tags used to filter problems, 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).
- get_user_profile: Get LeetCode user profile information. Parameters: username (LeetCode username, string, required).
- get_user_contest_ranking: Get the user's contest ranking information. Parameters: username (LeetCode username, string, required), attended (whether to include only contests the user has attended, boolean, optional, default true).
- get_recent_submissions: Get the user's recent submissions on LeetCode Global. Parameters: username (string, required), limit (maximum number of submissions to return, number, optional, default 10).
- get_recent_ac_submissions: Get the user's recent accepted submissions. Parameters: username (string, required), limit (number, optional, default 10).
- get_user_status: Get the current user's status. No parameters.
- get_problem_submission_report: Get detailed information about a specific submission. Parameters: id (numeric submission ID, number, required).
- get_problem_progress: Get the current user's problem-solving progress. Parameters: offset (number of problems to skip, number, optional, default 0), limit (maximum number of problems to return, number, optional, default 100), questionStatus (filter by problem status, enum: "ATTEMPTED", "SOLVED", optional), difficulty (filter by difficulty level, string[], optional).
- get_all_submissions: Get a paginated list of the user's submissions. Parameters: limit (number, default 20), offset (number, default 0), questionSlug (optional problem identifier, string, optional), lang (programming language filter, string, optional, China site only), status (submission status filter, enum: "AC", "WA", optional, China site only), lastKey (pagination token for retrieving the next page, string, optional, China site only).
- run_code: Run code for a specific problem and wait for completion (requires authentication). Parameters: titleSlug (string, required), lang (programming language, string enum, required), typedCode (the 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: Submit code for a specific problem and wait for completion (requires authentication). Parameters: titleSlug (string, required), lang (string enum, required), typedCode (the source code to submit, string, required), timeoutMs (number, optional, default 120000), pollIntervalMs (number, optional, default 1500).
- search_notes: Search user notes on LeetCode China. Parameters: keyword (search term used to filter notes, string, optional), limit (number, optional, default 10), skip (number, optional, default 0), orderBy (sort order, enum: "ASCENDING", "DESCENDING", optional, default "DESCENDING").
- get_note: Get user notes for a specific LeetCode problem. Parameters: questionId (the problem ID of the problem, string, required), limit (number, optional, default 10), skip (number, optional, default 0).
- create_note: Create a new note for a specific LeetCode problem. Parameters: questionId (string, required), content (note content, supports markdown format, string, required), summary (optional short summary or title, string, optional).
- update_note: Update an existing note with new content or summary. Parameters: noteId (the ID of the note to update, string, required), content (the new content of the note, supports markdown format, string, required), summary (optional new short summary or title, string, optional).
- list_problem_solutions: Get the list of community solutions for a specific problem. Parameters: questionSlug (the URL slug/identifier of the problem, string, required), limit (number, optional, default 10), skip (number, optional), userInput (search term used to filter solutions, string, optional), tagSlugs (array of tag identifiers used to filter solutions, string[], optional, default []), orderBy (sort condition for returned solutions: Global 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: Get the full content of a specific solution. Parameters: topicId (the unique topic ID of the solution, string, required, Global only), slug (the unique slug/identifier of the solution, string, required, CN only).
Available resources
- problem-categories: A list of all problem categories.