Skip to main content
Glama
Apache 2.0
356
1,505
  • Apple

@supabase/mcp-server-postgrest

这是PostgREST的 MCP 服务器。它允许 LLM 通过 REST API 在你的应用上执行 CRUD 操作。

该服务器可与 Supabase 项目(运行 PostgREST)和任何独立的 PostgREST 服务器配合使用。

工具

可以使用以下工具:

postgrestRequest

已配置的PostgREST 服务器执行 HTTP 请求。它接受以下参数:

  • method :要使用的 HTTP 方法(例如GETPOSTPATCHDELETE
  • path :查询的路径(例如/todos?id=eq.1
  • body :请求主体(用于POSTPATCH请求)

它返回来自 PostgREST 服务器的 JSON 响应,包括GET请求的选定行以及POSTPATCH请求的更新行。

sqlToRest

将 SQL 查询转换为等效的 PostgREST 语法(作为方法和路径)。这对于 LLM 难以转换为有效 PostgREST 语法的复杂查询非常有用。

请注意,PostgREST 仅支持 SQL 的子集,因此并非所有查询都会转换。有关更多详细信息,请参阅sql-to-rest

它接受以下参数:

  • sql :要转换的 SQL 查询。

它返回一个包含请求的methodpath属性的对象。然后,LLM 可以使用postgrestRequest工具来执行该请求。

用法

使用 Claude Desktop

Claude Desktop是一款流行的 LLM 客户端,支持模型上下文协议 (MCP)。您可以将 PostgREST 服务器连接到 Claude Desktop,以便通过自然语言命令查询数据库。

您可以通过以下配置文件将 MCP 服务器添加到 Claude Desktop:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

要将您的 Supabase 项目*(或任何 PostgREST 服务器)*添加到 Claude Desktop,请将以下配置添加到配置文件中的mcpServers对象:

{ "mcpServers": { "todos": { "command": "npx", "args": [ "-y", "@supabase/mcp-server-postgrest@latest", "--apiUrl", "https://your-project-ref.supabase.co/rest/v1", "--apiKey", "your-anon-key", "--schema", "public" ] } } }
配置
  • apiUrl :PostgREST 端点的基本 URL
  • apiKey :用于身份验证的 API 密钥*(可选)*
  • schema :用于提供 API 的 Postgres 模式(例如public )。请注意,任何非公共模式都必须从 PostgREST 手动公开。

以编程方式(自定义 MCP 客户端)

如果您正在构建自己的 MCP 客户端,可以使用您首选的传输方式以编程方式连接到 PostgREST 服务器。MCP SDK提供内置的stdioSSE传输方式。如果您希望直接连接到内存中的 MCP 服务器,或者通过您自己的基于流的传输方式进行管道传输,我们还提供StreamTransport接口。

安装
npm i @supabase/mcp-server-postgrest
yarn add @supabase/mcp-server-postgrest
pnpm add @supabase/mcp-server-postgrest
例子

以下示例使用StreamTransport直接连接 MCP 客户端和服务器。

import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StreamTransport } from '@supabase/mcp-utils'; import { createPostgrestMcpServer } from '@supabase/mcp-server-postgrest'; // Create a stream transport for both client and server const clientTransport = new StreamTransport(); const serverTransport = new StreamTransport(); // Connect the streams together clientTransport.readable.pipeTo(serverTransport.writable); serverTransport.readable.pipeTo(clientTransport.writable); const client = new Client( { name: 'MyClient', version: '0.1.0', }, { capabilities: {}, } ); const supabaseUrl = 'https://your-project-ref.supabase.co'; // http://127.0.0.1:54321 for local const apiKey = 'your-anon-key'; // or service role, or user JWT const schema = 'public'; // or any other exposed schema const server = createPostgrestMcpServer({ apiUrl: `${supabaseUrl}/rest/v1`, apiKey, schema, }); // Connect the client and server to their respective transports await server.connect(serverTransport); await client.connect(clientTransport); // Call tools, etc const output = await client.callTool({ name: 'postgrestRequest', arguments: { method: 'GET', path: '/todos', }, });
-
security - not tested
A
license - permissive license
-
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.

这是 PostgREST 的 MCP 服务器。它允许 LLM 通过 PostgREST 对 Postgres 数据库执行数据库查询和操作。该服务器既可以与使用 PostgREST 的 Supabase 项目配合使用,也可以与独立的 PostgREST 服务器配合使用。

  1. 工具
    1. postgrestRequest
    2. sqlToRest
  2. 用法
    1. 使用 Claude Desktop
    2. 以编程方式(自定义 MCP 客户端)

Related MCP Servers

  • A
    security
    A
    license
    A
    quality
    This server enables interaction with Supabase PostgreSQL databases through the MCP protocol, allowing seamless integration with Cursor and Windsurf IDEs for secure and validated database management.
    Last updated -
    11
    699
    Python
    Apache 2.0
    • Apple
    • Linux
  • -
    security
    A
    license
    -
    quality
    An MCP server that connects to Supabase PostgreSQL databases, exposing table schemas as resources and providing tools for data analysis through SQL queries.
    Last updated -
    JavaScript
    MIT License
  • -
    security
    A
    license
    -
    quality
    An MCP server that enables natural language querying of Supabase PostgreSQL databases using Claude 3.7, allowing users to inspect schemas, execute SQL, manage migrations, and convert natural language to SQL queries.
    Last updated -
    Python
    MIT License
    • Linux
    • Apple
  • -
    security
    F
    license
    -
    quality
    PG-MCP is an HTTP server implementation that enables AI systems to interact with PostgreSQL databases via MCP, providing tools for querying, connecting to multiple databases, and exploring schema resources. The system enriches context by extracting table/column description from database catalogs.
    Last updated -
    8
    • Linux
    • Apple

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

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