How to turn a Postgres, MySQL or SQL Server database into an MCP server
Updated
Paste your database's connection string into Kaiva Bridge. It reads the schema and creates read-only tools that your AI can use to look up and query data, then hosts them as an MCP server. PostgreSQL, MySQL, MariaDB and SQL Server are supported, and every query runs in a read-only transaction, so a tool call cannot change your data.
Step by step
- Create a read-only login (recommended)In your database, create a login that can only read the tables your AI should see. The console shows the SQL for it.
- Paste the connection stringChoose New server, then Database, pick PostgreSQL, MySQL, MariaDB or SQL Server and paste the connection string, or fill in host, port, database, user and password.
- Choose the toolsBridge reads the schema and proposes tools for the tables it can see. Switch on the ones your AI needs.
- Publish and connectClick Deploy server, copy the address from the Connect tab and add it to Claude, ChatGPT, Cursor or another MCP client.
From a terminal, with the connection string read from an environment variable so it never lands in your shell history:
npx @kaiva/bridge login
printf %s "$DATABASE_URL" | npx @kaiva/bridge push shop-db --postgres --secret-stdin
npx @kaiva/bridge install shop-db --client cursorConnect Postgres to Claude
Create a login that can only read (the SQL below, with your database's name), then in Bridge choose New server, Database, PostgreSQL, paste the connection string for that login and click Deploy server. In Claude open Settings, Connectors, Add custom connector, paste the server's address from its Connect tab and sign in with your Kaiva Bridge account. Claude can then look up rows and summarise tables; it cannot change data.
CREATE ROLE bridge_ro LOGIN PASSWORD 'choose-a-password';
GRANT CONNECT ON DATABASE shop TO bridge_ro;
GRANT USAGE ON SCHEMA public TO bridge_ro;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO bridge_ro;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO bridge_ro;Connect MySQL to ChatGPT
Create a user that can only read, then in Bridge choose New server, Database, MySQL (MariaDB works the same way), paste the connection string and click Deploy server. In ChatGPT open Plugins, click +, then Add custom MCP server (turn on Developer mode in Settings, Security if it is not there), paste the server's address as the MCP server URL, choose OAuth and sign in with your Kaiva Bridge account.
CREATE USER 'bridge_ro'@'%' IDENTIFIED BY 'choose-a-password';
GRANT SELECT ON shop.* TO 'bridge_ro'@'%';What you need
A PostgreSQL, MySQL, MariaDB or SQL Server database that Bridge can reach over the internet, and its connection string. The database must be reachable from a public address; private networks are an Enterprise option.
If your database uses a self-signed certificate, add the provider's CA certificate when you create the server.
Free includes 10 MCP servers, 200,000 tool calls a month and 200 pages of documents, with no card.
Other ways to do it
- Kaiva Postgres MCP, on your machineFor Postgres used only from Claude Code, Cursor or Claude Desktop on your own machine: a free, open-source, read-only MCP server, no account. It replaces the archived @modelcontextprotocol/server-postgres.
- Self-host an open-source database MCP serverOpen-source MCP servers exist for PostgreSQL and MySQL. You run them, keep them updated and decide how they reach your database.
- Give the AI a SQL consoleSome tools let an AI write any SQL. That is flexible, but it gives the AI as much access as the login it uses.
Questions
- Can the AI change or delete my data?
- No. Database tools only read, and their queries run in read-only transactions. Using a read-only login as well is recommended.
- Which databases are supported?
- PostgreSQL, MySQL, MariaDB and SQL Server (including Azure SQL).
- Is my database password safe?
- It is encrypted at rest with AES-256-GCM, used only while a request runs, and never returned by the API or shown in the console.
- Does my database need to be public?
- It needs an address Bridge can reach. Private networks are available on Enterprise.
- Is it free?
- Free includes 10 MCP servers, 200,000 tool calls a month and 200 pages of documents, with no card.