LeetCode MCP server

Provides structured access to LeetCode's problem database, user profiles, and contest information through GraphQL queries for exploring challenges, tracking progress, and analyzing performance.
Back to servers
Provider
gh-doggybee
Release date
Apr 02, 2025
Language
TypeScript
Stats
6 stars

The MCP Server LeetCode is a powerful tool that enables AI assistants to access LeetCode problems, user information, and contest data through the Model Context Protocol. It provides seamless integration with Claude and other MCP-compatible AI assistants, giving them the ability to search problems, retrieve daily challenges, and check user profiles.

Installation Options

Via Smithery (Recommended for Claude Desktop)

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

Global Installation

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

After global installation, run directly from the command line:

mcp-server-leetcode

Local Installation

npm install @mcpfun/mcp-server-leetcode

Integration with Claude for Desktop

Add this configuration to your Claude for Desktop claude_desktop_config.json file:

{
  "mcpServers": {
    "leetcode": {
      "command": "mcp-server-leetcode"
    }
  }
}

For local development, use:

{
  "mcpServers": {
    "leetcode": {
      "command": "node",
      "args": ["/path/to/dist/index.js"]
    }
  }
}

Using as a Library

You can also use the MCP Server LeetCode as a JavaScript library:

import { LeetCodeService } from '@mcpfun/mcp-server-leetcode';

// Initialize the service
const leetcodeService = new LeetCodeService();

// Get daily challenge
const dailyChallenge = await leetcodeService.getDailyChallenge();

// Search problems
const problems = await leetcodeService.searchProblems({
  difficulty: 'MEDIUM',
  tags: 'array+dynamic-programming'
});

Available Tools

Problem-related Tools

Tool Name Description Parameters
get-daily-challenge Get the daily challenge None
get-problem Get details for a specific problem titleSlug (string)
search-problems Search for problems based on criteria tags (optional), difficulty (optional), limit (default 20), skip (default 0)

User-related Tools

Tool Name Description Parameters
get-user-profile Get user information username (string)
get-user-submissions Get user submission history username (string), limit (optional, default 20)
get-user-contest-ranking Get user contest rankings username (string)

Contest-related Tools

Tool Name Description Parameters
get-contest-details Get contest details contestSlug (string)

Available Resources

Problem Resources

  • leetcode://daily-challenge: Daily challenge
  • leetcode://problem/{titleSlug}: Problem details
  • leetcode://problems{?tags,difficulty,limit,skip}: Problem list

User Resources

  • leetcode://user/{username}/profile: User profile
  • leetcode://user/{username}/submissions{?limit}: User submissions
  • leetcode://user/{username}/contest-ranking: User contest ranking

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later