- Home
- MCP servers
- Database Query
Database Query
- javascript
1
GitHub Stars
javascript
Language
4 months ago
First Indexed
3 weeks ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"xuejike-coding-db-mcp": {
"command": "coding-db-mcp",
"args": [],
"env": {
"DB_HOST": "YOUR_HOST",
"DB_NAME": "YOUR_DATABASE",
"DB_PORT": "YOUR_PORT",
"DB_USER": "YOUR_USER",
"DB_PASSWORD": "YOUR_PASSWORD"
}
}
}
}You can query multiple databases directly from your MCP workflow using the Database Query MCP Tool. It reads your project configuration to obtain connection details and can talk to MySQL, PostgreSQL, MSSQL, and Oracle databases in a safe read-only mode, returning structured results without modifying data.
How to use
Install and run the tool in your MCP workflow to perform read-only SQL queries across supported databases. When the MCP client invokes this service, you provide host, port, user, password, database name, and the query you want to run. The tool will ensure only read-only queries are executed and will return structured results with column metadata and row data.
How to install
Prerequisites: Node.js and npm installed on your system.
Option A: Install globally and run directly.
npm install -g coding-db-mcp
db-query-mcp
Option B: Run with npx without installation.
npx coding-db-mcp
Configure the MCP client to load this service as an MCP server. The following examples show how to register the service under the name database_query using either a direct command or an npx-based command.
Configuration and security
Database connection information can be picked up from your project configuration automatically. If you prefer manual configuration, you can supply a local environment file with the necessary credentials.
Security considerations: operate in read-only mode to automatically block any data modification statements. Restrict database user permissions so that credentials have only the necessary read access. Do not hard-code credentials in code, and enable SSL in production environments.
Examples and error handling
When a query succeeds, you receive a structured response containing success, data, columns, and rowCount. If an error occurs, you receive success: false along with an error message and a code.
Troubleshooting
If you encounter connection errors, verify network reachability to the database host, correct port numbers, and that the credentials have read access for the target database. Check SSL/TLS settings if your database requires encrypted connections.
Tools exposed by the MCP service
query_mysql: Execute read-only SQL on MySQL databases. Parameters: host, port, user, pwd, db, querySql.
query_postgresql: Execute read-only SQL on PostgreSQL databases. Parameters: host, port, user, pwd, db, querySql.
query_mssql: Execute read-only SQL on MSSQL databases. Parameters: host, port, user, pwd, db, querySql.
query_oracle: Execute read-only SQL on Oracle databases. Parameters: host, port, user, pwd, db, querySql.
Available tools
query_mysql
Executes a read-only SQL SELECT-style query against a MySQL database and returns structured results.
query_postgresql
Executes a read-only SQL SELECT-style query against a PostgreSQL database and returns structured results.
query_mssql
Executes a read-only SQL SELECT-style query against a MSSQL database and returns structured results.
query_oracle
Executes a read-only SQL SELECT-style query against an Oracle database and returns structured results.