Skip to main content
Glama
jinzcdev

LeetCode MCP Server

LeetCode MCP サーバー

NPMバージョン GitHubライセンス 鍛冶屋のバッジ 中国語ドキュメント 星

LeetCode MCP サーバーは、LeetCode API とのシームレスな統合を提供するモデル コンテキスト プロトコル (MCP)サーバーであり、LeetCode のプログラミング問題、コンテスト、ソリューション、およびユーザー データとの高度な自動化とインテリジェントな対話を可能にします。

特徴

  • 🌐マルチサイトサポート:leetcode.com(グローバル)とleetcode.cn(中国)の両方のプラットフォームをサポート

  • 📊問題データの取得:詳細な問題の説明、制約、例、公式の論説、ユーザーが投稿した解決策を取得します。

  • 👤ユーザーデータアクセス:ユーザープロフィール、提出履歴、コンテストパフォーマンスを取得します

  • 🔒プライベートデータアクセス:ユーザーノートの作成とクエリ、問題解決の進捗状況の追跡、提出内容の分析(AC/WA分析)

  • 🔍高度な検索機能: タグ、難易度、カテゴリ、キーワードで問題をフィルタリング

  • 📅デイリーチャレンジアクセス:デイリーチャレンジ問題に簡単にアクセスできます

Related MCP server: Linear MCP Server

前提条件

  1. Node.js ランタイム環境

  2. (オプション) 認証された API アクセス用の LeetCode セッション Cookie

インストール

Smithery経由でインストール

Smithery経由で Claude Desktop 用の leetcode-mcp-server を自動的にインストールするには:

npx -y @smithery/cli install @jinzcdev/leetcode-mcp-server --client claude

手動インストール

# Install from npm
npm install @jinzcdev/leetcode-mcp-server -g

# Or run with Global site configuration
npx -y @jinzcdev/leetcode-mcp-server --site global

# Run with authentication (for accessing private data)
npx -y @jinzcdev/leetcode-mcp-server --site global --session <YOUR_LEETCODE_SESSION_COOKIE>

あるいは、リポジトリをクローンしてローカルで実行することもできます。

# Clone the repository
git clone https://github.com/jinzcdev/leetcode-mcp-server.git

# Navigate to the project directory
cd leetcode-mcp-server

# Build and run the server
npm run build && node build/index.js --site global

使用法

Visual Studio Code 統合

ユーザー設定(JSON)ファイルに以下のJSON設定を追加します。Ctrl Ctrl/Cmd + Shift + Pを押してPreferences: Open User Settings (JSON)を検索し、アクセスしてください。

オプション1: 環境変数を使用する

{
  "mcp": {
    "servers": {
      "leetcode": {
        "type": "stdio",
        "command": "npx",
        "args": ["-y", "@jinzcdev/leetcode-mcp-server"],
        "env": {
          "LEETCODE_SITE": "global",
          "LEETCODE_SESSION": "<YOUR_LEETCODE_SESSION_COOKIE>"
        }
      }
    }
  }
}

オプション2: コマンドライン引数の使用

{
  "mcp": {
    "servers": {
      "leetcode": {
        "type": "stdio",
        "command": "npx",
        "args": [
          "-y",
          "@jinzcdev/leetcode-mcp-server",
          "--site",
          "global",
          "--session",
          "<YOUR_LEETCODE_SESSION_COOKIE>"
        ]
      }
    }
  }
}

LeetCode China サイトの場合は、 --siteパラメータをcnに変更します。

[!ヒント]

サーバーは次の環境変数をサポートしています。

  • LEETCODE_SITE : LeetCode APIエンドポイント('global'または'cn')

  • LEETCODE_SESSION : 認証された API アクセス用の LeetCode セッション Cookie

優先度に関する注意: コマンドライン引数と環境変数の両方が指定されている場合、コマンドライン引数が環境変数よりも優先されます。例:

  • LEETCODE_SITE=cnが設定されているが、 leetcode-mcp-server --site globalを実行すると、サーバーはglobalを使用します。

  • LEETCODE_SESSIONが存在するが、 --session "new_cookie"を指定すると、コマンドラインセッション値が使用されます。

利用可能なツール

問題

道具

グローバル

CN

認証が必要です

説明

毎日のチャレンジ

✅

✅

❌

今日のLeetCodeデイリーチャレンジ問題を取得します

問題を取得する

✅

✅

❌

特定の LeetCode 問題の詳細を取得します

検索の問題

✅

✅

❌

複数のフィルター条件でLeetCodeの問題を検索します

ユーザー

道具

グローバル

CN

認証が必要です

説明

ユーザープロファイルを取得する

✅

✅

❌

LeetCodeユーザーのプロフィール情報を取得します

get_user_contest_ranking

✅

✅

❌

ユーザーのコンテストランキング統計を取得します

最近のACサブミッションを取得する

✅

✅

❌

ユーザーの最近承認された提出物を取得します

最近の投稿を取得する

✅

❌

❌

ユーザーの最近の投稿履歴を取得します

get_user_status

✅

✅

✅

現在のユーザーの現在のステータスを取得します

問題報告を取得する

✅

✅

✅

特定の問題に対する詳細な提出分析を提供します

問題の進行状況を取得する

✅

✅

✅

現在のユーザーの問題解決の進捗状況を取得します

すべての提出物を取得する

✅

✅

✅

現在のユーザーの送信履歴を取得します

注記

道具

グローバル

CN

認証が必要です

説明

検索ノート

❌

✅

✅

フィルタリングオプションを使用してユーザーノートを検索します

メモを取得する

❌

✅

✅

質問IDで特定の問題のメモを取得します

ノートを作成

❌

✅

✅

特定の問題に対する新しいメモを作成します

更新ノート

❌

✅

✅

既存のメモを新しいコンテンツで更新します

ソリューション

道具

グローバル

CN

認証が必要です

説明

問題解決策のリスト

✅

✅

❌

特定の問題に対するコミュニティソリューションのリストを取得します

問題の解決策を取得する

✅

✅

❌

特定のソリューションの完全なコンテンツを取得します

ツールパラメータ

問題

  • get_daily_challenge - 今日の LeetCode デイリーチャレンジの問題を完全な詳細とともに取得します

    • パラメータは必要ありません

  • get_problem - 特定の LeetCode 問題の詳細を取得します

    • titleSlug : 問題のURLスラッグ/識別子(文字列、必須)

  • search_problems - 複数のフィルター条件に基づいて LeetCode の問題を検索します

    • category : 問題カテゴリフィルター (文字列、オプション、デフォルト: "all-code-essentials")

    • tags : 問題をフィルタリングするためのトピックタグのリスト(文字列[]、オプション)

    • difficulty : 問題の難易度フィルター (列挙型: "EASY", "MEDIUM", "HARD"、オプション)

    • searchKeywords : 問題のタイトルと説明で検索するキーワード(文字列、オプション)

    • limit : 返される問題の最大数(数値、オプション、デフォルト: 10)

    • offset : スキップする問題の数(数値、オプション)

ユーザー

  • get_user_profile - LeetCodeユーザーのプロフィール情報を取得します

    • username : LeetCode ユーザー名 (文字列、必須)

  • get_user_contest_ranking - ユーザーのコンテストランキング情報を取得します

    • username : LeetCode ユーザー名 (文字列、必須)

    • attended : ユーザーが参加したコンテストのみを含めるかどうか(ブール値、オプション、デフォルト: true)

  • get_recent_submissions - LeetCode Global におけるユーザーの最近の投稿を取得します

    • username : LeetCode ユーザー名 (文字列、必須)

    • limit : 返される送信の最大数(数値、オプション、デフォルト: 10)

  • get_recent_ac_submissions - ユーザーの最近承認された提出物を取得します

    • username : LeetCode ユーザー名 (文字列、必須)

    • limit : 返される送信の最大数(数値、オプション、デフォルト: 10)

  • get_user_status - 現在のユーザーのステータスを取得します

    • パラメータは必要ありません

  • get_problem_submission_report - 特定の提出に関する詳細情報を取得します

    • id : 数値の提出ID(数値、必須)

  • get_problem_progress - 現在のユーザーの問題解決の進捗状況を取得します

    • offset : スキップする質問の数(数値、オプション、デフォルト: 0)

    • limit : 返される質問の最大数(数値、オプション、デフォルト: 100)

    • questionStatus : 質問のステータスでフィルタリングします(列挙型: "ATTEMPTED"、"SOLVED"、オプション)

    • difficulty : 難易度レベルでフィルタリングする(文字列[]、オプション)

  • get_all_submissions - ユーザーの投稿のページ区切りリストを取得します

    • limit : 返される送信の最大数(数値、デフォルト: 20)

    • offset : スキップする送信数(数値、デフォルト: 0)

    • questionSlug : オプションの問題識別子(文字列、オプション)

    • lang : プログラミング言語フィルター(文字列、オプション、CNのみ)

    • status : 送信ステータスフィルター (列挙型: "AC", "WA"、オプション、CN のみ)

    • lastKey : 次のページを取得するためのページネーショントークン(文字列、オプション、CNのみ)

注記

  • search_notes - LeetCode China のユーザーノートを検索します

    • keyword : ノートをフィルタリングするための検索語(文字列、オプション)

    • limit : 返されるノートの最大数(数値、オプション、デフォルト: 10)

    • skip : スキップする音符の数(数値、オプション、デフォルト: 0)

    • orderBy : 返されるメモの並べ替え順序 (列挙型: "ASCENDING"、"DESCENDING"、オプション、デフォルト: "DESCENDING")

  • get_note - 特定の LeetCode 問題に関するユーザーメモを取得します

    • questionId : LeetCode問題の質問ID(文字列、必須)

    • limit : 返されるノートの最大数(数値、オプション、デフォルト: 10)

    • skip : スキップする音符の数(数値、オプション、デフォルト: 0)

  • create_note - 特定の LeetCode 問題に対する新しいメモを作成します

    • questionId : LeetCode問題の質問ID(文字列、必須)

    • content : ノートの内容。マークダウン形式をサポートします(文字列、必須)

    • summary : メモの短い要約またはタイトル(文字列、オプション)

  • update_note - 既存のノートを新しいコンテンツまたは要約で更新します

    • noteId : 更新するノートのID(文字列、必須)

    • content : ノートの新しいコンテンツ。マークダウン形式をサポートします(文字列、必須)

    • summary : ノートの新しい短い要約またはタイトル(文字列、オプション)

ソリューション

  • list_problem_solutions - 特定の問題に対するコミュニティソリューションのリストを取得します

    • questionSlug : 問題のURLスラッグ/識別子(文字列、必須)

    • limit : 返されるソリューションの最大数(数値、オプション、デフォルト: 10)

    • skip : スキップするソリューションの数(数値、オプション)

    • userInput : ソリューションをフィルタリングするための検索語句(文字列、オプション)

    • tagSlugs : ソリューションをフィルタリングするためのタグ識別子の配列(文字列[]、オプション、デフォルト: [])

    • orderBy : 返されるソリューションの並べ替え基準

      • グローバル: 列挙型: "HOT"、"MOST_RECENT"、"MOST_VOTES"、オプション、デフォルト: "HOT"

      • CN: 列挙型: "DEFAULT"、"MOST_UPVOTE"、"HOT"、"NEWEST_TO_OLDEST"、"OLDEST_TO_NEWEST"、オプション、デフォルト: "DEFAULT"

  • get_problem_solution - 特定のソリューションの完全なコンテンツを取得します

    • topicId : ソリューションの一意のトピックID(文字列、必須、グローバルのみ)

    • slug : ソリューションの一意のスラッグ/識別子(文字列、必須、CNのみ)

利用可能なリソース

リソース名

グローバル

CN

認証が必要です

説明

問題カテゴリ

✅

✅

❌

すべての問題分類カテゴリのリスト

問題タグ

✅

✅

❌

アルゴリズムとデータ構造のタグの詳細なコレクション

問題言語

✅

✅

❌

サポートされているすべてのプログラミング言語の完全なリスト

問題の詳細

✅

✅

❌

特定の問題に関する詳細を提供します

問題解決

✅

✅

❌

特定のソリューションの完全なコンテンツを提供します

リソースURI

  • 問題カテゴリ- すべての問題分類カテゴリのリスト

    • URI: categories://problems/all

  • 問題タグ- アルゴリズムとデータ構造のタグの詳細なコレクション

    • URI: tags://problems/all

  • problem-langs - LeetCode でサポートされているすべてのプログラミング言語の完全なリスト

    • URI: langs://problems/all

  • 問題の詳細- 特定の LeetCode 問題に関する詳細を提供します

    • URI: problem://{titleSlug}

    • パラメータ:

      • titleSlug : LeetCode URL に表示される問題識別子

  • 問題-解決策- 特定の解決策の完全な内容を提供します

    • グローバルURI: solution://{topicId}

      • パラメータ:

        • topicId : ソリューションの一意のトピックID

    • CN URI: solution://{slug}

      • パラメータ:

        • slug : ソリューションの一意のスラッグ/識別子

認証

ユーザー固有のデータ アクセスには、LeetCode セッション認証が必要です。

  1. LeetCodeにログイン(グローバルサイトまたは中国サイト)

  2. ブラウザ開発者ツールからLEETCODE_SESSION Cookieを抽出する

  3. --sessionフラグまたはLEETCODE_SESSION環境変数を使用してサーバーを構成する

応答フォーマット

すべてのツールは、次の構造の JSON 形式の応答を返します。

{
  "content": [
    {
      "type": "text",
      "text": "JSON_DATA_STRING"
    }
  ]
}

JSON_DATA_STRINGには、要求されたデータまたは失敗した要求のエラー メッセージのいずれかが含まれます。

ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています。

Available Tools

1 tool
get_problem_solutionA

Retrieves full content of a community solution article (read-only, no auth). Requires topicId from list_problem_solutions. Returns article text, author, and metadata as JSON. Use list_problem_solutions first to discover solutions and obtain topicId.

ParametersJSON Schema
NameRequiredDescriptionDefault
topicIdYesSolution topicId from list_problem_solutions response

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully covers behavioral traits: read-only, no authentication, and return format (JSON with text, author, metadata).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three concise sentences, front-loaded with purpose and safety, no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Complete for a simple retrieval tool with one parameter and no output schema; mentions return fields and prerequisite step. Could specify error cases, but not required.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, baseline 3. The description adds value by explaining the topicId's origin from list_problem_solutions, which is not in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Retrieves full content of a community solution article' with specific verb and resource. It is unambiguous and needs no sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly instructs to first use list_problem_solutions to obtain topicId, providing clear prerequisite and sequential usage guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv1.4.0
    • Addedget_problem_solution
    • Removedget_user_contest_ranking
  2. 9 tool updatesv1.4.0
    • Removedget_daily_challenge
    • Removedget_problem
    • Removedget_problem_solution
    • Removedget_recent_ac_submissions
    • Removedget_recent_submissions
    • Changedget_user_contest_ranking2 fields changed
      • changedInput schema / properties / attended / description
        Previous value: -"Whether to include only the contests the user has participated in (true) or all contests (false); defaults to true"New value: +"true = only contests the user attended (default); false = include all contests in history"
      • changedInput schema / properties / username / description
        Previous value: -"LeetCode username to retrieve contest ranking information for"New value: +"LeetCode username whose contest ranking to fetch"
    • Removedget_user_profile
    • Removedlist_problem_solutions
    • Removedsearch_problems
  3. 1 tool updatev1.0.0
    • Changedget_daily_challenge1 field changed
      • removedInput schema / additionalProperties
        Removed value: -false
  4. 9 tool updates
    • First observedget_daily_challenge
    • First observedget_problem
    • First observedget_problem_solution
    • First observedget_recent_ac_submissions
    • First observedget_recent_submissions
    • First observedget_user_contest_ranking
    • First observedget_user_profile
    • First observedlist_problem_solutions
    • First observedsearch_problems

TDQS

A4.2/5.0

Scored across 1 tool

Disambiguation4/5

Only one tool exists, so there is no ambiguity with other tools. However, the tool's dependency on a missing listing tool could cause confusion for agents trying to use it.

Naming Consistency5/5

With a single tool, naming is trivially consistent. The pattern 'get_problem_solution' follows verb_noun convention.

Tool Count1/5

A single tool for a LeetCode server is far too few. Expected operations (list problems, get problem details, submit solutions, etc.) are missing, making the surface extremely limited.

Completeness1/5

The only tool requires a topicId from a non-existent list_problem_solutions tool, rendering it unusable. The surface is severely incomplete.

Maintenance

ActivityStale
ResponsivenessSlow

Related MCP Connectors

Related MCP Servers