Skip to main content
Glama

Supabase MCP サーバー

鍛冶屋のバッジ Supabaseのデータベース、ストレージ、エッジ機能と連携するための包括的なツールを提供するModel Context Protocol(MCP)サーバー。このサーバーは、SupabaseサービスとMCP対応アプリケーションとのシームレスな統合を実現します。

概要

Supabase MCP サーバーは、MCP クライアントと Supabase の一連のサービス間のブリッジとして機能し、次の機能を提供します。

  • 豊富なクエリ機能を備えたデータベース操作

  • ファイルと資産のストレージ管理

  • エッジ関数の呼び出し

  • プロジェクトと組織管理

  • ユーザー認証と管理

  • ロールベースのアクセス制御

Related MCP server: Supabase MCP Server

建築

サーバーは TypeScript を使用して構築され、モジュール アーキテクチャに従います。

supabase-server/
├── src/
│   ├── index.ts              # Main server implementation
│   └── types/
│       └── supabase.d.ts     # Type definitions
├── package.json
├── tsconfig.json
├── config.json.example       # Example configuration file
└── .env.example             # Environment variables template

主要コンポーネント

  • サーバークラス: MCPサーバーインターフェースを実装し、すべてのクライアント要求を処理します。

  • 型定義: すべての操作に対する包括的なTypeScript定義

  • 環境設定: 環境変数による安全な設定管理

  • エラー処理: 詳細なエラーメッセージによる堅牢なエラー処理

前提条件

  • Node.js 16.x 以上

  • Supabase プロジェクト:

    • プロジェクトURL

    • サービスロールキー(管理者操作用)

    • アクセストークン(管理操作用)

  • MCP互換クライアント

インストール

Smithery経由でインストール

Smithery経由で Claude Desktop 用の Supabase Server を自動的にインストールするには:

npx -y @smithery/cli install supabase-server --client claude
  1. リポジトリをクローンします。

git clone https://github.com/DynamicEndpoints/supabase-mcp.git
cd supabase-mcp
  1. 依存関係をインストールします:

npm install
  1. 環境構成を作成します。

cp .env.example .env
  1. 環境変数を設定します。

SUPABASE_URL=your_project_url_here
SUPABASE_KEY=your_service_role_key_here
SUPABASE_ACCESS_TOKEN=your_access_token_here  # Required for management operations
  1. サーバー構成を作成します。

cp config.json.example config.json
  1. サーバーを構築します。

npm run build

構成

サーバーは、環境変数とconfig.jsonファイルの両方を通じて、広範な設定をサポートしています。設定オプションの詳細な内訳は次のとおりです。

サーバー構成

{
  "server": {
    "name": "supabase-server",    // Server name
    "version": "0.1.0",           // Server version
    "port": 3000,                 // Port number (if running standalone)
    "host": "localhost"           // Host address (if running standalone)
  }
}

Supabase 構成

{
  "supabase": {
    "project": {
      "url": "your_project_url",
      "key": "your_service_role_key",
      "accessToken": "your_access_token"
    },
    "storage": {
      "defaultBucket": "public",           // Default storage bucket
      "maxFileSize": 52428800,            // Max file size in bytes (50MB)
      "allowedMimeTypes": [               // Allowed file types
        "image/*",
        "application/pdf",
        "text/*"
      ]
    },
    "database": {
      "maxConnections": 10,               // Max DB connections
      "timeout": 30000,                   // Query timeout in ms
      "ssl": true                         // SSL connection
    },
    "auth": {
      "autoConfirmUsers": false,          // Auto-confirm new users
      "disableSignup": false,             // Disable public signups
      "jwt": {
        "expiresIn": "1h",               // Token expiration
        "algorithm": "HS256"              // JWT algorithm
      }
    }
  }
}

ログ構成

{
  "logging": {
    "level": "info",                      // Log level
    "format": "json",                     // Log format
    "outputs": ["console", "file"],       // Output destinations
    "file": {
      "path": "logs/server.log",          // Log file path
      "maxSize": "10m",                   // Max file size
      "maxFiles": 5                       // Max number of files
    }
  }
}

セキュリティ構成

{
  "security": {
    "cors": {
      "enabled": true,
      "origins": ["*"],
      "methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
      "allowedHeaders": ["Content-Type", "Authorization"]
    },
    "rateLimit": {
      "enabled": true,
      "windowMs": 900000,                 // 15 minutes
      "max": 100                          // Max requests per window
    }
  }
}

監視構成

{
  "monitoring": {
    "enabled": true,
    "metrics": {
      "collect": true,
      "interval": 60000                   // Collection interval in ms
    },
    "health": {
      "enabled": true,
      "path": "/health"                   // Health check endpoint
    }
  }
}

完全なサンプル構成ファイルについては、 config.json.example参照してください。

MCP統合

サーバーを MCP 設定 (cline_mcp_settings.json) に追加します。

{
  "mcpServers": {
    "supabase": {
      "command": "node",
      "args": ["path/to/supabase-server/build/index.js"],
      "env": {
        "SUPABASE_URL": "your_project_url",
        "SUPABASE_KEY": "your_service_role_key",
        "SUPABASE_ACCESS_TOKEN": "your_access_token"
      },
      "config": "path/to/config.json"  // Optional: path to configuration file
    }
  }
}

利用可能なツール

データベース操作

レコード作成

特定のフィールドを返す機能をサポートするテーブルに新しいレコードを作成します。

{
  table: string;
  data: Record<string, any>;
  returning?: string[];
}

例:

{
  table: "users",
  data: {
    name: "John Doe",
    email: "john@example.com"
  },
  returning: ["id", "created_at"]
}

レコード読み取り

高度なフィルタリング、結合、フィールド選択を使用してレコードを読み取ります。

{
  table: string;
  select?: string[];
  filter?: Record<string, any>;
  joins?: Array<{
    type?: 'inner' | 'left' | 'right' | 'full';
    table: string;
    on: string;
  }>;
}

例:

{
  table: "posts",
  select: ["id", "title", "user.name"],
  filter: { published: true },
  joins: [{
    type: "left",
    table: "users",
    on: "posts.user_id=users.id"
  }]
}

更新レコード

フィルタリング機能と戻り機能を使用してレコードを更新します。

{
  table: string;
  data: Record<string, any>;
  filter?: Record<string, any>;
  returning?: string[];
}

例:

{
  table: "users",
  data: { status: "active" },
  filter: { email: "john@example.com" },
  returning: ["id", "status", "updated_at"]
}

レコードの削除

フィルタリング機能と戻り機能を使用してレコードを削除します。

{
  table: string;
  filter?: Record<string, any>;
  returning?: string[];
}

例:

{
  table: "posts",
  filter: { status: "draft" },
  returning: ["id", "title"]
}

ストレージ操作

アップロードファイル

設定可能なオプションを使用して、Supabase ストレージにファイルをアップロードします。

{
  bucket: string;
  path: string;
  file: File | Blob;
  options?: {
    cacheControl?: string;
    contentType?: string;
    upsert?: boolean;
  };
}

例:

{
  bucket: "avatars",
  path: "users/123/profile.jpg",
  file: imageBlob,
  options: {
    contentType: "image/jpeg",
    upsert: true
  }
}

ダウンロードファイル

Supabase Storage からファイルをダウンロードします。

{
  bucket: string;
  path: string;
}

例:

{
  bucket: "documents",
  path: "reports/annual-2023.pdf"
}

エッジ関数

呼び出し関数

パラメーターとカスタム オプションを使用して Supabase Edge Functions を呼び出します。

{
  function: string;
  params?: Record<string, any>;
  options?: {
    headers?: Record<string, string>;
    responseType?: 'json' | 'text' | 'arraybuffer';
  };
}

例:

{
  function: "process-image",
  params: {
    url: "https://example.com/image.jpg",
    width: 800
  },
  options: {
    responseType: "json"
  }
}

ユーザー管理

リストユーザー

ページ区切りをサポートするユーザーを一覧表示します。

{
  page?: number;
  per_page?: number;
}

ユーザー作成

メタデータを使用して新しいユーザーを作成します。

{
  email: string;
  password: string;
  data?: Record<string, any>;
}

更新ユーザー

ユーザーの詳細を更新します。

{
  user_id: string;
  email?: string;
  password?: string;
  data?: Record<string, any>;
}

ユーザー削除

ユーザーを削除します。

{
  user_id: string;
}

ユーザーロールの割り当て

ユーザーにロールを割り当てます。

{
  user_id: string;
  role: string;
}

ユーザーロールの削除

ユーザーからロールを削除します。

{
  user_id: string;
  role: string;
}

エラー処理

サーバーは、一般的なシナリオに対して詳細なエラー メッセージを提供します。

  • 無効なパラメータ

  • 認証失敗

  • 権限の問題

  • レート制限

  • ネットワークエラー

  • データベースの制約

エラーは標準化された形式で返されます。

{
  code: ErrorCode;
  message: string;
  details?: any;
}

発達

テストの実行

npm test

建物

npm run build

リンティング

npm run lint

評価の実行

evalsパッケージはmcpクライアントをロードし、index.tsファイルを実行するため、テスト間でリビルドする必要はありません。npxコマンドの先頭に環境変数をロードすることもできます。完全なドキュメントはこちらでご覧いただけます。

OPENAI_API_KEY=your-key  npx mcp-eval src/evals/evals.ts src/index.ts

貢献

  1. リポジトリをフォークする

  2. 機能ブランチを作成する

  3. 変更をコミットする

  4. ブランチにプッシュする

  5. プルリクエストを作成する

ライセンス

MITライセンス - 詳細はライセンスを参照

サポート

サポートについては、以下をご覧ください。

  1. 既存の問題/解決を確認する

  2. 詳細な再現手順を記載した新しい問題を作成する

  3. 関連するエラーメッセージと環境の詳細を含める

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

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

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/DynamicEndpoints/supabase-mcp'

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