home / mcp / leetcode mcp server

LeetCode MCP Server

Provides an MCP server that integrates LeetCode data and actions for problem data, user data, notes, and solutions via MCP clients.

Installation
Add the following to your MCP client configuration file.

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.

How to use

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.

How to install

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 claude

Option 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 global

Additional setup and notes

The 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.

Configuration and usage notes

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.

Security and authentication

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.

Building from source

To build and run from source, clone the repository, install dependencies, build, then start the server with the desired site.

Available tools

get_daily_challenge

Retrieves today's LeetCode Daily Challenge problem with complete details

get_problem

Retrieves details for a specific LeetCode problem

search_problems

Searches for LeetCode problems with multiple filter criteria

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

search_notes

Searches for user notes with filtering options (CN)