Supabase MCP — Postgres + Auth Server for AI Agents
MCP server for Supabase that gives AI agents access to PostgreSQL databases, authentication, storage, and edge functions. Query data, manage users, and build full-stack features. 4,000+ stars.
What it is
Supabase MCP is a Model Context Protocol server that connects AI agents to Supabase services. It provides access to PostgreSQL databases, authentication, file storage, and edge functions through the MCP tool interface.
Supabase MCP targets AI developers building agents that need to query databases, manage users, or interact with Supabase-hosted applications -- all through natural language commands in their AI client.
How it saves time or tokens
Instead of writing SQL queries manually or building API integrations, developers can ask their AI agent to query data, create users, or manage storage directly. The MCP server handles the Supabase API calls and returns structured results. Token estimate is approximately 2400 tokens per session.
How to use
- Add Supabase MCP to your
.mcp.json:
{
"mcpServers": {
"supabase": {
"command": "npx",
"args": ["-y", "@supabase/mcp-server"],
"env": {
"SUPABASE_URL": "https://your-project.supabase.co",
"SUPABASE_SERVICE_KEY": "eyJ..."
}
}
}
}
- Get your keys from Supabase Dashboard > Settings > API.
- Restart your AI client and start querying your database.
Example
-- Example queries the agent can execute via Supabase MCP:
-- 'Show me all users who signed up this week'
SELECT id, email, created_at
FROM auth.users
WHERE created_at >= NOW() - INTERVAL '7 days'
ORDER BY created_at DESC;
-- 'Count active projects by status'
SELECT status, COUNT(*) as total
FROM projects
WHERE deleted_at IS NULL
GROUP BY status;
Related on TokRepo
- MCP Supabase Integration -- Supabase MCP deep dive
- Database Tools -- Database management and query tools
Common pitfalls
- The SUPABASE_SERVICE_KEY has admin-level access. Never expose it in client-side code or public repositories.
- MCP tool calls execute real queries against your database. Use a development project for testing before connecting production.
- Row-level security (RLS) policies are bypassed when using the service key. Ensure your agent queries do not expose sensitive data.
Frequently Asked Questions
The Supabase MCP server provides access to PostgreSQL queries (select, insert, update, delete), authentication user management, file storage operations, and edge function invocation.
Yes. The @supabase/mcp-server package is published by Supabase and maintained as part of their official tooling for AI agent integrations.
Yes. The agent can execute arbitrary SQL queries against your Supabase PostgreSQL database. This includes SELECT, INSERT, UPDATE, DELETE, and DDL operations depending on the service key permissions.
The MCP protocol is request-response based. Real-time subscriptions (Supabase Realtime) are not supported through MCP. Use the Supabase client SDK directly for real-time features.
Use environment variables for the service key, never commit it to version control. Consider using a read-only database role for the service key if write access is not needed.
Citations (3)
- Supabase MCP GitHub— Supabase MCP server for AI agent database access
- Supabase Documentation— Supabase platform documentation
- MCP Specification— Model Context Protocol specification