home / mcp / leetcode mcp server
Provides an MCP server that integrates LeetCode data and actions for problem data, user data, notes, and solutions via MCP clients.
Configuration
View docs{
"mcpServers": {
"jinzcdev-leetcode-mcp-server": {
"command": "npx",
"args": [
"-y",
"@jinzcdev/leetcode-mcp-server",
"--site",
"global",
"--session",
"<YOUR_LEETCODE_SESSION_COOKIE>"
],
"env": {
"LEETCODE_SITE": "global",
"LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"
}
}
}
}The LeetCode MCP Server lets you connect to LeetCode APIs through a Model Context Protocol (MCP) server, enabling automated data retrieval, user insights, and problem-solving analytics across global and China sites.
You connect to the MCP server from your MCP client and call the available tools to retrieve problems, user data, notes, and solutions. Use the global site by default or switch to the China site when needed. For authenticated access to private data, you provide a LeetCode session cookie so the server can access your private resources.
Prerequisites: You need Node.js (v20.x or above). If you want authenticated access to private data, have your LeetCode session cookie ready.
Option A โ Installing via Smithery (automatic for Claude Desktop)
npx -y @smithery/cli install @jinzcdev/leetcode-mcp-server --client claudeOption B โ Manual installation (global command)
# Install globally
npm install @jinzcdev/leetcode-mcp-server -g
# Run with global site configuration
npx -y @jinzcdev/leetcode-mcp-server --site global
# Run with authentication for private data
npx -y @jinzcdev/leetcode-mcp-server --site global --session <YOUR_LEETCODE_SESSION_COOKIE>Option C โ Build and run from source (local)
# 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 locally (global site)
node build/index.js --site globalThe server supports both the LeetCode Global site and the LeetCode China site. When you run the server, you can pass the site parameter to select global or cn. You can also provide a LeetCode session cookie to access private data. Remember that command-line options take precedence over environment variables when both are specified.
Environment variables you may use when running locally include LEETCODE_SITE (global or cn) and LEETCODE_SESSION (the LeetCode session cookie). If you supply both an explicit --site and LEETCODE_SITE, the explicit flag wins.
If you need access to private data, provide your LeetCode session cookie as a command-line argument or via the LEETCODE_SESSION environment variable. Never share your session cookie publicly. Rotate secrets if you suspect exposure.
To build and run from source, clone the repository, install dependencies, build, then start the server with the desired site.
Retrieves today's LeetCode Daily Challenge problem with complete details
Retrieves details for a specific LeetCode problem
Searches for LeetCode problems with multiple filter criteria
Retrieves profile information for a LeetCode user
Obtains contest ranking statistics for a user
Retrieves a user's recent accepted submissions
Retrieves a user's recent submissions history
Retrieves current user's current status
Provides detailed submission analysis for a specific problem
Retrieves current user's problem-solving progress
Retrieves current user's submission history
Searches for user notes with filtering options (CN)