MCP Directory

How to add LeetCode MCP Server to Cursor

Integrate LeetCode problems, solutions, contests, and user data into MCP clients, supporting leetcode.com and leetcode.cn. Paste the config into ~/.cursor/mcp.json and restart Cursor.

Last updated June 14, 2026 · 118 · stdio · apikey

Cursor config for LeetCode MCP Server

npm install @jinzcdev/leetcode-mcp-server -g
{
  "mcpServers": {
    "leetcode-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "@jinzcdev/leetcode-mcp-server"
      ],
      "env": {
        "LEETCODE_SITE": "global",
        "LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"
      }
    }
  }
}

Setup steps

  1. 1Open Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
  2. 2Paste the LeetCode MCP Server config below into the "mcpServers" object.
  3. 3Fill in placeholder secrets, then save.
  4. 4Cursor reloads MCP servers automatically — check Settings → MCP for a green status dot.
  5. 5Ask Cursor to use one of LeetCode MCP Server's tools to confirm it's connected.

Before you start

  • Node.js (v20.x or above)
  • (Optional) LeetCode session cookie for authenticated API access

What LeetCode MCP Server can do in Cursor

get_daily_challenge

Retrieves today's LeetCode Daily Challenge problem with complete details. No parameters required.

get_problem

Retrieves details for a specific LeetCode problem by its titleSlug (URL identifier).

search_problems

Searches for LeetCode problems with multiple filter criteria: category, tags, difficulty (EASY/MEDIUM/HARD), searchKeywords, limit, and offset.

get_user_profile

Retrieves profile information for a LeetCode user by username.

get_user_contest_ranking

Obtains contest ranking statistics for a user by username, with an optional 'attended' filter.

get_recent_ac_submissions

Retrieves a user's recent accepted submissions by username, with an optional limit.

get_recent_submissions

Retrieves a user's recent submissions history (Global only) by username, with an optional limit.

get_user_status

Retrieves the current authenticated user's status. Requires authentication. No parameters required.

Security

Authenticated (private) data access requires a LeetCode session cookie. Log in to LeetCode (Global or China), extract the LEETCODE_SESSION cookie from browser developer tools, and pass it via the --session flag or the LEETCODE_SESSION environment variable. Without it, only public data is accessible. Treat the session cookie as a secret credential.

LeetCode MCP Server + Cursor FAQ

Where is the Cursor config file?

Cursor reads MCP servers from ~/.cursor/mcp.json. Paste the LeetCode MCP Server config there under the "mcpServers" key and restart the client.

Is LeetCode MCP Server safe to use with Cursor?

Authenticated (private) data access requires a LeetCode session cookie. Log in to LeetCode (Global or China), extract the LEETCODE_SESSION cookie from browser developer tools, and pass it via the --session flag or the LEETCODE_SESSION environment variable. Without it, only public data is accessible. Treat the session cookie as a secret credential.

Do I need a LeetCode account to use this server?

No. Public tools such as daily challenge, problem details, search, community solutions, user profiles, and contest rankings work without authentication. Only user-specific/private features (status, submission reports, progress, notes, running/submitting code) require a LeetCode session cookie.

How do I enable authenticated access?

Log in to LeetCode (Global or China site), extract the LEETCODE_SESSION cookie from your browser's developer tools, and configure the server with the --session flag or the LEETCODE_SESSION environment variable.

Does it support both the global and Chinese LeetCode sites?

Yes. Set the site via the LEETCODE_SITE environment variable ('global' or 'cn', default 'global') or the --site command-line argument. Some tools (e.g. notes) are CN-only and some (e.g. get_recent_submissions) are Global-only.

View repo Full LeetCode MCP Server page