LeetCode

LeetCode

By jinzcdev GitHub

-

leetcode mcp-server
Overview

what is LeetCode MCP Server?

LeetCode MCP Server is a Model Context Protocol (MCP) server that integrates with LeetCode APIs, allowing for advanced automation and interaction with programming problems, contests, and user data on LeetCode.

how to use LeetCode MCP Server?

To use the server, install it via npm or clone the repository. You can run it with or without authentication, depending on whether you need access to private user data.

key features of LeetCode MCP Server?

  • Multi-site support for leetcode.com and leetcode.cn
  • Detailed problem data retrieval including descriptions and examples
  • Access to user profiles and submission history
  • Advanced search capabilities for filtering problems
  • Daily challenge tracking

use cases of LeetCode MCP Server?

  1. Automating problem retrieval for coding practice.
  2. Analyzing user performance in contests.
  3. Integrating with development environments for seamless coding experiences.

FAQ from LeetCode MCP Server?

  • Can I use it without a LeetCode account?

Yes, but some features require authentication for accessing private data.

  • Is it free to use?

Yes, the server is free to use.

  • What programming languages are supported?

The server supports multiple programming languages as specified in the LeetCode platform.

Content

LeetCode MCP Server

NPM Version GitHub License 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: Supports both leetcode.com and leetcode.cn platforms
  • Problem Data Retrieval: Obtain detailed problem descriptions, constraints, examples, and solution approaches
  • User Data Access: Retrieve user profiles, submission history, and contest performance
  • Advanced Search Capabilities: Filter problems by tags, difficulty levels, and categories
  • Daily Challenge Tracking: Easily access daily challenge problems

Prerequisites

  1. Node.js runtime environment
  2. (Optional) LeetCode session cookie for authenticated API access

Installation

# 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:

# Clone the repository
git clone https://github.com/jinzcdev/leetcode-mcp-server.git

# Navigate to the project directory
cd leetcode-mcp-server

# Build and run the server
npm run build && node build/index.js --site global

Usage

Visual Studio Code Integration

Add the following JSON configuration to your User Settings (JSON) file Code. Access this by pressing Ctrl/Cmd + Shift + P and searching for Preferences: Open User Settings (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.

Environment Variables

The server supports the following environment variables:

  • LEETCODE_SITE: LeetCode API endpoint ('global' or 'cn')
  • LEETCODE_SESSION: LeetCode session cookie for authenticated API access

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.

Tools

The server provides a comprehensive suite of tools categorized by functionality and platform compatibility.

Problem Tools

Available on both Global and China sites, with optional authentication.

Tool NameDescriptionParameters
leetcode_daily_challengeRetrieves today's LeetCode Daily Challenge with complete metadataNone
leetcode_problemRetrieves comprehensive details for a specified LeetCode problemtitleSlug (string, required): Problem URL identifier (e.g., 'two-sum')
leetcode_search_problemsExecutes filtered searches across LeetCode problemscategory (string, optional): Problem classification
tags (string[], optional): Topic tags filter
difficulty (string, optional): Problem complexity level ('EASY', 'MEDIUM', 'HARD')
limit (number, optional): Maximum results count
offset (number, optional): Pagination offset

User Tools

Provides user-specific data across both platforms.

Tool NameDescriptionParameters
leetcode_user_profileRetrieves complete profile information for a LeetCode userusername (string, required): LeetCode username
leetcode_user_contest_rankingObtains contest ranking statistics for a userusername (string, required): LeetCode username
attended (boolean, optional): Filter for attended contests only

Global Site-Specific User Tools

Exclusive to leetcode.com platform.

Tool NameDescriptionParameters
leetcode_recent_submissionsRetrieves a user's recent submission history (Global)username (string, required): LeetCode username
limit (number, optional): Results limit
leetcode_recent_ac_submissionsRetrieves a user's recent accepted submissions (Global)username (string, required): LeetCode username
limit (number, optional): Results limit

China Site-Specific User Tools

Exclusive to leetcode.cn platform.

Tool NameDescriptionParameters
leetcode_user_recent_ac_submissionsRetrieves recent accepted submissions (China)username (string, required): LeetCode China username
limit (number, optional): Results limit

Authenticated Common Tools

Requires session authentication, available on both platforms.

Tool NameDescriptionParameters
leetcode_user_statusRetrieves authenticated user's current statusNone
leetcode_problem_submission_detailProvides detailed submission analysisid (number, required): Submission ID
leetcode_user_progress_questionsTracks user's problem-solving progressoffset (number, required): Pagination offset
limit (number, required): Results limit
questionStatus (enum, optional): 'ATTEMPTED' or 'SOLVED' filter
difficulty (string[], optional): Complexity level filter

Global Site-Specific Authenticated Tools

Authenticated tools exclusive to leetcode.com.

NameDescriptionParameters
leetcode_user_all_submissionsRetrieves paginated submission history (Global)limit (number, required): Results limit
offset (number, required): Pagination offset
questionSlug (string, optional): Problem identifier filter

China Site-Specific Authenticated Tools

Authenticated tools exclusive to leetcode.cn.

Tool NameDescriptionParameters
leetcode_user_all_submissionsRetrieves comprehensive submission history (China)limit (number, required): Results limit
offset (number, required): Pagination offset
questionSlug (string, optional): Problem identifier
lang (string, optional): Programming language filter
status (string, optional): Submission status filter
lastKey (string, optional): Pagination token

Resources

The server provides reference resources for platform metadata access via URI endpoints.

Resource NameDescriptionURI
problem-categoriesComplete problem classification categoriesleetcode://problems/categories/all
problem-tagsAlgorithmic and data structure tags collectionleetcode://problems/tags/all
problem-langsSupported programming languages listleetcode://problems/langs/all
solution-articleA LeetCode solution articleglobal: leetcode://solutions/{topicId}
cn: leetcode://solutions/{slug}

Authentication

Advanced features require 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:

{
  "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.

No tools information available.

Mirror of

image-generation mcp-server
View Details

Secure MCP server for analyzing Excel files with oletools

oletools mcp-server
View Details

Mirror of

bigquery mcp-server
View Details

MCPHubs is a website that showcases projects related to Anthropic's Model Context Protocol (MCP)

mcp mcp-server
View Details
Dealx
Dealx by DealExpress

-

dealx mcp-server
View Details

Google Analytics MCP server for accessing analytics data through tools and resources

google-analytics mcp-server
View Details

A Python-based MCP server that lets Claude run boto3 code to query and manage AWS resources. Execute powerful AWS operations directly through Claude with proper sandboxing and containerization. No need for complex setups - just pass your AWS credentials and start interacting with all AWS services.

aws mcp-server
View Details