Sponsored by Deepsite.site

LeetCode

Created By
jinzcdev8 months ago
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.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
CursorThe AI Code Editor
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
ChatWiseThe second fastest AI chatbot™
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
DeepChatYour AI Partner on Desktop
WindsurfThe new purpose-built IDE to harness magic
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Playwright McpPlaywright MCP server
Tavily Mcp
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Amap Maps高德地图官方 MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.