Cover image
Try Now
2025-03-30

Supabase MCP服务器在Python中创建。

3 years

Works with Finder

5

Github Watches

43

Github Forks

81

Github Stars

Supabase MCP Server

A Model Context Protocol (MCP) server that provides tools for interacting with a Supabase database. This server enables AI assistants to perform database operations through a standardized interface.

NOTE: This Supabase MCP server was created as a demonstration of my AI IDE coding workflow. It is still a work in progress which I will expand on in future videos on my channel.

Features

  • Read Table Rows: Query data from Supabase tables with optional filtering, pagination, and column selection
  • Create Table Records: Insert new records into Supabase tables
  • Update Table Records: Modify existing records in Supabase tables based on filters
  • Delete Table Records: Remove records from Supabase tables based on filters

Prerequisites

  • Docker or Docker Desktop
  • Supabase account and project

Installation

  1. Clone the repository:
    git clone https://github.com/coleam00/supabase-mcp.git
    cd supabase-mcp
    

Docker Setup

  1. Build the Docker image:
    docker build -t mcp/supabase .
    

Usage

Running as an MCP Server with Docker

The Supabase MCP server can be integrated with AI assistants using the Model Context Protocol.

  1. Include the below configuration in your MCP config (in Claude Desktop, Windsurf, etc.)

Be sure to build the container with the installation steps first!

{
  "mcpServers": {
    "supabase": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "-e", "SUPABASE_URL", "-e", "SUPABASE_SERVICE_KEY", "mcp/supabase"],
      "env": {
        "SUPABASE_URL": "YOUR-SUPABASE-URL",
        "SUPABASE_SERVICE_KEY": "YOUR-SUPABASE-SERVICE-ROLE-KEY"
      }
    }
  }
}
  1. Replace YOUR-SUPABASE-URL and YOUR-SUPABASE-SERVICE-ROLE-KEY with your actual Supabase credentials.

  2. The AI assistant can now access the Supabase database through the MCP server using the provided tools.

For more information on the Model Context Protocol, visit modelcontextprotocol.io.

Available Tools

Read Table Rows

read_table_rows(
    table_name: str,
    columns: Optional[List[str]] = None,
    filters: Optional[Dict[str, Any]] = None,
    limit: Optional[int] = None,
    offset: Optional[int] = None
)

Example:

# Read active users
read_table_rows(
    table_name="users",
    columns=["id", "name", "email"],
    filters={"is_active": True},
    limit=10,
    offset=0
)

Create Table Records

create_table_records(
    table_name: str,
    records: Union[Dict[str, Any], List[Dict[str, Any]]]
)

Example:

# Create a new user
create_table_records(
    table_name="users",
    records={
        "name": "John Doe",
        "email": "john@example.com",
        "is_active": True
    }
)

Update Table Records

update_table_records(
    table_name: str,
    updates: Dict[str, Any],
    filters: Dict[str, Any]
)

Example:

# Update user status
update_table_records(
    table_name="users",
    updates={"status": "premium"},
    filters={"is_active": True}
)

Delete Table Records

delete_table_records(
    table_name: str,
    filters: Dict[str, Any]
)

Example:

# Delete inactive users
delete_table_records(
    table_name="users",
    filters={"is_active": False}
)

Development

Project Structure

supabase-mcp/
├── supabase_mcp/
│   ├── __init__.py
│   ├── server.py              # Main MCP server implementation
│   └── tests/                 # Unit tests
├── Dockerfile                 # Docker configuration for MCP server
├── example_mcp_config.json    # Example MCP configuration
├── requirements.txt           # Python dependencies
├── .env.example               # Example environment variables
├── README.md                  # Project documentation
├── PLANNING.md                # Project planning
└── TASKS.md                   # Task tracking

Running Tests

pytest supabase_mcp/tests/

Model Context Protocol Integration

The Supabase MCP server implements the Model Context Protocol, which allows AI assistants to interact with Supabase databases in a standardized way.

How It Works

  1. The MCP server exposes tools for database operations (read, create, update, delete)
  2. AI assistants connect to the MCP server using the stdio transport
  3. The AI assistant can invoke the tools to perform database operations
  4. The MCP server handles the communication with Supabase and returns the results

MCP Configuration

The example_mcp_config.json file shows how to configure an AI assistant to use the Supabase MCP server:

{
  "mcpServers": {
    "supabase": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "-e", "SUPABASE_URL", "-e", "SUPABASE_SERVICE_KEY", "mcp/supabase"],
      "env": {
        "SUPABASE_URL": "YOUR-SUPABASE-URL",
        "SUPABASE_SERVICE_KEY": "YOUR-SUPABASE-SERVICE-ROLE-KEY"
      }
    }
  }
}

This configuration tells the AI assistant:

  • To use Docker to run the MCP server
  • To pass the Supabase credentials as environment variables
  • To use the mcp/supabase Docker image

Using with AI Assistants

AI assistants that support the Model Context Protocol can use this server to:

  1. Query data from Supabase tables
  2. Insert new records into tables
  3. Update existing records
  4. Delete records

The assistant will have access to the tools documented in the "Available Tools" section above.

Environment Variables

Variable Description
SUPABASE_URL URL of your Supabase project
SUPABASE_SERVICE_KEY Service role key for Supabase authentication

License

This project is licensed under the MIT License - see the LICENSE file for details.

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • 田中 楓太
  • A virtual science instructor for engaging and informative lessons.

  • 林乔安妮
  • A fashion stylist GPT offering outfit suggestions for various scenarios.

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • appcypher
  • 很棒的MCP服务器 - 模型上下文协议服务器的策划列表

  • chongdashu
  • 使用模型上下文协议(MCP),启用Cursor,Windsurf和Claude Desktop等AI助手客户,以通过自然语言控制虚幻引擎。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • GeyserMC
  • 与Minecraft客户端/服务器通信的库。

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

    Reviews

    5 (1)
    Avatar
    user_aCkzkJAx
    2025-04-17

    Supabase-MCP by coleam00 is a phenomenal tool for managing your Supabase projects efficiently. The seamless integration and straightforward interface make it a must-have for anyone serious about their development workflow. Check it out on GitHub and elevate your project management to the next level!