LeetCode MCP (Model Context Protocol)

by Kishan-N

156 downloads Not rated yet
GitHub

About

LeetCode MCP is a Python-based tool that fetches LeetCode problem descriptions and produces detailed explanations of multiple solution approaches. It is designed for developers preparing for coding interviews who want to understand both the intuition and complexity behind…

Explore

- Fetches problem descriptions from LeetCode
- Extracts examples and constraints
- Provides multiple solution approaches with:
- Intuition behind the solution
- Time and space complexity analysis
- Implementation details
- Step-by-step explanations

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 MCP (Model Context Protocol)
    Command (node, npx, python, etc.)

    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

1. Clone this repository
2. Install the required dependencies:

pip install -r requirements.txt

3. Update your open API Key in the config.json file:
{"OPENAI_API_KEY": "<Add your OpenAI API key here>"}

Claude Desktop / Cursor

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

{
    "mcpServers": {
        "leetcode mcp (model context protocol)": {
            "Leetcode_Notes_MCP": {
                "command": "python",
                "args": [
                    "leetcode_mcp.py"
                ]
            }
        }
    }
}

McpServers

{
    "Leetcode_Notes_MCP": {
        "command": "python",
        "args": [
            "leetcode_mcp.py"
        ]
    }
}

This is a Python-based tool that fetches LeetCode problems and provides detailed explanations of various solution approaches.

Features

- Fetches problem descriptions from LeetCode
- Extracts examples and constraints
- Provides multiple solution approaches with:
- Intuition behind the solution
- Time and space complexity analysis
- Implementation details
- Step-by-step explanations

Installation

1. Clone this repository
2. Install the required dependencies:

pip install -r requirements.txt

3. Update your open API Key in the config.json file:
{"OPENAI_API_KEY": "<Add your OpenAI API key here>"}

Usage

Run the script:

python leetcode_mcp.py

When prompted, enter the name of the LeetCode problem you want to explore. The tool will fetch the problem and provide detailed explanations of various solution approaches.

Example:

Enter LeetCode problem name: valid-sudoku

Output Format

The tool generates a markdown-formatted output with:

1. Problem title and difficulty
2. Problem description
3. Examples
4. Constraints
5. Multiple solution approaches, each containing:
- Intuition
- Complexity analysis
- Implementation
- Detailed explanation

Note

This tool scrapes data from LeetCode's public problem pages. Please be mindful of LeetCode's terms of service and rate limiting when using this tool.

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.