leetcode
An MCP server enabling automated access to LeetCode's problems, solutions, and public data with optional authentication for user-specific features, supporting leetcode.com & leetcode.cn sites.
claude mcp add --transport stdio jinzcdev-leetcode-mcp-server npx -y @jinzcdev/leetcode-mcp-server \ --env LEETCODE_SITE="global" \ --env LEETCODE_SESSION="<YOUR_LEETCODE_SESSION_COOKIE>"
How to use
The LeetCode MCP Server provides a set of tools to interact with LeetCode data through the Model Context Protocol (MCP). It aggregates capabilities such as retrieving daily challenges, problem details, user profiles, and submission data, alongside private-note features and progress tracking. You can run the server via npx or integrate it into an editor workflow (for example VS Code) using the provided JSON configurations. When running, you can supply your LeetCode site (global or cn) and an authenticated session cookie to access private data. The available tools are organized into Problems, Users, Notes, and Solutions, with functions like get_daily_challenge, get_problem, search_problems, get_user_profile, get_user_status, create_note, and list_problem_solutions. This setup enables automated querying, scripting, and IDE-based interactions with LeetCode data through MCP requests.
How to install
Prerequisites:\n- Node.js v20.x or above\n- npm (comes with Node.js)\n- Optional: LeetCode session cookie for authenticated API access\n\nInstallation steps:\n1) Install the MCP server globally via npm (preferred for CLI usage):\nbash\nnpm install -g @jinzcdev/leetcode-mcp-server\n\n2) Run the server with a site configuration (global by default):\nbash\nnpx -y @jinzcdev/leetcode-mcp-server --site global\n\n3) If you want to use Smithery (optional) for client integration:\nbash\nnpx -y @smithery/cli install @jinzcdev/leetcode-mcp-server --client claude\n\n4) Alternatively, clone and build locally:\nbash\n# Clone the repository\ngit clone https://github.com/jinzcdev/leetcode-mcp-server.git\n\n# Navigate to project directory\ncd leetcode-mcp-server\n\n# Install dependencies and build\nnpm install && npm run build\n\n# Run the server locally (example)\nnode build/index.js --site global\n
Additional notes
Environment variables provide flexible runtime configuration. If both command-line arguments and environment variables are set, the command-line arguments take precedence. Common variables to consider:\n- LEETCODE_SITE: global or cn (default: global)\n- LEETCODE_SESSION: authenticated session cookie for private data access (default: empty)\n\nTroubleshooting tips:\n- Ensure Node.js v20.x+ is installed.\n- If you encounter authentication errors, verify your LeetCode session cookie is valid and not expired.\n- When using VS Code integration, ensure the MCP JSON configuration matches your runtime environment (env vs. args).\n- If the server fails to start, check network access and that the required npm package is published and accessible in your environment.
Related MCP Servers
mcp-graphql
Model Context Protocol server for GraphQL
rohlik
MCP server that lets you shop groceries across the Rohlik Group platforms (Rohlik.cz, Knuspr.de, Gurkerl.at, Kifli.hu, Sezamo.ro)
hackmd
A Model Context Protocol server for integrating HackMD's note-taking platform with AI assistants.
ez
The easiest path to getting an MCP server going
google-scholar
An MCP server for Google Scholar written in TypeScript with Streamable HTTP
alris
Alris is an AI automation tool that transforms natural language commands into task execution.