How to turn a Postgres or MySQL 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 and MariaDB 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 or MySQL (MySQL also covers MariaDB) 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 cursorWhat you need
A PostgreSQL, MySQL or MariaDB 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 3 MCP servers, 200,000 tool calls a month and 200 pages of documents, with no card.
Other ways to do it
- 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 and MariaDB.
- 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 3 MCP servers, 200,000 tool calls a month and 200 pages of documents, with no card.