# Rheopyrin/db-access-mcp [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/Rheopyrin/db-access-mcp  
**GitHub Stars:** 0  
**npm Downloads (last month):** 603  
**Views:** 6  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/rheopyrin-db-access-mcp

## Description
Query PostgreSQL, MySQL, Redshift and SQL Server over verified SSH / AWS SSM tunnels, with read-only enforcement, confined file exports, and pluggable secret providers (env, Vault, AWS Secrets Manager, RDS IAM). Published on the official MCP Registry.

## Tools
Capabilities this server exposes over MCP:

- **dialect_list** — List the database dialects this server supports. Returns each dialect name (usable as the "type" field of a connection in the config), its default port and the execution-plan format produced by query_plan.
- **connection_list** — List configured database connections (postgres, mysql, redshift). Returns key, type, description, read_only flag, host/port/database and metadata. Credentials are never included. Use the returned key with the query, query_plan and up_tunnel tools.
- **connection_find** — Find configured database connections by parameters: host, port, database, type, read_only and/or metadata key-value pairs. All provided filters are combined with AND. Username/password filters are ignored. Returns the same sanitized shape as connection_list.
- **connection_test** — Test a configured connection end-to-end: resolves secrets, opens the tunnel if configured, connects and runs a one-row server-info query. Returns ok=true with server version, user, database and latency — or ok=false with the failure code and hint (an unreachable database is a valid test result, not a tool error).
- **query** — Execute a SQL query on a configured connection (use connection_list to discover keys). Results are truncated to max_rows (default from config, typically 1000) with truncated=true set; add LIMIT for large tables. Connections marked read_only reject writes at the session level. Multi-statement scripts are passed to the driver as-is (for mysql they require multipleStatements enabled in the connection options).
- **query_to_file** — Execute a SQL query and write the full result to a file (csv or jsonl) instead of returning rows — use this for large exports that must not go through the model context. Relative file_path resolves under the export dir (default /tmp/db-access-mcp/exports); absolute or ~-prefixed paths must fall under the export dir or a configured allow_export_paths root. Parent directories are created. Existing files are not overwritten unless overwrite=true. postgres/mysql stream rows (no row limit by default); redshift/mssql buffer in memory and are capped at 100000 rows.
- **query_plan** — Get the execution plan (EXPLAIN) for a SQL query without running it. postgres/mysql return a JSON plan; redshift returns a text plan (Redshift supports neither FORMAT JSON nor EXPLAIN ANALYZE, and its cost numbers are relative — do not compare them to postgres costs).
- **up_tunnel** — Open (or reuse) the tunnel configured for a connection WITHOUT connecting to the database. Returns the local host/port to connect through and a tunnel_id for down_tunnel. The tunnel is closed by down_tunnel, on idle timeout or when this MCP instance exits. Pass local_port to bind an exact local port; this fails if the tunnel is already open on a different port or the port is taken.
- **down_tunnel** — Close a tunnel previously opened with up_tunnel, by its tunnel_id. By default only the up_tunnel pin is released: if live connection pools still use the tunnel it stays open and their keys are returned in remaining_holders. With force=true the holder pools are drained and the tunnel is closed unconditionally (the next query recreates them).
- **tunnel_list** — List the tunnels currently open in THIS MCP instance, with a live health probe each. tunnel_id is accepted by down_tunnel; "connections" are the pools holding the tunnel, "pins" are up_tunnel holds. Configured-but-not-open tunnels are visible via connection_list (the tunnel field).
- **config_reload** — Re-read the configuration files (config.json + conf.d/*.json, or --config <file>) into the running server, so connections and tunnels added or edited on disk become usable WITHOUT a restart. Open pools and running tunnels are never touched: they keep their previous definition until they are closed (idle timeout, down_tunnel, shutdown) and are reported in "warnings". Returns the files that were read plus the connections/tunnels added, removed and changed. On an invalid config nothing is swapped — the server keeps running on the previous configuration and the validation errors are returned.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "db-access-mcp": {
    "command": "npx",
    "args": ["-y","@rheopyrin/db-access-mcp"],
    "env": {
      "DB_ACCESS_MCP_WORKDIR": "",
      "DB_ACCESS_MCP_EXPORTDIR": "",
      "DB_ACCESS_MCP_CONFIG": "",
      "DB_ACCESS_MCP_LOG_LEVEL": ""
    }
  }
}
```

**Requires environment variables:** `DB_ACCESS_MCP_WORKDIR`, `DB_ACCESS_MCP_EXPORTDIR`, `DB_ACCESS_MCP_CONFIG`, `DB_ACCESS_MCP_LOG_LEVEL` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What Rheopyrin/db-access-mcp does

Rheopyrin/db-access-mcp gives MCP clients access to configured PostgreSQL, MySQL, Amazon Redshift, and Microsoft SQL Server databases. It provides tools for discovering connections, checking database health, executing SQL, inspecting query plans, managing tunnels, and reloading configuration.

The server is designed for database access where credentials and network paths need explicit controls. Connections can use SSH or AWS SSM tunnels, while secrets can come from environment variables, HashiCorp Vault, AWS Secrets Manager, RDS IAM authentication, or temporary Redshift credentials. Connection listings return sanitized metadata rather than credentials.

## How it works

The server communicates over stdio, so an MCP client starts it as a child process. Each process maintains its own connection pools, tunnels, and idle timers. SSH tunnels run in process, while AWS SSM sessions use a watchdog. Tunnels close when explicitly released, after an idle timeout, or when the MCP process exits.

`query` returns rows up to the configured limit, which defaults to a value typically set to 1,000, and marks truncated responses. `query_to_file` writes CSV or JSONL results under the export directory or another configured permitted root, keeping large result sets out of the model context. PostgreSQL and MySQL exports stream rows; Redshift and SQL Server exports buffer results and cap them at 100,000 rows.

Read-only connections reject writes at the database session level. SSH connections verify bastion host keys using a configured SHA-256 pin or `known_hosts`. Logs are emitted as JSON lines on stderr, with sensitive values redacted; stdout remains available for MCP protocol traffic.

## Setup and configuration

The package requires Node.js 20.19 or newer. Run it with `npx -y @rheopyrin/db-access-mcp`, or point an MCP client at a locally built `dist/cli.js`. On first startup, it creates the `~/.db_acess_mcp` work directory, including `config.json`, `conf.d/`, and an example configuration. Edit the configuration before using database tools.

The command accepts `--workdir`, `--exportdir`, `--config`, repeatable `--env-file`, and `--log-level` options. Their environment equivalents include `DB_ACCESS_MCP_WORKDIR`, `DB_ACCESS_MCP_EXPORTDIR`, `DB_ACCESS_MCP_CONFIG`, and `DB_ACCESS_MCP_LOG_LEVEL`. The default export location is `/tmp/db-access-mcp/exports`, created when the first export is requested.

AWS SSM tunnels require the AWS CLI and Session Manager plugin on the host. AWS SSO bootstrap may open a browser for login. SSH tunnels use the in-process SSH client and require no additional tunnel executable.

## Tools and capabilities

- `dialect_list` reports supported dialect names, default ports, and execution-plan formats.
- `connection_list` and `connection_find` locate configured connections without returning credentials.
- `connection_test` resolves secrets, opens any configured tunnel, connects, and runs a one-row server-information query.
- `query` executes SQL with row-count and timeout controls. Multi-statement behavior follows the database driver and connection options.
- `query_plan` runs `EXPLAIN` without executing the query. PostgreSQL and MySQL return JSON plans; Redshift returns text.
- `query_to_file` writes complete or capped results as CSV or JSONL while enforcing export-path restrictions and overwrite rules.
- `up_tunnel`, `down_tunnel`, and `tunnel_list` open, release, inspect, and health-check tunnels. Forced shutdown can drain pools holding a tunnel.
- `config_reload` applies valid connection and tunnel changes without restarting, while leaving already-open pools and tunnels on their previous definitions.

## Limitations and notes

Redshift plans are text format, and their cost figures are relative rather than directly comparable with PostgreSQL costs. Redshift does not support JSON-format plans or `EXPLAIN ANALYZE` through this tool.

Relative export paths resolve below the export directory. Absolute and `~`-prefixed paths must remain below that directory or a configured `allow_export_paths` root. Existing files require `overwrite: true`.

A configured read-only connection prevents writes at the session level. MySQL multi-statement scripts require `multipleStatements` to be enabled in the connection options. Configuration reload keeps active pools and tunnels unchanged until they close or are recreated.

_Full upstream README: https://allmcps.com/mcp/rheopyrin-db-access-mcp/readme_

