postgrest (supabase).com
postgrest (supabase).com logo

PostgREST (Supabase)

Connects to Supabase projects using PostgREST, or standalone PostgREST servers, enabling natural language querying and m...

Created byApr 22, 2025

@supabase/mcp-server-postgrest

This is an MCP server for PostgREST. It allows LLMs to perform CRUD operations on your app via REST API.
This server works with Supabase projects (which run PostgREST) and any standalone PostgREST server.

Tools

The following tools are available:

`postgrestRequest`

Performs an HTTP request to a configured PostgREST server. It accepts the following arguments:
  • method: The HTTP method to use (eg. GET, POST, PATCH, DELETE)
  • path: The path to query (eg. /todos?id=eq.1)
  • body: The request body (for POST and PATCH requests)
It returns the JSON response from the PostgREST server, including selected rows for GET requests and updated rows for POST and PATCH requests.

`sqlToRest`

Converts a SQL query to the equivalent PostgREST syntax (as method and path). Useful for complex queries that LLMs would otherwise struggle to convert to valid PostgREST syntax.
Note that PostgREST only supports a subset of SQL, so not all queries will convert. See `sql-to-rest` for more details.
It accepts the following arguments:
  • sql: The SQL query to convert.
It returns an object containing method and path properties for the request. LLMs can then use the postgrestRequest tool to execute the request.

Usage

With Claude Desktop

Claude Desktop is a popular LLM client that supports the Model Context Protocol. You can connect your PostgREST server to Claude Desktop to query your database via natural language commands.
You can add MCP servers to Claude Desktop via its config file at:
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows:%APPDATA%\Claude\claude_desktop_config.json
To add your Supabase project (or any PostgREST server) to Claude Desktop, add the following configuration to the mcpServers object in the config file:

Configuration

  • apiUrl: The base URL of your PostgREST endpoint
  • apiKey: Your API key for authentication (optional)
  • schema: The Postgres schema to serve the API from (eg. public). Note any non-public schemas must be manually exposed from PostgREST.

Programmatically (custom MCP client)

If you're building your own MCP client, you can connect to a PostgREST server programmatically using your preferred transport. The MCP SDK offers built-in stdio and SSE transports. We also offer a `StreamTransport` if you wish to directly connect to MCP servers in-memory or by piping over your own stream-based transport.

Installation

Example

The following example uses the `StreamTransport` to connect directly between an MCP client and server.

@supabase/mcp-server-postgrest

This is an MCP server for PostgREST. It allows LLMs to perform CRUD operations on your app via REST API.
This server works with Supabase projects (which run PostgREST) and any standalone PostgREST server.

Tools

The following tools are available:

`postgrestRequest`

Performs an HTTP request to a configured PostgREST server. It accepts the following arguments:
  • method: The HTTP method to use (eg. GET, POST, PATCH, DELETE)
  • path: The path to query (eg. /todos?id=eq.1)
  • body: The request body (for POST and PATCH requests)
It returns the JSON response from the PostgREST server, including selected rows for GET requests and updated rows for POST and PATCH requests.

`sqlToRest`

Converts a SQL query to the equivalent PostgREST syntax (as method and path). Useful for complex queries that LLMs would otherwise struggle to convert to valid PostgREST syntax.
Note that PostgREST only supports a subset of SQL, so not all queries will convert. See `sql-to-rest` for more details.
It accepts the following arguments:
  • sql: The SQL query to convert.
It returns an object containing method and path properties for the request. LLMs can then use the postgrestRequest tool to execute the request.

Usage

With Claude Desktop

Claude Desktop is a popular LLM client that supports the Model Context Protocol. You can connect your PostgREST server to Claude Desktop to query your database via natural language commands.
You can add MCP servers to Claude Desktop via its config file at:
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows:%APPDATA%\Claude\claude_desktop_config.json
To add your Supabase project (or any PostgREST server) to Claude Desktop, add the following configuration to the mcpServers object in the config file:

Configuration

  • apiUrl: The base URL of your PostgREST endpoint
  • apiKey: Your API key for authentication (optional)
  • schema: The Postgres schema to serve the API from (eg. public). Note any non-public schemas must be manually exposed from PostgREST.

Programmatically (custom MCP client)

If you're building your own MCP client, you can connect to a PostgREST server programmatically using your preferred transport. The MCP SDK offers built-in stdio and SSE transports. We also offer a `StreamTransport` if you wish to directly connect to MCP servers in-memory or by piping over your own stream-based transport.

Installation

Example

The following example uses the `StreamTransport` to connect directly between an MCP client and server.