mcp-win-stdio-db

v0.5.6
mcp-win-stdio-db Checked 2 hours ago Published 2 days ago

Unified Database Model Context Protocol (MCP) server for PostgreSQL & MySQL: 36 tools for multi-server querying, DBA operations (create, drop, clone, dump…

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_connections

List all configured database connections (PostgreSQL & MySQL) and indicate the active connection.

test_connection

Test live connectivity and latency to a configured database connection or server. Args: connection: Optional database connection alias or URL to test. Defaults to active connection. server: Optional server alias. timeout: Socket connection timeout in seconds (default: 3).

ParameterTypeDescription
connection
server
timeoutinteger

remove_connection

Remove a configured database connection alias.

ParameterTypeDescription
name *string

use_database

Switch active database connection. Supports connection aliases (e.g. 'showreel', 'production'), database names, or sibling databases on the active/specified server. Sticky connection state is guaranteed for all subsequent tool calls when connection/server is omitted. Args: database: Database name to connect to, or registered connection/server alias. server: Optional server or connection alias (e.g. 'showreel', 'localhost') to locate sibling database on. connection: Optional alias for server/connection name. name: Optional alias for database or…

ParameterTypeDescription
connection
database
name
server

list_databases

List all databases available on the active (or specified) server instance.

ParameterTypeDescription
connection
server

list_schemas

List all user schemas with table count and disk size (PostgreSQL) or current database table summary (MySQL).

ParameterTypeDescription
connection
server

describe_table

Deep inspection of a table: column types, defaults, nullability, PKs, inbound/outbound FKs, indexes, and sizes. Accepts 'table', 'table_name', or 'tableName'.

ParameterTypeDescription
connection
schema
server
table
tableName
table_name

get_table_ddl

Reconstruct and return the complete, ground-truth CREATE TABLE DDL statement for a table. Includes all column types, defaults, nullability, primary keys, foreign keys (with ON DELETE/ON UPDATE actions), unique/check constraints, and separate table indexes. Accepts 'table', 'table_name', or 'tableName'. Args: tableName: Name of the table (or alias 'table' / 'table_name'). table: Alias for tableName. table_name: Alias for tableName. schema: Optional schema name (defaults to 'public' or auto-resolves in PostgreSQL). connection: Optional co…

ParameterTypeDescription
connection
schema
server
table
tableName
table_name

schema_overview

High-level architecture map of tables, column summaries, estimated row counts, and disk sizes. Capped to prevent context window bloat in large enterprise databases. Args: schema: Target schema name or 'all' (PostgreSQL). Default 'public'. connection: Optional connection or server name to query. server: Optional server or connection alias. max_tables: Maximum number of tables to detail (default 60, max 150).

ParameterTypeDescription
connection
max_tablesinteger
schema
server

compact_schema_overview

Token-optimized compact schema overview returning ultra-concise 1-line table definitions. Example: '• props_management.materials (id: uuid PK, material_number: varchar UQ, department_id: uuid FK->departments)' Condenses 50+ enterprise tables into <1000 tokens to protect context windows. Args: schema: Target schema name or 'all' (PostgreSQL, default: 'public'). connection: Optional target database connection or server alias. server: Optional server or connection alias. max_tables: Maximum number of tables to include (default: 80, max 150).…

ParameterTypeDescription
connection
max_tablesinteger
schema
server

get_table_sample

Fetch sample rows from a table along with column metadata and row count estimate. Automatically masks PII and credentials (passwords, tokens, keys) unless mask_sensitive=False. Accepts 'table', 'table_name', or 'tableName'. Args: tableName: Name of the table to sample (or alias 'table' / 'table_name'). table: Alias for tableName. table_name: Alias for tableName. limit: Number of sample rows to retrieve (default 5, max 100). schema: Optional schema name (PostgreSQL). mask_sensitive: Whether to redact sensitive columns like passwo…

ParameterTypeDescription
connection
limitinteger
mask_sensitiveboolean
schema
server
table
tableName
table_name

search_schema

Search across tables and column names for a keyword with safety limits to protect context window. Accepts both snake_case ('search_term') and camelCase ('searchTerm'), or 'query'.

ParameterTypeDescription
connection
max_resultsinteger
query
schema
searchTerm
search_term
server

read_query

Safely execute a read-only SELECT query inside a read-only transaction with automatic rollback and token-safe pagination. Forwards native PostgreSQL / MySQL error diagnostics directly upon error. Args: sql: SELECT SQL query. params: Optional query parameters. limit: Max rows to return (default 50, max 200). max_cell_chars: Max characters per cell (default 2000, increase up to 50000 for large string_agg/JSON values). connection: Optional target database connection or server alias. server: Optional server or connection alias.

ParameterTypeDescription
sql *string
connection
limitinteger
max_cell_charsinteger
params
server

execute_query

Execute INSERT, UPDATE, DELETE, or DDL statement(s). Supports transactional multi-statement batch execution with statement-by-statement progress, exact line/statement failure diagnostics, dry_run rollback support with before-image row preview, safety guardrails against naked updates/deletes and destructive DDL, and statement audit logging with undo support. Safety Guards: - Connections configured as mode='read_only' automatically block all write statements. - Connections flagged with env='prod' require explicit confirm=True for non-dry-run writes. - Naked UPDA…

ParameterTypeDescription
sql *string
allowDestructiveDdl
allowUnfiltered
allow_destructive_ddlboolean
allow_unfilteredboolean
confirmboolean
connection
dryRun
dry_runboolean
lockTimeoutMs
lock_timeout_ms
params
server
statementTimeoutMs
statement_timeout_ms

execute_sql_file

Execute a .sql migration or script file directly from disk without loading its SQL into LLM context. Reads the file in Python with a bounded 10 MB read and delegates to execute_query's transactional multi-statement batch engine, inheriting all safety guardrails (read_only, prod confirm=True, dry_run, destructive DDL checks, lock/statement timeouts, and audit logging). Security Note: Reads any .sql file accessible to the MWS process; intended for local/authorized coding-agent workflows where filesystem access is scoped to the host user. Args: file_path: Pa…

ParameterTypeDescription
file_path *string
allowDestructiveDdl
allowUnfiltered
allow_destructive_ddlboolean
allow_unfilteredboolean
confirmboolean
connection
dryRun
dry_runboolean
encodingstring
lockTimeoutMs
lock_timeout_ms
server
statementTimeoutMs
statement_timeout_ms

undo_query

Safely undo the previous mutating SQL statement (UPDATE or DELETE) using captured before-image snapshots. Re-inserts deleted records (including cascading child records in topological FK order) or restores pre-update values. Args: audit_id: Optional specific audit ID (e.g. 'aud_20261103_093120_1a2b'). If omitted, finds the latest undoable write for the connection. auditId: CamelCase alias for audit_id. connection: Optional connection name (defaults to active connection). server: Optional server alias. dry_run: If True, simulates and previews…

ParameterTypeDescription
auditId
audit_id
connection
dryRun
dry_runboolean
server

get_audit_log

Retrieve recent database statement execution history and audit records. Displays executed statements, timestamps, status, rows affected, and available audit_ids for undo. Args: limit: Maximum number of audit records to return (default 20). connection: Optional filter by connection alias. server: Optional alias for connection. include_snapshots: If True, includes full before-image row data in records (default False). includeSnapshots: CamelCase alias for include_snapshots.

ParameterTypeDescription
connection
includeSnapshots
include_snapshotsboolean
limitinteger
server

explain_query

Run EXPLAIN on a SQL statement to inspect execution plan and costs.

ParameterTypeDescription
sql *string
analyzeboolean
connection
server

get_database_stats

Get database metrics: database size, active connections vs max_connections, cache hit ratio, schema sizes, and engine version.

ParameterTypeDescription
connection
server

add_connection

Dynamically add a new PostgreSQL or MySQL connection at runtime. Args: name: Unique alias for this connection (e.g. 'aws_showreel', 'local_dev'). url: Database URL (postgresql://user:pass@host:5432/db). type: Optional engine override ('postgres' or 'mysql'). setActive: Set as default active connection. test_connect: Verify connectivity upon registration. mode: Access mode: 'read_only' (blocks writes) or 'read_write' (default). env: Target environment: 'prod', 'staging', or 'dev' (default). 'prod' requires confirm=True on writes.…

ParameterTypeDescription
name *string
url *string
description
envstring
modestring
setActive
set_active
test_connectboolean
type

edit_connection

Dynamically update an existing database connection's URL, credentials, or alias name at runtime. Persists updates to ~/.mcp-win-stdio/db_connections.json. Args: name: Existing connection alias name to update (e.g. 'dev', 'showreel_dev'). new_url: Optional new PostgreSQL or MySQL connection string (e.g. 'postgresql://user:pass@host:5432/db'). new_name: Optional new alias name if renaming the connection. type: Optional engine type override ('postgres' or 'mysql'). setActive: If True, sets this connection as the active sticky database default.…

ParameterTypeDescription
name *string
description
env
mode
new_name
new_url
setActive
set_active
test_connectboolean
type

create_database

Create a new database on the active (or specified) PostgreSQL or MySQL server instance.

ParameterTypeDescription
database *string
connection
encoding
server
template

drop_database

Safely drop a database. Requires exact 'confirm_name' matching the database name. Supports 'force' to kill active connections.

ParameterTypeDescription
database *string
confirm
confirmName
confirm_name
connection
forceboolean
server

clone_database

Instantly clone an entire database (schema, tables, indexes, data). Uses native template cloning in PostgreSQL.

ParameterTypeDescription
connection
server
source
sourceDatabase
source_database
target
targetDatabase
target_database

terminate_connections

Kill active client connections or hanging locks on a specific database.

ParameterTypeDescription
database *string
connection
server

list_active_queries

Inspect currently executing queries, lock waits, and execution durations.

ParameterTypeDescription
connection
database
server

dump_database

Export an SQL dump snapshot of the database using native pg_dump or mysqldump. Accepts both snake_case ('output_path', 'schema_only') and camelCase ('outputPath', 'schemaOnly').

ParameterTypeDescription
connection
database
outputPath
output_path
schemaOnly
schema_only
server

restore_database

Restore a database from a .sql dump file using native psql or mysql. Accepts both snake_case ('dump_file_path', 'file_path') and camelCase ('dumpFilePath').

ParameterTypeDescription
database *string
connection
dumpFilePath
dump_file_path
file_path
server

analyze_table_indexes

Perform deep index analysis on a database table. Identifies defined indexes, primary keys, unindexed foreign keys (unindexed FKs cause full table scans during joins and cascaded deletes), and unused indexes. Accepts 'table', 'table_name', or 'tableName'. Args: tableName: Name of the table (or alias 'table' / 'table_name'). table: Alias for tableName. table_name: Alias for tableName. schema: Target schema (Postgres). If None, auto-resolved. connection: Connection name to query. server: Optional server or connection alias.…

ParameterTypeDescription
connection
schema
server
table
tableName
table_name

compare_schemas

Compare table structures, missing tables, missing columns, and data type discrepancies between two database connections. Ideal for detecting environment drift (e.g. dev vs staging vs prod). Args: source_connection: Baseline source connection or server name. target_connection: Target connection or server name to compare against. schema: Target schema name (PostgreSQL, default: 'public'). source_server: Optional alias for source_connection. target_server: Optional alias for target_connection.

ParameterTypeDescription
schema
source_connection
source_server
target_connection
target_server

audit_database_health

Comprehensive database-wide health audit for PostgreSQL. Returns three categories of actionable findings: 1. unindexed_foreign_keys — FK columns with no supporting index (causes slow JOINs). 2. unused_indexes — Truly unused indexes with zero scans (excludes Primary Keys & Unique Constraints). 3. bloated_tables — Tables with >20% dead tuples that need VACUUM. Args: schema: Schema to audit. Default None (or '*'/'all') audits all non-system schemas. detail: If True, returns full list of all unused indexes. Default Fa…

ParameterTypeDescription
connection
detailboolean
schema
server

generate_erd

Generate an Entity-Relationship Diagram (ERD) in GitHub/Mermaid markdown syntax. Extracts all tables, columns, primary keys, and foreign key relationships directly from database catalog metadata. Args: schema: Target schema (PostgreSQL) or database (MySQL). If None, uses active/public schema. tables: Optional list of table names to filter ERD scope (e.g. ['materials', 'props_inventory']). include_columns: If True, includes column definitions with PK/FK annotations inside table blocks. connection: Optional connection name or URL (defaults to act…

ParameterTypeDescription
connection
include_columnsboolean
schema
server
tables

diff_data

Compare row data between two tables (or across schemas/connections). Identifies rows only in source, rows only in target, and rows with modified values with column-by-column diffs. Args: table1: Source table name (e.g. 'materials'). table2: Target table name. If omitted, defaults to table1 (useful for comparing across schemas/connections). key_columns: Primary key or unique identifier columns for matching rows. Auto-detected if omitted. schema1: Schema for table1 (Postgres). schema2: Schema for table2 (defaults to schema1 if omitted).…

ParameterTypeDescription
table1 *string
connection1
connection2
key_columns
max_differencesinteger
schema1
schema2
table2

list_slow_queries

Inspect slow database queries using pg_stat_statements / pg_stat_activity (PostgreSQL) or performance_schema / processlist (MySQL). Args: limit: Maximum number of slow queries to return (default: 20). min_duration_ms: Minimum execution time threshold in milliseconds (default: 100.0). connection: Optional connection name or URL. server: Optional server or connection alias.

ParameterTypeDescription
connection
limitinteger
min_duration_msnumber
server

get_locks

Inspect active database locks and query blocking dependency trees. Reveals hanging transactions, blocking PIDs, locked tables, and lock wait times. Args: connection: Optional connection name or URL. server: Optional server or connection alias.

ParameterTypeDescription
connection
server

export_table

Export an entire table or SQL query result directly to a file (CSV, JSON, or TSV) on disk. Executes in streaming batches without loading intermediate records into LLM context. Args: table_or_query: Table name (e.g. 'materials') or raw SQL query if is_query=True. output_path: Destination file path (e.g. 'exports/materials.csv'). format: Export format: 'csv', 'json', or 'tsv' (default: 'csv'). is_query: Set to True if table_or_query is a custom SQL SELECT statement. schema: Optional schema name if exporting a table in PostgreSQL. conn…

ParameterTypeDescription
output_path *string
table_or_query *string
connection
formatstring
is_queryboolean
schema
server

import_csv

Bulk import a CSV file directly into a database table with batching and transaction safety. Supports dry-run validation (checks all rows against constraints, then safely rolls back). Args: table_name: Destination database table name. csv_path: Path to the source CSV file. delimiter: CSV delimiter character (default: ','). schema: Target schema name (PostgreSQL). if_exists: 'append' to insert rows, or 'truncate' to clear table before inserting. on_conflict: 'error' (fail on unique constraint violation) or 'ignore' (skip conflicting r…

ParameterTypeDescription
csv_path *string
table_name *string
batch_sizeinteger
connection
delimiterstring
dry_runboolean
if_existsstring
on_conflictstring
schema
server