npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

leetcode-mcp

v1.1.6

Published

MCP server for LeetCode — browse problems, get AI coaching, and submit solutions from your editor

Downloads

1,236

Readme

🧠 LeetCode MCP

An MCP server that connects your AI coding assistant (Cursor, Claude Code, or any MCP-compatible host) directly to LeetCode — browse problems, get AI coaching, and submit solutions without leaving your editor.


✨ What you can do

| | | |---|---| | 🔍 | Search and read any LeetCode problem with full statement + starter code | | 📅 | Fetch today's daily challenge | | 💡 | Get progressive hints (5 levels — from a nudge to a near-walkthrough) | | 🗺️ | Get a step-by-step conceptual walkthrough without being given the answer | | 🧪 | Review your approach before you code it | | 🐛 | Debug a failing solution with targeted feedback | | 📊 | Analyze the time and space complexity of your code | | 🚀 | Submit a solution and see the result inline | | 📜 | View your full submission history | | 👤 | See your profile and solve counts |


📋 Prerequisites

  • Node.js 18 or later
  • Cursor, Claude Code, or any MCP-compatible AI host
  • A LeetCode account (free tier is fine)

🔌 Setup

Cursor

Add to ~/.cursor/mcp.json:

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

Restart Cursor. Go to Settings → Features → MCP — you should see leetcode listed with a green dot.

Claude Code

claude mcp add leetcode npx -y leetcode-mcp

🔑 Connecting your account

Open an Agent chat and type:

connect my leetcode

The tool will reply with exact instructions — no guessing:

To connect your LeetCode account, grab your session key in 3 steps:

1. Open leetcode.com in your browser and make sure you're logged in
2. Press F12 (or Cmd+Option+I on Mac) to open DevTools
   → Go to Application tab → Cookies → https://leetcode.com
   → Find the row named LEETCODE_SESSION and copy its Value

3. Come back here and say:
   "connect with session key YOUR_VALUE_HERE"

Paste the value and you're done. Sessions last roughly 2 weeks of inactivity — longer if you visit LeetCode regularly in your browser.

🔄 When your session expires

Every tool will tell you clearly:

LeetCode session expired — run 'connect my leetcode' to re-authenticate.

Just follow the same 3 steps again to get a fresh key.

🔍 Checking your connection

check my leetcode status
MCP server: ✓ running
LeetCode:   ✓ logged in as gokhan (session saved 5/28/2026)
Solved:     87 (E:34 M:45 H:8)

🛠️ Tools reference

🔐 Auth tools

| Tool | What it does | |---|---| | connect | Walks you through getting your session key, then saves it | | logout | Clear the saved session | | whoami | Show your username, ranking, and solve counts | | status | Check if the server is running and your session is valid |


🔍 Problem tools

Search for problems

"find medium array problems about sliding window"
"show me 5 easy string problems"
"search for two sum"

Returns: problem ID, title, difficulty, acceptance rate, and the slug you need for other tools.


Read a problem

"get the two-sum problem"
"show me merge-intervals in typescript"
"give me the daily challenge in python"

Returns: full problem statement, constraints, examples, hints, and starter code for your chosen language (or all languages if not specified).

Supported languages: python, python3, java, cpp, c, javascript, typescript, go, rust, swift, kotlin, ruby, scala, php, csharp, dart


Today's daily challenge

"what's the daily challenge?"
"get today's leetcode problem in go"

🧠 AI coaching tools

These use your AI host's model via MCP Sampling — no API key or extra config needed.


💡 Get a hint

"give me a hint for two-sum"
"hint level 2 for longest-substring-without-repeating-characters"
"I'm stuck on coin-change, hint with my current code: [paste code]"

Five progressive levels — start at 1 and work up:

| Level | What you get | |---|---| | 1 | A one-line category nudge ("think about hashing") | | 2 | Which data structure or technique applies and why | | 3 | The key insight that makes the efficient solution possible | | 4 | The algorithm described in plain English, step by step | | 5 | A near-complete walkthrough with edge cases and complexity |

Tip: Start at level 1. Jumping to 5 skips the learning.


🗺️ Step-by-step walkthrough

"walk me through how to think about two-sum"
"explain step by step how to approach coin-change"
"explain the sliding window part of longest-substring-without-repeating-characters"

Covers: how to read the problem, what pattern applies, algorithm construction, edge cases, and complexity. Zero code given.


🧪 Review your approach

"I want to solve two-sum by iterating through all pairs — review my approach"
"my plan for merge-intervals: sort by start time, merge overlapping ones. Is this right?"

Returns: whether your approach is correct, its complexity, edge cases you might miss, and a nudge toward better if one exists.


🐛 Debug your solution

"debug my two-sum solution in python:
  [paste your code]
  it fails with: Expected [0,1] but got [0,0] for input nums=[2,7,11,15], target=9"

Finds the bug, explains why it causes the failure, shows a corrected snippet for the broken section only.


📊 Analyze complexity

"analyze the complexity of my solution in typescript: [paste code]"

Returns: time and space complexity with a trace through the loops, whether this is optimal, and any quick wins.


🚀 Submission tools

Submit a solution

"submit this python solution for two-sum: [paste code]"
"submit my typescript solution for merge-intervals: [paste code]"

Submits to LeetCode, polls until judging is done, and shows the result:

Submission ID: 1234567890
Status:        Accepted
Runtime:       52 ms
Memory:        16.4 MB
Tests:         63 / 63

Or if it fails:

Status:      Wrong Answer
Tests:       42 / 63
Failing Input:
  nums = [3,2,4], target = 6
Expected: [1,2]
Got:      [0,1]

View submission history

"show my recent submissions"
"show my submissions for two-sum"

🎯 Typical workflow

1. "connect my leetcode"               → get session key, paste it back
2. "what's the daily challenge in typescript?"
3. "walk me through how to think about [slug]"
4. "review my approach: [describe your plan]"
5. [write your solution]
6. "hint level 1 for [slug] with my code: [paste]"   ← if stuck
7. "debug my solution: [paste code + error]"          ← if failing
8. "submit this typescript solution for [slug]: [paste code]"
9. "analyze the complexity of my solution: [paste code]"

❓ Troubleshooting

The MCP server doesn't appear in Cursor

  • Restart Cursor after editing mcp.json
  • Make sure you're using Agent mode in chat, not normal Ask mode

"Session expired" on every tool

  • Run "connect my leetcode" and follow the 3 steps to get a fresh key

submit_solution returns "Language not supported"

  • Use the slug form: python3 not Python 3, cpp not C++, csharp not C#

AI coaching tools return an error about sampling

  • Your host doesn't support MCP sampling. Claude Code and Cursor both do.

📁 Project structure

src/
├── server.ts           — MCP server + all tool definitions
├── auth.ts             — session storage (~/.config/leetcode-mcp/session.json)
├── leetcode-client.ts  — LeetCode GraphQL + REST API client
├── ai-helper.ts        — AI coaching prompts via MCP sampling
└── types.ts            — TypeScript types + language slug map

🔐 Privacy

Your session key is stored locally at ~/.config/leetcode-mcp/session.json and is only sent to LeetCode's own API. AI coaching uses MCP sampling through your host (Cursor, Claude Code) — no third-party services involved.