LeetCode

by jinzcdev

16 stars
33 downloads
Not rated
GitHub Website

About

Connects to LeetCode's programming platform for accessing problem descriptions, searching by tags and difficulty, retrieving user profiles, and viewing community solutions to enhance algorithm learning and contest preparation.

Details

Author
jinzcdev
Repository
jinzcdev/leetcode-mcp-server
GitHub stars
16
Downloads
33
License
MIT License
Categories
Developer Tools, File Management, AI, Community, Search, Infrastructure, Security, Other
Tags
#integration

- 🌐 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

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name LeetCode
    Command (node, npx, python, etc.) npx
    Arguments
    • Argument 1 -y
    • Argument 2 @jinzcdev/leetcode-mcp-server
    Environment
    • LEETCODE_SITE global
    • LEETCODE_SESSION <YOUR_LEETCODE_SESSION_COOKIE>

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

The server supports two transport modes:

| Transport | Description |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| stdio (default) | Standard input/output transport for local MCP clients |
| http | Streamable HTTP transport for web-based integrations and remote access |

npm install @jinzcdev/leetcode-mcp-server -g

npx -y @jinzcdev/leetcode-mcp-server --site global

npx -y @jinzcdev/leetcode-mcp-server --site global --session <YOUR_LEETCODE_SESSION_COOKIE>

Add the following server entry to your MCP client configuration file:

{
  "mcpServers": {
    "leetcode": {
      "command": "npx",
      "args": ["-y", "@jinzcdev/leetcode-mcp-server"],
      "env": {
        "LEETCODE_SITE": "global",
        "LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"
      }
    }
  }
}

First, start the server in HTTP mode:

npx -y @jinzcdev/leetcode-mcp-server --transport http --port 3000 --site global

Then 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>

> [!NOTE]
> 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.

> [!TIP]
>
> The server supports the following optional 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:
> Command-line arguments take precedence over environment variables when both are specified. For example:
>
> - If LEETCODE_SITE=cn is set but you run leetcode-mcp-server --site global, the server will use global.
> - If LEETCODE_SESSION exists but you provide --session "new_cookie", the command-line session value will be used.

User-specific data access requires LeetCode session authentication:

1. Log in to LeetCode (Global or China site)
2. Extract LEETCODE_SESSION cookie from browser developer tools
3. Configure server with --session flag or LEETCODE_SESSION environment variable

get_daily_challenge

Retrieves today's LeetCode Daily Challenge problem.

get_problem

Retrieves details for a specific LeetCode problem. Parameters: titleSlug (string, required)

search_problems

Searches for LeetCode problems with multiple filter criteria. Parameters: category (string, optional), tags (string[], optional), difficulty (enum: 'EASY', 'MEDIUM', 'HARD', optional), searchKeywords (string, optional), limit (number, optional), offset (number, optional)

get_user_profile

Retrieves profile information for a LeetCode user. Parameters: username (string, required)

get_user_contest_ranking

Obtains contest ranking statistics for a user. Parameters: username (string, required), attended (boolean, optional, default: true)

get_recent_ac_submissions

Retrieves a user's recent accepted submissions. Parameters: username (string, required), limit (number, optional, default: 10)

get_recent_submissions

Retrieves a user's recent submissions history. Parameters: username (string, required), limit (number, optional, default: 10)

get_user_status

Retrieves the current user's status.

get_problem_submission_report

Provides detailed submission analysis for a specific problem. Parameters: id (number, required)

get_problem_progress

Retrieves current user's problem-solving progress. Parameters: offset (number, optional, default: 0), limit (number, optional, default: 100), questionStatus (enum: 'ATTEMPTED', 'SOLVED', optional), difficulty (string[], optional)

get_all_submissions

Retrieves current user's submission history. Parameters: limit (number, default: 20), offset (number, default: 0), questionSlug (string, optional), lang (string, optional, CN only), status (enum: 'AC', 'WA', optional, CN only), lastKey (string, optional, CN only)

run_code

Runs code for a problem and polls `/check/` until finished. Parameters: titleSlug (string, required), lang (string enum, required), typedCode (string, required), dataInput (string, optional), timeoutMs (number, optional, default: 120000), pollIntervalMs (number, optional, default: 1500)

submit_solution

Submits code for a problem and polls `/check/` until finished. Parameters: titleSlug (string, required), lang (string enum, required), typedCode (string, required), timeoutMs (number, optional, default: 120000), pollIntervalMs (number, optional, default: 1500)

search_notes

Searches for user notes with filtering options. Parameters: keyword (string, optional), limit (number, optional, default: 10), skip (number, optional, default: 0), orderBy (enum: 'ASCENDING', 'DESCENDING', optional, default: 'DESCENDING')

get_note

Retrieves notes for a specific problem by question ID. Parameters: questionId (string, required), limit (number, optional, default: 10), skip (number, optional, default: 0)

create_note

Creates a new note for a specific LeetCode problem. Parameters: questionId (string, required), content (string, required), summary (string, optional)

update_note

Updates an existing note with new content. Parameters: noteId (string, required), content (string, required), summary (string, optional)

list_problem_solutions

Retrieves a list of community solutions for a specific problem. Parameters: questionSlug (string, required), limit (number, optional, default: 10), skip (number, optional), userInput (string, optional), tagSlugs (string[], optional, default: []), orderBy (enum: 'HOT', 'MOST_RECENT', 'MOST_VOTES', optional, default: 'HOT')

get_problem_solution

Retrieves the complete content of a specific solution. Parameters: topicId (string, required, Global only), slug (string, required, CN only)

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "leetcode": {
            "env": {
                "LEETCODE_SITE": "global",
                "LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"
            },
            "args": [
                "-y",
                "@jinzcdev/leetcode-mcp-server"
            ],
            "command": "npx"
        }
    }
}

Linux

{
    "env": {
        "LEETCODE_SITE": "global",
        "LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"
    },
    "args": [
        "-y",
        "@jinzcdev/leetcode-mcp-server"
    ],
    "command": "npx"
}

Macos

{
    "env": {
        "LEETCODE_SITE": "global",
        "LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"
    },
    "args": [
        "-y",
        "@jinzcdev/leetcode-mcp-server"
    ],
    "command": "npx"
}

Windows

{
    "env": {
        "LEETCODE_SITE": "global",
        "LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"
    },
    "args": [
        "/c",
        "npx",
        "-y",
        "@jinzcdev/leetcode-mcp-server"
    ],
    "command": "cmd"
}

LeetCode MCP Server

NPM Version
Chinese Doc
NPM Downloads
GitHub License
LeetCode MCP Server on Glama
Stars

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

Prerequisites

1. Node.js (v20.x or above)
2. (Optional) LeetCode session cookie for authenticated API access

Installation

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.