Forge
Provides tools for working with Supabase, including listing tables, policies, and functions, explaining SQL query plans, proposing RLS policies, and running read-only SQL queries as the authenticated user with RLS enforced.
This server has a remotely hosted endpoint. Open its connector listing for connection details, authentication requirements, and setup instructions:
Forge
MCP server + debugging assistant running on Supabase Edge Functions.
Forge inspects database schemas, explains SQL query plans, drafts RLS policies, and executes read-only queries scoped to the signed-in user's JWT. No service_role key is ever exposed to the client.
Hosted setup guide: HOSTED.md
Repository: https://github.com/mcontrerasmalpar-pixel/Forge
What It Demonstrates
MCP Server on Supabase Edge Functions (Deno, JSON-RPC 2.0)
Allowlisted MCP Tools with multi-layer read-only SQL guardrails (blocks destructive DDL/DML)
PostgreSQL RLS as the Authorization Layer (
security invokerRPCs, zero frontend permission hacks)Multi-Tenant RLS Isolation Demo: visible tenant
acme-alphavs isolated tenantbeta-shadowNext.js Assistant UI with live JWT session, one-click Seed RLS Demo, and expandable MCP tool trace
Optional LLM Orchestrator (
AzureOpenAISDK) with a built-in zero-key MCP router fallback so the demo works out of the box
Related MCP server: mcp-server-postgres
Architecture
Cursor / Web Assistant UI
| MCP JSON-RPC 2.0 (Bearer User JWT)
v
Edge Function: mcp-server
| Postgres RPCs + Row Level Security (auth.uid())
v
PostgreSQLThe chat Edge Function orchestrates tool calls via AzureOpenAI when configured, or falls back to a deterministic MCP tool router so every tool (list_tables, list_policies, list_functions, explain_query, propose_rls, run_readonly_sql) can be tested live without paid LLM quota.
Try It in 30 Seconds (Zero Setup — Connects to Hosted Demo Backend)
The web assistant is pre-wired to a live hosted Supabase project protected by PostgreSQL RLS (https://skxljgnpjmnekvecpfjd.supabase.co), with a ready-to-use demo account pre-filled in the UI:
git clone https://github.com/mcontrerasmalpar-pixel/Forge.git
cd Forge/apps/web
npm install
npm run devClick Sign in (pre-filled with
demo@forge.dev/ForgeDemo123!) → status updates toJWT: yes · demo@forge.dev.Click Seed RLS Demo → seeds two tenants (
your_org: "acme-alpha"andhidden_org: "beta-shadow").Click any quick-prompt chip (e.g. How many documents can I see and what are their titles? or DROP TABLE documents) and expand View MCP tool trace to inspect the raw JSON-RPC 2.0 tool call and response.
Run the automated router + SQL guardrail test suite from the repo root:
npm run evalsKey Files for Code Review
supabase/functions/mcp-server/index.ts— Edge Function MCP server (initialize,tools/list,tools/call, SQL read-only validator, rate limiter).supabase/migrations/20260907000000_init.sql— Multi-tenant schema (organizations,memberships,documents,usage_events) and RLS policies usingmy_org_ids().supabase/migrations/20260907000001_forge_rpcs.sql— Catalog inspection RPCs (security definer, restricted toservice_role) and query execution RPCs (security invoker,default_transaction_read_only = on,statement_timeout = '3s').supabase/migrations/20260907000002_bootstrap_demo.sql— Idempotent two-tenant RLS fixture (acme-alphavsbeta-shadow).supabase/functions/chat/index.ts— OptionalAzureOpenAItool-calling loop with a built-in zero-key MCP router fallback.evals/run.mjs— 12 automated checks covering tool routing and SQL injection/DDL guardrails.server.json— Official MCP Registry manifest (streamable-httpremote specification).
Deploy to Your Own Supabase Project
Create a Supabase project and link this repository (or run
npx supabase db push+npx supabase functions deploy).Create
apps/web/.env.local:
NEXT_PUBLIC_SUPABASE_URL=https://YOUR_REF.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ... # anon or publishable keyRun the web assistant:
cd apps/web
npm install
npm run devIn Supabase Dashboard → Authentication → Providers → Email, disable Confirm email for quick demo testing.
Sign up / Sign in → status shows
JWT: yes.Click Seed RLS Demo → returns JSON confirming
your_org: "acme-alpha"andhidden_org: "beta-shadow".Click any quick-prompt chip (or ask a question) and expand View MCP tool trace to inspect the raw JSON-RPC payload.
Connect from Cursor (Direct MCP)
Copy .cursor/mcp.json.example to .cursor/mcp.json and point it to your deployed mcp-server function:
{
"mcpServers": {
"forge": {
"url": "https://YOUR_REF.supabase.co/functions/v1/mcp-server",
"headers": {
"Authorization": "Bearer USER_JWT",
"apikey": "SUPABASE_ANON_KEY"
}
}
}
}USER_JWT is the access_token of a signed-in user session. Every MCP tool call inherits PostgreSQL RLS permissions from that JWT.
Allowlisted MCP Tools
Tool | Guardrail |
| Catalog metadata only ( |
| Read-only |
| Read-only |
|
|
| Returns a reviewable SQL migration draft ( |
| Single |
Optional Azure OpenAI Configuration
If you want chat to use Azure OpenAI instead of the built-in MCP router:
npx supabase secrets set AZURE_OPENAI_ENDPOINT=https://YOUR_RESOURCE.openai.azure.com
npx supabase secrets set AZURE_OPENAI_API_KEY=...
npx supabase secrets set AZURE_OPENAI_DEPLOYMENT=gpt-4o-mini
npx supabase functions deploy chat --project-ref YOUR_REFSecurity Model & Evals
Client only uses the public
anon/publishablekey + user session JWT.run_readonly_sqlandexplain_querystrip comments, reject multi-statement queries, block write/DDL/session keywords (INSERT,UPDATE,DELETE,DROP,ALTER,ANALYZE,SET,LOCK, etc.), enforceSET LOCAL default_transaction_read_only = on, and cap execution at3s.propose_rlsdrafts policies without executing DDL.Per-user rate limiting (
40 tools/min) tracked byauth.uid().
Run the router + SQL guardrail evaluation suite:
npm run evalsLicense
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Check project health and advisors, run read-only SQL, manage Edge Function secrets in Supabase.
1Your Supabase account in natural language: run SQL, apply migrations, manage tables, storage, edge f
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Supabase RLS simulator, app key-leak check, email sender check, DMARC and payment-fraud checks.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables read-only exploration of a Postgres database using natural language, with multiple safety layers to prevent any modifications.5-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to query PostgreSQL, inspect schemas, and explain queries, designed for local and development databases with read-only safety by default.49 npmMIT
- AlicenseAqualityBmaintenanceEnables AI assistants to discover allowed PostgreSQL schemas, run parameterized SELECT queries, and inspect query plans safely through parser-checked read-only transactions, timeouts, row caps, and role-based access controls.4MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to explore PostgreSQL schemas and run safe, read-only queries in plain English. It applies SQL validation, row limits, and read-only sessions to prevent writes and unsafe operations.6MIT