LeetCode MCP Server

by jinzcdev
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Provides tools for accessing LeetCode problems, user data, search capabilities, and submission tracking across both leetcode.com and leetcode.cn platforms. Enables retrieval of detailed problem descriptions, user profiles, submission history, and contest performance statistics.

LeetCode MCP サーバー

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

特徴

  • マルチサイトサポート:leetcode.comとleetcode.cnの両方のプラットフォームをサポート
  • 問題データの検索: 詳細な問題の説明、制約、例、および解決アプローチを取得します。
  • ユーザーデータアクセス: ユーザープロフィール、提出履歴、コンテストパフォーマンスを取得します
  • 高度な検索機能: タグ、難易度、カテゴリで問題をフィルタリング
  • デイリーチャレンジトラッキング:デイリーチャレンジ問題に簡単にアクセスできます

前提条件

  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)を検索し、アクセスしてください。

{ "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"を指定すると、コマンドラインセッション値が使用されます。

ツール

サーバーは、機能とプラットフォームの互換性によって分類された包括的なツール スイートを提供します。

問題ツール

オプションの認証により、グローバル サイトと中国サイトの両方で利用できます。

ツール名説明パラメータ
リートコードデイリーチャレンジ今日の LeetCode Daily Challenge を完全なメタデータとともに取得しますなし
リートコードの問題指定された LeetCode の問題の包括的な詳細を取得しますtitleSlug (文字列、必須): 問題のURL識別子(例:'two-sum')
leetcode_search_problemsLeetCodeの問題全体でフィルタリングされた検索を実行しますcategory (文字列, オプション): 問題の分類tags (文字列[], オプション): トピックタグフィルターdifficulty (文字列, オプション): 問題の複雑さのレベル ('EASY', 'MEDIUM', 'HARD') limit (数値, オプション): 最大結果数offset (数値, オプション): ページネーションオフセット

ユーザーツール

両方のプラットフォームにわたってユーザー固有のデータを提供します。

ツール名説明パラメータ
leetcode_user_profileLeetCodeユーザーの完全なプロフィール情報を取得しますusername (文字列、必須): LeetCode ユーザー名
leetcode_user_contest_rankingユーザーのコンテストランキング統計を取得しますusername (文字列、必須):LeetCodeユーザー名attended (ブール値、オプション):出席したコンテストのみをフィルターします

グローバルサイト固有のユーザーツール

leetcode.com プラットフォーム限定。

ツール名説明パラメータ
leetcode_recent_submissionsユーザーの最近の送信履歴を取得します(グローバル)username (文字列、必須):LeetCodeユーザー名limit (数値、オプション):結果制限
leetcode_recent_ac_submissionsユーザーの最近承認された提出物を取得します (グローバル)username (文字列、必須):LeetCodeユーザー名limit (数値、オプション):結果制限

中国サイト固有のユーザーツール

leetcode.cn プラットフォーム限定。

ツール名説明パラメータ
leetcode_user_recent_ac_submissions最近受理された投稿を取得します(中国)username (文字列、必須):LeetCode China ユーザー名limit (数値、オプション):結果制限

認証された共通ツール

両方のプラットフォームで利用可能なセッション認証が必要です。

ツール名説明パラメータ
leetcode_user_status認証されたユーザーの現在のステータスを取得しますなし
leetcode_problem_submission_detail詳細な提出分析を提供しますid (数字、必須): 提出ID
leetcode_user_progress_questionsユーザーの問題解決の進捗状況を追跡しますoffset (数値、必須): ページネーションオフセットlimit (数値、必須): 結果の制限questionStatus (列挙型、オプション): 'ATTEMPTED' または 'SOLVED' フィルターdifficulty (文字列[]、オプション): 複雑さのレベルフィルター

グローバルサイト固有の認証ツール

leetcode.com 専用の認証ツール。

名前説明パラメータ
leetcode_user_all_submissionsページ分けされた送信履歴を取得します(グローバル)limit (数値, 必須): 結果の制限offset (数値, 必須): ページネーションのオフセットquestionSlug (文字列, オプション): 問題識別子フィルター

中国サイト固有の認証ツール

leetcode.cn専用の認証ツール。

ツール名説明パラメータ
leetcode_user_all_submissions包括的な提出履歴を取得します(中国)limit (数値、必須): 結果の制限offset (数値、必須): ページネーションのオフセットquestionSlug (文字列、オプション): 問題識別子lang (文字列、オプション): プログラミング言語フィルターstatus (文字列、オプション): 提出ステータスフィルターlastKey (文字列、オプション): ページネーショントークン

リソース

サーバーは、URI エンドポイントを介してプラットフォーム メタデータにアクセスするための参照リソースを提供します。

リソース名説明URI
問題カテゴリ完全な問題分類カテゴリleetcode://problems/categories/all
問題タグアルゴリズムとデータ構造のタグのコレクションleetcode://problems/tags/all
問題言語サポートされているプログラミング言語のリストleetcode://problems/langs/all
ソリューション記事LeetCodeソリューション記事グローバル: leetcode://solutions/{topicId} cn: leetcode://solutions/{slug}

認証

高度な機能には LeetCode セッション認証が必要です。

  1. LeetCodeにログイン(グローバルサイトまたは中国サイト)
  2. ブラウザ開発者ツールからLEETCODE_SESSION Cookieを抽出する
  3. --sessionフラグまたはLEETCODE_SESSION環境変数を使用してサーバーを構成する

応答フォーマット

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

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

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

ライセンス

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

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

LeetCode API との統合を提供し、leetcode.com と leetcode.cn プラットフォームの両方でプログラミングの問題、コンテスト、ソリューション、ユーザー データとの自動的な対話を可能にするモデル コンテキスト プロトコル サーバーです。

  1. Features
    1. Prerequisites
      1. Installation
        1. Installing via Smithery
        2. Manual Installation
      2. Usage
        1. Visual Studio Code Integration
      3. Environment Variables
        1. Tools
          1. Problem Tools
          2. User Tools
          3. Global Site-Specific User Tools
          4. China Site-Specific User Tools
          5. Authenticated Common Tools
          6. Global Site-Specific Authenticated Tools
          7. China Site-Specific Authenticated Tools
        2. Resources
          1. Authentication
            1. Response Format
              1. License
                ID: 4gwka0r9rw