Skip to main content
Glama

Supabase MCP Server

by gevans3000

Supabase MCP サーバー

Supabaseデータベースと連携するためのモデルコンテキストプロトコル(MCP)サーバー。このサーバーは、FastMCP Python SDKを使用してモデルコンテキストプロトコルを実装し、大規模言語モデル(LLM)用のデータベース操作ツールを提供します。

特徴

  • フィルタリング、ページネーション、ソート機能を使用して Supabase テーブルからレコードを読み取ります
  • Supabase テーブルに新しいレコード (単一またはバッチ) を作成します
  • フィルター条件に基づいて既存のレコードを更新する
  • フィルター条件に基づいてテーブルからレコードを削除する
  • MCPのStdioトランスポートを使用して通信します

前提条件

  • Python 3.8以上
  • テーブルがすでに設定されているSupabaseプロジェクト
  • 認証用の Supabase サービス ロール キー

インストール

  1. このリポジトリをクローンします:
    git clone https://github.com/gevans3000/supabase-mcp.git cd supabase-mcp
  2. 仮想環境をセットアップします (推奨):
    # Create a virtual environment python -m venv venv # Activate the virtual environment # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
  3. 依存関係をインストールします。
    pip install -r requirements.txt
  4. 環境変数を設定します。
    • .env.exampleファイルを.envにコピーします。
      cp .env.example .env # On Windows, use: # copy .env.example .env
    • .envファイルに Supabase URL とサービス ロール キーを入力します。
      SUPABASE_URL=your_supabase_project_url SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key

使用法

サーバーの起動

仮想環境がアクティブになっていることを確認してから、サーバーを実行します。

python server.py

サーバーは Stdio トランスポートを使用するため、標準入力で MCP 要求をリッスンし、標準出力で応答します。

MCPクライアントとの統合

このサーバーはモデルコンテキストプロトコル(MCP)を実装しており、MCP対応のあらゆるクライアントと統合できます。例えば、MCPツールをサポートするLLMフレームワークと連携して使用できます。

Windsurf/Cursor MCP設定への追加

この MCP サーバーを Windsurf または Cursor 構成に追加するには:

  1. mcp_config.jsonファイルを見つけます。
    • Windows: C:\Users\<username>\.codeium\windsurf\mcp_config.json
    • macOS: ~/.codeium/windsurf/mcp_config.json
    • Linux: ~/.codeium/windsurf/mcp_config.json
  2. Supabase MCP サーバーをmcpServersセクションに追加します。
{ "mcpServers": { // ... other servers "supabase": { "command": "python", "args": [ "/path/to/your/supabase-mcp/server.py" ], "env": { "SUPABASE_URL": "your_supabase_url", "SUPABASE_SERVICE_ROLE_KEY": "your_supabase_key" } } } }

/path/to/your/supabase-mcp/server.pyを server.py ファイルへの絶対パスに置き換えます。

: 分離性を高めるために、仮想環境から Python 実行ファイルを使用できます。

{ "mcpServers": { "supabase": { "command": "/path/to/your/venv/bin/python", // or "venv\\Scripts\\python.exe" on Windows "args": [ "/path/to/your/supabase-mcp/server.py" ] } } }
  1. 変更を適用するには、Windsurf/Cursor アプリケーションを再起動します。
  2. Supabase MCP ツールが AI アシスタントで利用できるようになります。

ツールの説明

サーバーは次のツールを提供します。

1. レコードの読み取り

柔軟なクエリ オプションを使用して、Supabase データベース テーブルからレコードを読み取ります。

パラメータ:

  • table (文字列、必須): 読み取るテーブルの名前
  • columns (文字列、オプション、デフォルト: "*"): 選択する列 (カンマ区切り、またはすべてを指定する場合は *)
  • filters (オブジェクト、オプション):キーと値のペアとしてのフィルタリング条件
  • limit (整数、オプション): 返されるレコードの最大数
  • offset (整数、オプション):ページ区切りでスキップするレコード数
  • order_by (オブジェクト、オプション): 列:方向のペアとして並べ替えオプションを指定します。

例:

{ "table": "users", "columns": "id,name,email", "filters": {"is_active": true}, "limit": 10, "offset": 0, "order_by": {"created_at": "desc"} }
2. レコードを作成する

Supabase データベース テーブルに 1 つ以上のレコードを作成します。

パラメータ:

  • table (文字列、必須): レコードを作成するテーブルの名前
  • records (オブジェクトまたは配列、必須): 作成する単一のレコードオブジェクトまたはレコードオブジェクトの配列

例(単一レコード):

{ "table": "users", "records": { "name": "John Doe", "email": "john@example.com", "role": "user" } }

例 (複数のレコード):

{ "table": "users", "records": [ { "name": "John Doe", "email": "john@example.com", "role": "user" }, { "name": "Jane Smith", "email": "jane@example.com", "role": "admin" } ] }
3. レコードの更新

フィルター条件に基づいて、Supabase データベース テーブル内の既存のレコードを更新します。

パラメータ:

  • table (文字列、必須): レコードを更新するテーブルの名前
  • updates (オブジェクト、必須): キーと値のペアとして更新するフィールド
  • filters (オブジェクト、必須):更新するレコードを識別するためのフィルタリング条件

例:

{ "table": "users", "updates": { "is_verified": true, "last_login_at": "2025-04-04T15:30:00Z" }, "filters": { "id": 123 } }
4. レコードの削除

フィルター条件に基づいて Supabase データベース テーブルからレコードを削除します。

パラメータ:

  • table (文字列、必須): レコードを削除するテーブルの名前
  • filters (オブジェクト、必須): 削除するレコードを識別するためのフィルタリング条件

例:

{ "table": "expired_sessions", "filters": { "expires_at": {"lt": "2025-01-01T00:00:00Z"} } }

発達

プロジェクト構造

  • server.py : メイン MCP サーバーの実装
  • supabase_client.py : Supabase クライアントラッパー
  • requirements.txt : Python の依存関係
  • .env.example : 環境変数ファイルの例

新しいツールの追加

サーバーに新しいツールを追加するには:

  1. server.pyでツールのリクエストパラメータの Pydantic モデルを定義します。
  2. SupabaseMCPServerクラスにハンドラーメソッドを追加する
  3. _register_toolsメソッドで、わかりやすい名前とドキュメントを付けてツールを登録します。

ライセンス

MITライセンス

貢献

貢献を歓迎します!お気軽にプルリクエストを送信してください。

-
security - not tested
-
license - not tested
-
quality - not tested

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.

モデル コンテキスト プロトコルを実装して、LLM に Supabase データベースと対話するためのツールを提供し、フィルタリング機能やページ区切り機能を使用してレコードの読み取り、作成、更新、削除などの操作をサポートします。

  1. 特徴
    1. 前提条件
      1. インストール
        1. 使用法
          1. サーバーの起動
          2. MCPクライアントとの統合
          3. ツールの説明
        2. 発達
          1. プロジェクト構造
          2. 新しいツールの追加
        3. ライセンス
          1. 貢献

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              A Model Context Protocol server that enables LLMs to interact with Salesforce data through SOQL queries, SOSL searches, and various API operations including record management.
              Last updated -
              10
              77
              Python
              MIT License
            • -
              security
              A
              license
              -
              quality
              A Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.
              Last updated -
              340
              TypeScript
              MIT License
              • Apple
            • -
              security
              A
              license
              -
              quality
              A Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.
              Last updated -
              340
              MIT License
              • Apple
            • -
              security
              A
              license
              -
              quality
              A Model Context Protocol server that enables Claude and other LLMs to perform database operations and invoke Edge Functions within Supabase through natural language.
              Last updated -
              TypeScript
              MIT License

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/gevans3000/supabase-mcp'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server