db-mcp
Provides tools for interacting with MySQL databases, including querying data, executing INSERT/UPDATE/DELETE statements, running DDL commands, listing tables, and describing table structures.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@db-mcpwhat's the schema of the orders table?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
db-mcp is a Model Context Protocol (MCP) server that exposes database operations for HighGo (瀚高) and MySQL databases as MCP tools. AI assistants such as OpenCode and Claude Code can query, modify, and inspect databases through a permission-controlled, stdio-based interface.
Features
Two database types: HighGo (PostgreSQL-compatible) and MySQL, selected via configuration
Five MCP tools: query, execute, DDL, list tables, and describe table
Fine-grained permissions: per-operation allowlist (
SELECT/INSERT/UPDATE/DELETE/DDL)Flexible configuration: environment variables or a JSON config file (env vars take precedence), with
${ENV_VAR}placeholder support in config filesConnection pooling: configurable pool size per connection
Single-file build:
build:prodbundles everything into one self-containeddist/index.js— nonode_modulesneeded at runtime
Related MCP server: Multi-DB MCP Server
Requirements
Node.js >= 18
Quick Start
npm install
npm run build:prodnpm run build:prod runs tsc and then bundles the output with esbuild into a single file:
dist/
└── index.js # self-contained, run directly with nodeNote:
npm run build(tsc only) also compiles todist/, but that output still requiresnode_modules/at runtime. Usebuild:prodfor a portable single-file build.
Run the server (it speaks MCP over stdio, so it is normally launched by an MCP client, not run interactively):
node dist/index.jsConfiguration
Two ways to configure a connection; environment variables take precedence over the config file.
Option 1: Environment variables
Variable | Required | Default | Description |
| yes | — | Database host |
| yes | — | Database name |
| yes | — | Username |
| yes | — | Password |
| no |
|
|
| no |
| Auto-selected per type when omitted |
| no | all | Comma-separated, e.g. |
| no |
| Max pool size |
DB_HOST=127.0.0.1 DB_PORT=5866 DB_DATABASE=mydb DB_USERNAME=admin DB_PASSWORD=xxx node dist/index.jsOption 2: Config file
The server loads ./db-mcp-config.mysql.example.json from the current working directory by default. Copy one of the examples from config/ and point DB_MCP_CONFIG at it:
# e.g. on Windows
set DB_MCP_CONFIG=D:\path\to\db-mcp\config\db-mcp-config.highgo.example.json
node dist/index.jsOr place a config file named db-mcp-config.mysql.example.json in the working directory (the default path).
Example config:
{
"name": "highgo-dev",
"type": "highgo",
"host": "127.0.0.1",
"port": 5866,
"database": "your_database",
"username": "your_username",
"password": "your_password",
"pool": { "max": 10 },
"permissions": ["SELECT", "INSERT", "UPDATE", "DELETE", "DDL"]
}Config file fields: name, type (highgo | mysql), host, port, database, username, password, pool.max, permissions. Values may reference environment variables with ${ENV_VAR} syntax, e.g. "password": "${DB_PASSWORD}".
⚠️ The config file contains database credentials — never commit real values to git. The shipped examples under
config/only contain placeholders.
Connecting an MCP Client
OpenCode
Add the server to the mcp field of opencode.json (project root) or your global config:
Via environment variables:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"db-mcp": {
"type": "local",
"command": ["node", "/path/to/db-mcp/dist/index.js"],
"enabled": true,
"environment": {
"DB_TYPE": "highgo",
"DB_HOST": "127.0.0.1",
"DB_PORT": "5866",
"DB_DATABASE": "your_database",
"DB_USERNAME": "your_username",
"DB_PASSWORD": "your_password",
"DB_PERMISSIONS": "SELECT,INSERT,UPDATE,DELETE,DDL"
}
}
}
}Via config file:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"db-mcp": {
"type": "local",
"command": ["node", "/path/to/db-mcp/dist/index.js"],
"enabled": true,
"environment": {
"DB_MCP_CONFIG": "/path/to/db-mcp/config/db-mcp-config.mysql.example.json"
}
}
}
}Or add it interactively with the CLI:
opencode mcp addOpenCode walks you through the setup step by step:
Run
opencode mcp add— an interactive prompt opens.Select local as the server type.
Give the server a name, e.g.
db-mcp.Enter the command:
node /path/to/db-mcp/dist/index.js.Add the environment variables when prompted (
DB_TYPE,DB_HOST, ... orDB_MCP_CONFIG).Verify the server is connected with
opencode mcp list.
If the server is slow to start up, raise the tool-fetch timeout with "timeout": 10000 (defaults to 5000 ms).
Codex
MCP servers are configured in ~/.codex/config.toml under the [mcp_servers] section. Add the server with the Codex CLI:
codex mcp add db-mcp --env DB_MCP_CONFIG=/path/to/db-mcp/config/db-mcp-config.mysql.example.json -- node /path/to/db-mcp/dist/index.jsOr edit ~/.codex/config.toml directly:
[mcp_servers.db-mcp]
command = "node"
args = ["/path/to/db-mcp/dist/index.js"]
enabled = true
[mcp_servers.db-mcp.env]
DB_MCP_CONFIG = "/path/to/db-mcp/config/db-mcp-config.mysql.example.json"To connect via environment variables instead, list them in the env table (see Option 1).
Claude Code
Add the server with the Claude Code CLI (saved to ~/.claude/settings.json by default; pass --scope project to save it to .mcp.json in the project root instead):
claude mcp add -e DB_MCP_CONFIG=/path/to/db-mcp/config/db-mcp-config.mysql.example.json db-mcp -- node /path/to/db-mcp/dist/index.jsOr edit .mcp.json (project scope) or ~/.claude/settings.json (user scope) directly:
{
"mcpServers": {
"db-mcp": {
"type": "stdio",
"command": "node",
"args": ["/path/to/db-mcp/dist/index.js"],
"env": {
"DB_MCP_CONFIG": "/path/to/db-mcp/config/db-mcp-config.mysql.example.json"
}
}
}
}Tools
Tool | Description | Risk |
| Execute a SELECT query; returns column names and data rows | Read-only |
| Execute INSERT / UPDATE / DELETE; returns affected row count | Write |
| Execute DDL statements (CREATE / ALTER / DROP / indexes, etc.) | Write |
| List all tables in the current database | Read-only |
| Inspect a table's structure (columns, types, primary key, etc.) | Read-only |
Permission Control
Every connection carries a permissions allowlist. Requests are rejected with an error when the required permission is missing:
db_query/db_list_tables/db_describe_tablerequireSELECTdb_executechecks the statement prefix and requiresINSERT,UPDATE, orDELETEaccordinglydb_ddlrequiresDDL
To restrict a connection, set DB_PERMISSIONS (comma-separated) or the permissions array in the config file. Restrictive example: SELECT,DDL allows reads and schema changes but no DML writes.
Project Structure
src/
├── index.ts # MCP server entry: tool registration + stdio transport
├── config.ts # config loading, permission checks, SQL validation
├── types.ts # shared types (ConnectionConfig, QueryResult, ...)
└── clients/
├── highgo-client.ts # HighGo client implementation
└── mysql-client.ts # MySQL client implementation
config/
├── db-mcp-config.highgo.example.json
└── db-mcp-config.mysql.example.json
highgodb/ # vendored HighGo database driver (based on pg), installed via file: dependencyDevelopment
npm install
npm run dev # watch mode via tsx (src/index.ts)
npm run build # tsc compile only
npm run build:prod # tsc + esbuild single-file bundleSecurity Notes
The server executes arbitrary SQL within the granted permissions — run it with the least-privileged database account your use case allows.
The MCP transport is stdio and does not enforce authentication on its own; control access to the machine/process that hosts it.
Read-only tools are marked with
readOnlyHintso clients can route them accordingly, but enforcement happens through the permission allowlist.Keep credentials out of version control (see the config section).
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceMCP server for connecting to databases (PostgreSQL, MySQL, SQL Server, Redis) enabling SQL queries, table exploration, and Redis key-value operations.1MIT
- Flicense-qualityCmaintenanceA multi-database MCP server supporting PostgreSQL, ClickHouse, and MySQL that enables database exploration and SQL execution through MCP stdio or HTTP API.
- Flicense-qualityCmaintenanceA generic MCP server for MySQL operations, enabling listing databases/tables, describing schemas, running read-only SQL, and optionally executing write SQL with logging.1
- Alicense-qualityBmaintenanceA database operation server based on the MCP protocol, providing database connection, querying, schema exploration, data analysis, and SQL generation tools.MIT
Related MCP Connectors
MCP server for managing Prisma Postgres.
MCP server for interacting with the Supabase platform
GibsonAI MCP server: manage your databases with natural language
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/FQXCS/db-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server