A Model Context Protocol (MCP) server for LeetCode that interacts with the LeetCode API using GraphQL queries.
- Access LeetCode problems, user information, and contest data
- Structured access through MCP tools and resources
- Comprehensive error handling
- Modular architecture
get-daily-challenge: Retrieve the daily challenge problemget-problem: Get detailed information about a specific problem by its slugsearch-problems: Search for problems based on difficulty, tags, and other criteria
get-user-profile: Retrieve profile information for a LeetCode userget-user-submissions: Get submission history for a userget-user-contest-ranking: Retrieve contest ranking information for a user
get-contest-details: Get information about a specific contestget-user-contest-ranking: Retrieve a user's performance in contests
leetcode://daily-challenge: Current daily challenge problemleetcode://problem/{titleSlug}: Detailed information about a specific problemleetcode://problems{?tags,difficulty,limit,skip}: List of problems matching query parameters
leetcode://user/{username}/profile: User profile informationleetcode://user/{username}/submissions{?limit}: User's submission historyleetcode://user/{username}/contest-ranking: User's contest ranking data
What are the top 5 easy array problems on LeetCode?
This will use the search-problems tool with parameters for difficulty level "EASY" and the "array" tag.
Show me details of the "two-sum" problem on LeetCode.
This will use the get-problem tool with the titleSlug "two-sum" to retrieve comprehensive information about the problem.
What is the LeetCode profile information for user "username123"?
This will use the get-user-profile tool to retrieve statistics and profile data for the specified user.
What is today's LeetCode daily challenge?
This will use the get-daily-challenge tool to retrieve the current day's challenge problem.
npm installnpm run buildnpm startnpm run devConnect to this server using Claude for Desktop or other MCP-compatible clients.
Add the following to your Claude for Desktop claude_desktop_config.json file:
{
"mcpServers": {
"leetcode": {
"command": "node",
"args": ["/path/to/leetcode-mcp-server/dist/index.js"]
}
}
}For a fresh setup, you can use the provided script:
./clean-install.shThis script will remove existing node_modules and dist directories, install dependencies, and build the project.
- Inspired by alfa-leetcode-api
- Implemented using the Model Context Protocol specification