MySQL MCP Server
Connects an MCP client to a MySQL database to browse schemas, sample tables and run SQL
Inspect, search and query Microsoft SQL Server and Azure SQL databases from an MCP client
By Hendrick Castro (individual) TypeScript Local · stdio Databases
37 popularity score ★ 15 ↓ 645/wk
Opens the app, which asks before it adds the server. Then replace each <NAME> in its settings with your value.
It needs DB_SERVER, DB_NAME, DB_USER, DB_PASSWORD. Replace each <NAME> with your value.
claude mcp add mcpql -e DB_SERVER=<DB_SERVER> -e DB_NAME=<DB_NAME> -e DB_USER=<DB_USER> -e DB_PASSWORD=<DB_PASSWORD> -- npx -y mcpql{
"mcpServers": {
"mcpql": {
"command": "npx",
"args": [
"-y",
"mcpql"
],
"env": {
"DB_SERVER": "<DB_SERVER>",
"DB_NAME": "<DB_NAME>",
"DB_USER": "<DB_USER>",
"DB_PASSWORD": "<DB_PASSWORD>"
}
}
}
}{
"mcpServers": {
"mcpql": {
"command": "npx",
"args": [
"-y",
"mcpql"
],
"env": {
"DB_SERVER": "<DB_SERVER>",
"DB_NAME": "<DB_NAME>",
"DB_USER": "<DB_USER>",
"DB_PASSWORD": "<DB_PASSWORD>"
}
}
}
}{
"servers": {
"mcpql": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcpql"
],
"env": {
"DB_SERVER": "<DB_SERVER>",
"DB_NAME": "<DB_NAME>",
"DB_USER": "<DB_USER>",
"DB_PASSWORD": "<DB_PASSWORD>"
}
}
}
}[mcp_servers.mcpql]
command = "npx"
args = ["-y", "mcpql"]
[mcp_servers.mcpql.env]
DB_SERVER = "<DB_SERVER>"
DB_NAME = "<DB_NAME>"
DB_USER = "<DB_USER>"
DB_PASSWORD = "<DB_PASSWORD>"gemini mcp add --scope user -e DB_SERVER=<DB_SERVER> -e DB_NAME=<DB_NAME> -e DB_USER=<DB_USER> -e DB_PASSWORD=<DB_PASSWORD> mcpql npx -- -y mcpqlOpens the app, which asks before it adds the server. Then replace each <NAME> in its settings with your value.
It needs DB_SERVER, DB_NAME, DB_USER, DB_PASSWORD. Replace each <NAME> with your value.
git clone https://github.com/hendrickcastro/MCPQL.git
cd MCPQL
npm install
npm run buildclaude mcp add mcpql -e DB_SERVER=<DB_SERVER> -e DB_NAME=<DB_NAME> -e DB_USER=<DB_USER> -e DB_PASSWORD=<DB_PASSWORD> -- node '<ABSOLUTE_PATH_TO_CLONE>/dist/server.js'{
"mcpServers": {
"mcpql": {
"command": "node",
"args": [
"<ABSOLUTE_PATH_TO_CLONE>/dist/server.js"
],
"env": {
"DB_SERVER": "<DB_SERVER>",
"DB_NAME": "<DB_NAME>",
"DB_USER": "<DB_USER>",
"DB_PASSWORD": "<DB_PASSWORD>"
}
}
}
}{
"mcpServers": {
"mcpql": {
"command": "node",
"args": [
"<ABSOLUTE_PATH_TO_CLONE>/dist/server.js"
],
"env": {
"DB_SERVER": "<DB_SERVER>",
"DB_NAME": "<DB_NAME>",
"DB_USER": "<DB_USER>",
"DB_PASSWORD": "<DB_PASSWORD>"
}
}
}
}{
"servers": {
"mcpql": {
"type": "stdio",
"command": "node",
"args": [
"<ABSOLUTE_PATH_TO_CLONE>/dist/server.js"
],
"env": {
"DB_SERVER": "<DB_SERVER>",
"DB_NAME": "<DB_NAME>",
"DB_USER": "<DB_USER>",
"DB_PASSWORD": "<DB_PASSWORD>"
}
}
}
}[mcp_servers.mcpql]
command = "node"
args = ["<ABSOLUTE_PATH_TO_CLONE>/dist/server.js"]
[mcp_servers.mcpql.env]
DB_SERVER = "<DB_SERVER>"
DB_NAME = "<DB_NAME>"
DB_USER = "<DB_USER>"
DB_PASSWORD = "<DB_PASSWORD>"gemini mcp add --scope user -e DB_SERVER=<DB_SERVER> -e DB_NAME=<DB_NAME> -e DB_USER=<DB_USER> -e DB_PASSWORD=<DB_PASSWORD> mcpql node -- '<ABSOLUTE_PATH_TO_CLONE>/dist/server.js'DB_SERVER |
Required: SQL Server host name or IP (not needed when DB_CONNECTION_STRING is set). |
|---|---|
DB_NAME |
Required: Database to connect to. |
DB_USER |
Required: Login name for SQL, Windows or Azure AD password sign-in. |
DB_PASSWORD |
Required: Password for that login. |
DB_AUTHENTICATION_TYPE |
Optional: sql (default), windows or azure-ad. |
DB_CONNECTION_STRING |
Optional: Full connection string, used instead of the individual settings. |
DB_PORT |
Optional: Server port; the README gives 1433. |
DB_INSTANCE_NAME |
Optional: Named instance such as SQLEXPRESS. |
DB_DOMAIN |
Optional: Windows domain; required when DB_AUTHENTICATION_TYPE is windows. |
DB_AZURE_CLIENT_ID |
Optional: Service principal client ID for azure-ad; also set DB_AZURE_CLIENT_SECRET and DB_AZURE_TENANT_ID. |
DB_ENCRYPT |
Optional: Encrypt the connection (default false). |
DB_ALLOW_MODIFICATIONS |
Optional: Allow write and DDL queries (default false); DB_ALLOW_STORED_PROCEDURES does the same for procedures. |
MCPQL is a local stdio server for Microsoft SQL Server and Azure SQL Database. It connects through the mssql driver and gives an assistant tools to look at a database's structure: table columns, keys, indexes and constraints, stored procedure parameters and source, and the dependencies between objects. It can also search object names and definitions, preview rows, profile a column or a whole table, and run SQL or stored procedures.
It starts read-only. Version 1.1.0 (dist/security.js) refuses a query passed to mcp_execute_query if its text contains any of the words INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, TRUNCATE, MERGE, BULK, EXEC or EXECUTE, unless DB_ALLOW_MODIFICATIONS is true. mcp_execute_procedure is refused unless DB_ALLOW_STORED_PROCEDURES is true. This is a word filter on the query text, not a database permission. GRANT, DENY, REVOKE and SELECT ... INTO are not on the list, and a read query that uses one of the listed words, such as a column called Update, is blocked.
It signs in with SQL Server logins (the default), Windows NTLM with a domain, Azure AD user and password, an Azure AD service principal, or a full connection string in DB_CONNECTION_STRING. It opens the connection on the first tool call, not at startup.
| Runtime | Node.js 18+ |
|---|
Node.js 18 or later for npx. A reachable SQL Server 2016+ or Azure SQL database and a login for it: a SQL login by default, or a Windows domain account (DB_DOMAIN is required for that mode), or Azure AD credentials. For Azure SQL, a server firewall rule that admits your IP. For SQL Server Express, TCP/IP must be enabled and DB_INSTANCE_NAME set.
SQL Server and Azure SQL only. Object names must be schema-qualified (dbo.Users). mcp_preview_data returns 100 rows by default, up to 1000 with limit. mcp_get_sample_values returns 10 values by default. mcp_quick_data_analysis samples 1000 rows by default. Connection and request timeouts default to 30 seconds. With DB_AUTHENTICATION_TYPE=azure-ad the code always turns encryption on and certificate trust off, whatever DB_ENCRYPT says (src/db.ts). The README's own snippets run npx -y hendrickcastro/mcpql, which fetches the GitHub repository; the published npm package is mcpql.
It suits developers and DBAs who work on SQL Server and want an assistant to explore a schema, trace dependencies or profile data, mostly read-only. It runs on your own machine with your own database login. Read-only depends on a keyword filter, so give it a login that only has read rights on production instead of relying on the default settings. It is a community project, not a Microsoft one. If you need a database other than SQL Server, pick a server made for that engine.
mcp_table_analysismcp_sp_structuremcp_preview_datamcp_get_column_statsmcp_execute_proceduremcp_execute_querymcp_quick_data_analysismcp_search_comprehensivemcp_get_dependenciesmcp_get_sample_valuesmcp_get_security_status