LeetCode MCP Server

LeetCode MCP Server

Seamless Model Context Protocol integration with LeetCode APIs for advanced automation and intelligent tooling.

70
Stars
17
Forks
70
Watchers
4
Issues
LeetCode MCP Server is a Model Context Protocol (MCP) compliant server that enables advanced integration with LeetCode’s APIs. It provides robust access to problem data, user profiles, contest analytics, and private user notes across both global and China LeetCode platforms. The server streamlines retrieval, analysis, and interaction with programming challenges, facilitating intelligent automation and enhanced workflow for developers and AI-powered tools. It can be installed via npm or Smithery and easily configured in popular environments like VSCode.

Key Features

Multi-site support for leetcode.com and leetcode.cn
Detailed problem data retrieval including descriptions, constraints, and editorials
Access to user profiles, submission histories, and contest performance data
Private user data access such as notes and problem-solving progress
Advanced search filters for tags, difficulty, and categories
Daily challenge problem retrieval
Integration with VSCode and other tooling via MCP configuration
Authenticated access to private LeetCode resources using session cookies
Installation via npm or Smithery for flexibility
Support for both command line and environment variable configuration

Use Cases

Automating retrieval of LeetCode problems and solutions in developer tooling
Enabling AI-powered code assistant workflows tailored to programming challenges
Tracking and visualizing user contest performance and submission analytics
Integrating LeetCode data into educational platforms or contests
Facilitating private note-taking and progress tracking on LeetCode problems
Building dashboards for competitive programming statistics
Enhancing VSCode or IDEs with direct access to LeetCode APIs
Performing real-time advanced search and filtering of LeetCode problems
Enabling automated daily challenge fetching for learning routines
Accessing and analyzing user-specific problem-solving trends and histories

README

LeetCode MCP Server

NPM Version GitHub License smithery badge Chinese Doc 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
  • 📊 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

Installing via Smithery

To install leetcode-mcp-server for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @jinzcdev/leetcode-mcp-server --client claude

Manual Installation

bash
# Install from npm
npm install @jinzcdev/leetcode-mcp-server -g

# Or run with Global site configuration
npx -y @jinzcdev/leetcode-mcp-server --site global

# Run with authentication (for accessing private data)
npx -y @jinzcdev/leetcode-mcp-server --site global --session <YOUR_LEETCODE_SESSION_COOKIE>

Alternatively, you can clone the repository and run it locally:

bash
# 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
node build/index.js --site global

Usage

Visual Studio Code Integration

Add the following JSON configuration to your User Settings (JSON) file. Access this by pressing Ctrl/Cmd + Shift + P and searching for Preferences: Open User Settings (JSON).

Option 1: Using Environment Variables

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

Option 2: Using Command Line Arguments

json
{
  "mcp": {
    "servers": {
      "leetcode": {
        "type": "stdio",
        "command": "npx",
        "args": [
          "-y",
          "@jinzcdev/leetcode-mcp-server",
          "--site",
          "global",
          "--session",
          "<YOUR_LEETCODE_SESSION_COOKIE>"
        ]
      }
    }
  }
}

For LeetCode China site, modify the --site parameter to cn.

[!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)

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.

Available Tools

Problems

Tool Global CN Auth Required Description
get_daily_challenge Retrieves today's LeetCode Daily Challenge problem
get_problem Retrieves details for a specific LeetCode problem
search_problems Searches for LeetCode problems with multiple filter criteria

Users

Tool Global CN Auth Required Description
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

Notes

Tool Global CN Auth Required Description
search_notes Searches for user notes with filtering options
get_note Retrieves notes for a specific problem by question ID
create_note Creates a new note for a specific problem
update_note Updates an existing note with new content

Solutions

Tool Global CN Auth Required Description
list_problem_solutions Retrieves a list of community solutions for a specific problem
get_problem_solution Retrieves the complete content of a specific solution

Tool Parameters

Problems

  • get_daily_challenge - Retrieves today's LeetCode Daily Challenge problem with complete details

    • No parameters required
  • get_problem - Retrieves details about a specific LeetCode problem

    • titleSlug: The URL slug/identifier of the problem (string, required)
  • search_problems - Searches for LeetCode problems based on multiple filter criteria

    • category: Problem category filter (string, optional, default: "all-code-essentials")
    • tags: List of topic tags to filter problems by (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)

Users

  • get_user_profile - Retrieves profile information about a LeetCode user

    • username: LeetCode username (string, required)
  • get_user_contest_ranking - Retrieves a user's contest ranking information

    • username: LeetCode username (string, required)
    • attended: Whether to include only the contests the user has participated in (boolean, optional, default: true)
  • get_recent_submissions - Retrieves a user's recent submissions on LeetCode Global

    • username: LeetCode username (string, required)
    • limit: Maximum number of submissions to return (number, optional, default: 10)
  • get_recent_ac_submissions - Retrieves a user's recent accepted submissions

    • username: LeetCode username (string, required)
    • limit: Maximum number of submissions to return (number, optional, default: 10)
  • get_user_status - Retrieves the current user's status

    • No parameters required
  • get_problem_submission_report - Retrieves detailed information about a specific submission

    • id: The numerical submission ID (number, required)
  • get_problem_progress - Retrieves the current user's problem-solving progress

    • offset: Number of questions to skip (number, optional, default: 0)
    • limit: Maximum number of questions to return (number, optional, default: 100)
    • questionStatus: Filter by question status (enum: "ATTEMPTED", "SOLVED", optional)
    • difficulty: Filter by difficulty levels (string[], optional)
  • get_all_submissions - Retrieves paginated list of user's submissions

    • limit: Maximum number of submissions to return (number, default: 20)
    • offset: Number of submissions to skip (number, default: 0)
    • questionSlug: Optional problem identifier (string, optional)
    • lang: Programming language filter (string, optional, CN only)
    • status: Submission status filter (enum: "AC", "WA", optional, CN only)
    • lastKey: Pagination token for retrieving next page (string, optional, CN only)

Notes

  • search_notes - Searches for user notes on LeetCode China

    • keyword: Search term to filter notes (string, optional)
    • limit: Maximum number of notes to return (number, optional, default: 10)
    • skip: Number of notes to skip (number, optional, default: 0)
    • orderBy: Sort order for returned notes (enum: "ASCENDING", "DESCENDING", optional, default: "DESCENDING")
  • get_note - Retrieves user notes for a specific LeetCode problem

    • questionId: The question ID of the LeetCode problem (string, required)
    • limit: Maximum number of notes to return (number, optional, default: 10)
    • skip: Number of notes to skip (number, optional, default: 0)
  • create_note - Creates a new note for a specific LeetCode problem

    • questionId: The question ID of the LeetCode problem (string, required)
    • content: The content of the note, supports markdown format (string, required)
    • summary: An optional short summary or title for the note (string, optional)
  • update_note - Updates an existing note with new content or summary

    • noteId: The ID of the note to update (string, required)
    • content: The new content for the note, supports markdown format (string, required)
    • summary: An optional new short summary or title for the note (string, optional)

Solutions

  • list_problem_solutions - Retrieves a list of community solutions for a specific problem

    • questionSlug: The URL slug/identifier of the problem (string, required)
    • limit: Maximum number of solutions to return (number, optional, default: 10)
    • skip: Number of solutions to skip (number, optional)
    • userInput: Search term to filter solutions (string, optional)
    • tagSlugs: Array of tag identifiers to filter solutions (string[], optional, default: [])
    • orderBy: Sorting criteria for the 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 - Retrieves the complete content of a specific solution

    • topicId: Unique topic ID of the solution (string, required, Global only)
    • slug: Unique slug/identifier of the solution (string, required, CN only)

Available Resources

Resource Name Global CN Auth Required Description
problem-categories A list of all problem classification categories
problem-tags A detailed collection of algorithmic and data structure tags
problem-langs A complete list of all supported programming languages
problem-detail Provides details about a specific problem
problem-solution Provides the complete content of a specific solution

Resource URIs

  • problem-categories - A list of all problem classification categories

    • URI: categories://problems/all
  • problem-tags - A detailed collection of algorithmic and data structure tags

    • URI: tags://problems/all
  • problem-langs - A complete list of all programming languages supported by LeetCode

    • URI: langs://problems/all
  • problem-detail - Provides details about a specific LeetCode problem

    • URI: problem://{titleSlug}
    • Parameters:
      • titleSlug: Problem identifier as it appears in the LeetCode URL
  • problem-solution - Provides the complete content of a specific solution

    • Global URI: solution://{topicId}
      • Parameters:
        • topicId: Unique topic ID of the solution
    • CN URI: solution://{slug}
      • Parameters:
        • slug: Unique slug/identifier of the solution

Authentication

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

Response Format

All tools return JSON-formatted responses with the following structure:

json
{
  "content": [
    {
      "type": "text",
      "text": "JSON_DATA_STRING"
    }
  ]
}

The JSON_DATA_STRING contains either the requested data or an error message for failed requests.

License

This project is licensed under the MIT License.

Star History

Star History Chart

Repository Owner

jinzcdev
jinzcdev

User

Repository Details

Language TypeScript
Default Branch main
Size 247 KB
Contributors 3
License MIT License
MCP Verified Nov 11, 2025

Programming Languages

TypeScript
95.72%
JavaScript
3.7%
Dockerfile
0.58%

Tags

Topics

ai algorithm lc leetcode llm mcp mcp-server

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • MyMCP Server (All-in-One Model Context Protocol)

    MyMCP Server (All-in-One Model Context Protocol)

    Powerful and extensible Model Context Protocol server with developer and productivity integrations.

    MyMCP Server is a robust Model Context Protocol (MCP) server implementation that integrates with services like GitLab, Jira, Confluence, YouTube, Google Workspace, and more. It provides AI-powered search, contextual tool execution, and workflow automation for development and productivity tasks. The system supports extensive configuration and enables selective activation of grouped toolsets for various environments. Installation and deployment are streamlined, with both automated and manual setup options available.

    • 93
    • MCP
    • nguyenvanduocit/all-in-one-model-context-protocol
  • OpsLevel MCP Server

    OpsLevel MCP Server

    Read-only MCP server for integrating OpsLevel data with AI tools.

    OpsLevel MCP Server implements the Model Context Protocol to provide AI tools with a secure way to access and interact with OpsLevel account data. It supports read-only operations for a wide range of OpsLevel resources such as actions, campaigns, checks, components, documentation, domains, and more. The tool is compatible with popular environments including Claude Desktop and VS Code, enabling easy integration via configuration and API tokens. Installation options include Homebrew, Docker, and standalone binaries.

    • 8
    • MCP
    • OpsLevel/opslevel-mcp
  • Vectorize MCP Server

    Vectorize MCP Server

    MCP server for advanced vector retrieval and text extraction with Vectorize integration.

    Vectorize MCP Server is an implementation of the Model Context Protocol (MCP) that integrates with the Vectorize platform to enable advanced vector retrieval and text extraction. It supports seamless installation and integration within development environments such as VS Code. The server is configurable through environment variables or JSON configuration files and is suitable for use in collaborative and individual workflows requiring vector-based context management for models.

    • 97
    • MCP
    • vectorize-io/vectorize-mcp-server
  • Slite MCP Server

    Slite MCP Server

    Bridge Slite notes with AI model context using the MCP standard.

    Slite MCP Server implements the Model Context Protocol to interface with Slite's API, enabling seamless search, retrieval, and hierarchical browsing of workspace notes. It exposes standardized tools for searching notes, retrieving content by ID, and navigating note structures, making Slite content programmatically accessible to contextual AI pipelines. Built in Node.js and TypeScript, it is configurable and supports authentication via API key.

    • 0
    • MCP
    • fajarmf/slite-mcp
  • AgentQL MCP Server

    AgentQL MCP Server

    MCP-compliant server for structured web data extraction using AgentQL.

    AgentQL MCP Server acts as a Model Context Protocol (MCP) server that leverages AgentQL's data extraction capabilities to fetch structured information from web pages. It allows integration with applications supporting MCP, such as Claude Desktop, VS Code, and Cursor, by providing an accessible interface for extracting structured data based on user-defined prompts. With configurable API key support and streamlined installation, it simplifies the process of connecting web data extraction workflows to AI tools.

    • 120
    • MCP
    • tinyfish-io/agentql-mcp
  • Webvizio MCP Server

    Webvizio MCP Server

    Bridge between Webvizio feedback and AI coding agents via the Model Context Protocol

    Webvizio MCP Server is a TypeScript-based server implementing the Model Context Protocol to securely and efficiently interface with the Webvizio API. It transforms web page feedback and bug reports into structured, actionable developer tasks, providing AI coding agents with comprehensive task context and data. It offers methods to fetch project and task details, retrieve logs and screenshots, and manage task statuses. The server standardizes communication between Webvizio and AI agent clients, facilitating automated issue resolution.

    • 4
    • MCP
    • Webvizio/mcp
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results