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.
npx -y @smithery/cli install @doggybee/mcp-server-leetcode --client claude
npm install -g @mcpfun/mcp-server-leetcode
After global installation, run directly from the command line:
mcp-server-leetcode
npm install @mcpfun/mcp-server-leetcode
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"]
}
}
}
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'
});
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) |
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) |
Tool Name | Description | Parameters |
---|---|---|
get-contest-details |
Get contest details | contestSlug (string) |
leetcode://daily-challenge
: Daily challengeleetcode://problem/{titleSlug}
: Problem detailsleetcode://problems{?tags,difficulty,limit,skip}
: Problem listleetcode://user/{username}/profile
: User profileleetcode://user/{username}/submissions{?limit}
: User submissionsleetcode://user/{username}/contest-ranking
: User contest rankingThere 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.
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"
]
}
}
}
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.
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.