MCP server overview
What is the project about? Mcp Server Postgrest is an MCP (Model Context Protocol) server adapter for PostgREST that lets LLMs and MCP-capable clients perform CRUD operations against a PostgREST API (including Supabase projects). It exposes tools to execute HTTP requests to PostgREST and to convert SQL to equivalent PostgREST method/path syntax.
How to use the project?
- Install the package via npm/yarn/pnpm (e.g. npm i @supabase/mcp-server-postgrest).
- Run it as an MCP server from a client like Claude Desktop by adding a config entry that runs the package with --apiUrl, --apiKey, and --schema options.
- Or embed it programmatically by creating the PostgREST MCP server (createPostgrestMcpServer) and connecting it to your MCP client via transports (stdio, SSE, StreamTransport, etc.).
- Example flow: start server with your PostgREST URL (e.g. https://your-project-ref.supabase.co/rest/v1), authenticate with API key or JWT, then call tools like postgrestRequest from your MCP client.
Key features
- ‘postgrestRequest’ tool: perform GET/POST/PATCH/DELETE requests to PostgREST and return JSON responses (selected rows, updated rows).
- ‘sqlToRest’ tool: convert supported SQL queries into PostgREST method + path to help LLMs form valid REST calls.
- Works with Supabase and any compatible PostgREST server.
- Integrates with MCP clients (Claude Desktop, custom clients using MCP SDK) and supports multiple transports (stdio, SSE, StreamTransport).
- Simple CLI/config options: apiUrl, apiKey (optional), schema.
Use cases
- Let AI assistants query and update your database via natural language (e.g., add todos, fetch records).
- Integrate PostgREST-backed data into LLM workflows and automation pipelines.
- Build custom MCP clients that need direct, programmatic access to PostgREST.
- Rapid prototyping/testing of LLM-driven DB operations against local or hosted Supabase instances.
FAQ
- Does it work with Supabase?
Yes. It targets PostgREST and is compatible with Supabase projects or any standalone PostgREST server.
- How is authentication handled?
Provide an apiKey (anon, service role, or user JWT) when starting the server; you can also use session JWTs depending on your PostgREST setup.
- Will all SQL convert via sqlToRest?
No. sqlToRest supports PostgREST-compatible SQL patterns only; complex SQL may not convert and may require manual translation.
- Is it secure to expose keys?
Treat API keys/JWTs as secrets. Limit schema exposure on PostgREST and use least-privilege keys for MCP servers.
- Can I use it locally?
Yes. You can point apiUrl at a local Supabase (e.g. http://127.0.0.1:54321/rest/v1) for development and testing.