
LeetCode MCP Server
Integrate LeetCode problems, solutions, contests, and user data into MCP clients, supporting leetcode.com and leetcode.cn.
Add to your client
Copy the config for your MCP client and paste it into its config file.
npm install @jinzcdev/leetcode-mcp-server -gPaste into ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"leetcode-mcp-server": {
"command": "npx",
"args": [
"-y",
"@jinzcdev/leetcode-mcp-server"
],
"env": {
"LEETCODE_SITE": "global",
"LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"
}
}
}
}Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf
Before you start
- Node.js (v20.x or above)
- (Optional) LeetCode session cookie for authenticated API access
About LeetCode MCP Server
An MCP server enabling automated access to LeetCode's problems, solutions, and public data, with optional authentication for user-specific features. It supports both leetcode.com (Global) and leetcode.cn (China) sites. Public tools (daily challenge, problem details, search, community solutions, user profiles, contest rankings) require no authentication; private tools (user status, submission reports, progress, notes, running and submitting code) require a LeetCode session cookie. The server also exposes resources (categories, tags, languages, problem details, solutions) via URI schemes such as problem://{titleSlug} and solution://{topicId}.
Tools & capabilities (19)
get_daily_challengeRetrieves today's LeetCode Daily Challenge problem with complete details. No parameters required.
get_problemRetrieves details for a specific LeetCode problem by its titleSlug (URL identifier).
search_problemsSearches for LeetCode problems with multiple filter criteria: category, tags, difficulty (EASY/MEDIUM/HARD), searchKeywords, limit, and offset.
get_user_profileRetrieves profile information for a LeetCode user by username.
get_user_contest_rankingObtains contest ranking statistics for a user by username, with an optional 'attended' filter.
get_recent_ac_submissionsRetrieves a user's recent accepted submissions by username, with an optional limit.
get_recent_submissionsRetrieves a user's recent submissions history (Global only) by username, with an optional limit.
get_user_statusRetrieves the current authenticated user's status. Requires authentication. No parameters required.
get_problem_submission_reportProvides detailed submission analysis for a specific submission by numerical submission id. Requires authentication.
get_problem_progressRetrieves the current user's problem-solving progress, filterable by offset, limit, questionStatus (ATTEMPTED/SOLVED), and difficulty. Requires authentication.
get_all_submissionsRetrieves a paginated list of the current user's submission history, filterable by questionSlug, lang (CN), status (CN), and lastKey (CN). Requires authentication.
run_codeRuns code for a problem and polls /check/ until finished. Parameters: titleSlug, lang, typedCode, optional dataInput, timeoutMs, pollIntervalMs. Requires authentication.
submit_solutionSubmits code for a problem and polls /check/ until finished. Parameters: titleSlug, lang, typedCode, optional timeoutMs, pollIntervalMs. Requires authentication.
search_notesSearches for user notes (LeetCode China only) with filtering: keyword, limit, skip, orderBy (ASCENDING/DESCENDING). Requires authentication.
get_noteRetrieves notes for a specific problem by questionId (LeetCode China only), with optional limit and skip. Requires authentication.
create_noteCreates a new note for a specific problem (LeetCode China only). Parameters: questionId, content (markdown), optional summary. Requires authentication.
update_noteUpdates an existing note with new content or summary (LeetCode China only). Parameters: noteId, content (markdown), optional summary. Requires authentication.
list_problem_solutionsRetrieves a list of community solutions for a specific problem by questionSlug, with filters: limit, skip, userInput, tagSlugs, orderBy.
get_problem_solutionRetrieves the complete content of a specific solution. Use topicId (Global) or slug (CN).
What this server can do
LeetCode MCP Server provides tools for these capabilities — tap one to see every MCP server that does the same:
When to use it
- Fetch the daily LeetCode challenge and full problem details into an AI coding assistant
- Search and filter problems by topic tags, difficulty, and keywords
- Look up community and official solutions for a given problem
- Retrieve a user's profile, contest ranking, and recent submissions
- Track problem-solving progress and analyze AC/WA submissions with an authenticated session
- Run and submit code to LeetCode directly from an MCP client
- Create, search, and update personal study notes (LeetCode China)
Security notes
Authenticated (private) data access requires a LeetCode session cookie. Log in to LeetCode (Global or China), extract the LEETCODE_SESSION cookie from browser developer tools, and pass it via the --session flag or the LEETCODE_SESSION environment variable. Without it, only public data is accessible. Treat the session cookie as a secret credential.
LeetCode MCP Server FAQ
Do I need a LeetCode account to use this server?
No. Public tools such as daily challenge, problem details, search, community solutions, user profiles, and contest rankings work without authentication. Only user-specific/private features (status, submission reports, progress, notes, running/submitting code) require a LeetCode session cookie.
How do I enable authenticated access?
Log in to LeetCode (Global or China site), extract the LEETCODE_SESSION cookie from your browser's developer tools, and configure the server with the --session flag or the LEETCODE_SESSION environment variable.
Does it support both the global and Chinese LeetCode sites?
Yes. Set the site via the LEETCODE_SITE environment variable ('global' or 'cn', default 'global') or the --site command-line argument. Some tools (e.g. notes) are CN-only and some (e.g. get_recent_submissions) are Global-only.
What takes precedence, command-line arguments or environment variables?
Command-line arguments take precedence over environment variables when both are specified. For example, if LEETCODE_SITE=cn is set but you run the server with --site global, it uses 'global'.
Alternatives to LeetCode MCP Server
Compare all alternatives →Microsoft's official browser-automation MCP using Playwright's accessibility tree (no vision model).
Up-to-date, version-specific library documentation injected into your coding agent.
LSP-powered coding agent toolkit: semantic symbol search, references and structural edits.
Compare LeetCode MCP Server with: