Most of the questions people ask an AI about their business have the answer sitting in a MySQL database: how many orders came in last week, which customers went quiet, what a support ticket was about. Getting that data in front of Claude, ChatGPT or Cursor used to mean exporting CSVs or writing an API. With GetMCP’s Database connector, you enter the connection details once and the database becomes an MCP server your AI client can query directly — read-only until you decide otherwise.
This guide walks through it with MySQL (MariaDB works identically). Nothing here requires code.
What you need
- GetMCP — the WordPress plugin or the standalone app; the connector is the same on both.
- The connection details — host, port (3306 unless you changed it), database name, username and password. A managed database shows these on its dashboard; for a database on your own server, your administrator has them.
- Network access from the server running GetMCP to the database. A managed database usually keeps an allow-list of IP addresses; add your GetMCP server’s IP.
Your PHP needs the pdo_mysql extension, which practically every host ships. If yours doesn’t, the connection test says so in plain words.
Step 1 — Create a read-only database user
Don’t hand an AI your administrator account. Give GetMCP its own user with exactly the access an AI should have — for most uses, reading. Run this in your database (adjust the database name and the password):
CREATE USER 'getmcp_reader'@'%' IDENTIFIED BY 'a-strong-password';GRANT SELECT, SHOW VIEW ON shop.* TO 'getmcp_reader'@'%';
The '%' means the user may connect from any host. If you know your GetMCP server’s address, use it instead — MySQL users are tied to a host pattern, and a user created for localhost cannot log in from anywhere else, which is the single most common reason a first connection test fails.
Step 2 — Install the Database template
In GetMCP go to Templates, find Database (MySQL / PostgreSQL) and click Install. Give the server a name your AI client will recognise — “Shop Database” beats “Server 3”. GetMCP creates the server with nine database tools. At this point the tools exist but nothing is connected yet.
Step 3 — Enter the connection details
Open the new server, go to the Settings tab and find the Database section.
- Engine: MySQL / MariaDB. The port fills in with 3306.
- Host, Database name, Username, Password: the details from your provider and the user you just created.
- Encryption: leave it on TLS (don’t verify certificate). Choose TLS, verify certificate if you want the certificate checked too, or None only for a database on a private network you trust.
- Leave Read-only connection ticked.
- Click Test connection. Testing saves what you typed first, then connects.
A successful test tells you the server version and what it found — “Connected to MySQL 8.4.0. Found 29 tables and views in shop.” — followed by the table names. If it fails, the message names the problem: a rejected password, a host it couldn’t reach, a database that doesn’t exist for that user, a TLS handshake the server refused.
The password is encrypted with your installation’s own key and stored in your own database. Query results move directly between your server and MySQL; nothing passes through getmcp.com.
Step 4 — Connect your AI client
Set the server to Active. At the top of the server page, Connect to Claude opens claude.ai with the connector already filled in, and Connect to Cursor installs it straight into Cursor; How to connect has the snippet for ChatGPT, Claude Code, Windsurf and VS Code. Then ask:
- “What tables are in this database?”
- “Describe the orders table.”
- “How many orders were placed last month, and what was the total?”
- “Show me the ten most recent customers from Germany.”
- “Which products haven’t sold in 90 days?”
A good AI client calls list_tables and describe_table first, so it writes queries against your real column names instead of guessing them. Every call shows up on the server’s Logs tab with the exact SQL and arguments the AI sent.
What the nine tools do
Five read, and they’re on from the start: list_tables, describe_table, run_query (a SELECT with bound parameters), get_rows (filtered, sorted, paged rows with no SQL at all) and count_rows. Four change data — insert_row, update_rows, delete_rows and execute_sql — and they install switched off.
Turning a write tool on is only one of two locks. The connection itself is opened read-only at the MySQL session level while that box is ticked, so even an enabled write tool is refused by the database, not by a pattern match on the SQL. To let an AI change data you enable the tool and untick Read-only connection — and grant the user INSERT, UPDATE or DELETE on the tables that need it, not on everything. update_rows and delete_rows refuse to run without a filter, so an accidental “update every row” can’t happen.
Keeping answers manageable
Every connection has a row cap — 200 by default, up to 1,000 — and no tool returns more than that in one call; the response says when it stopped short so the AI can narrow the query or page on. Long text cells are trimmed and binary columns summarised, and a query timeout (30 seconds by default) cancels anything that runs too long. One wide table can’t flood your conversation.
Troubleshooting the first connection
- “The database rejected the username or password” — check both, and check the host pattern the user was created with.
- “Could not reach the host” or a timeout — wrong host or port, or the database’s firewall doesn’t allow your GetMCP server’s IP.
- “Connected to the server, but the database was not found” — the database name is wrong, or the user has no grant on it.
- “The TLS handshake with the database failed” — the server doesn’t offer TLS on that port; try None for a private-network database.
- A table isn’t found by name — names are case-sensitive on MySQL running on Linux. Use the exact names
list_tablesreturns.
The full reference — including PostgreSQL, the schema field and the notice that adds new tools to servers you built earlier — is in Connect a database. And if the database is one of several things you want your AI to reach, the MCP Gateway publishes this server alongside every other one at a single URL.
Related posts
Let AI Draft and Edit Your WordPress Posts — Without Giving It the Publish Button
GetMCP's WordPress template gives Claude, ChatGPT or Cursor 17 tools to read, draft, revise and tag your content…
One MCP Endpoint per Client: How Agencies Use GetMCP to Connect Every App a Client Runs
Build a client's CRM, store, mailbox and database into MCP servers, put them behind the MCP Gateway, and…
Connect PostgreSQL or Supabase to Your AI as an MCP Server
A Supabase project is a PostgreSQL database, and GetMCP's Database connector talks to it directly. Which connection string…