Database
About
Database MCP server for MySQL, MariaDB, PostgreSQL & SQLite
Details
- Author
- haymon-ai
- Downloads
- 218
- Categories
- Database, Other
Jump to
- MCP server for SQL databases.
- Supports MySQL, MariaDB, PostgreSQL, and SQLite.
- Enables database interaction through the Model Context Protocol.
—
A single-binaryMCPserver for SQL databases. Connect your AI assistant to MySQL/MariaDB, PostgreSQL, or SQLite with zero runtime dependencies.
- Multi-database— MySQL/MariaDB, PostgreSQL, and SQLite from one binary
- MCP tools— schema discovery (listDatabases,listTables,listViews,listTriggers,listFunctions,listProcedures,listMaterializedViews), data access (readQuery,writeQuery), DDL (createDatabase,dropDatabase,dropTable), andexplainQuery. Read-only mode hides the write tools (writeQuery,createDatabase,dropDatabase,dropTable). SeeMCP Toolsfor per-backend availability.
- Single binary— ~7 MB, no Python/Node/Docker needed
- Multiple transports— stdio (for Claude Desktop, Cursor) and HTTP (for remote/multi-client)
- Two-layer config— CLI flags > environment variables, with sensible defaults per backend
curl -fsSL https://dbmcp.haymon.ai/install.sh | bash
irm https://dbmcp.haymon.ai/install.ps1 | iex
curl -fsSL https://dbmcp.haymon.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
See theinstallation docsfor Docker, Cargo, and other methods.
Add a.mcp.jsonfile to your project root. MCP clients read this file and configure the server automatically.
Stdio transport— the client starts and manages the server process:
{ "mcpServers": { "dbmcp": { "command": "dbmcp", "args": ["stdio"], "env": { "DB_BACKEND": "mysql", "DB_HOST": "127.0.0.1", "DB_PORT": "3306", "DB_USER": "root", "DB_PASSWORD": "secret", "DB_NAME": "mydb" } } } }
HTTP transport— you start the server yourself, the client connects to it:
# Start the server first dbmcp http --db-backend mysql --db-user root --db-name mydb --port 9001
{ "mcpServers": { "dbmcp": { "type": "http", "url": "http://127.0.0.1:9001/mcp" } } }
Note:The"type": "http"field is required for HTTP transport. Without it, clients like Claude Code will reject the config.
# MySQL/MariaDB dbmcp stdio --db-backend mysql --db-host localhost --db-user root --db-name mydb # PostgreSQL dbmcp stdio --db-backend postgres --db-host localhost --db-user postgres --db-name mydb # SQLite dbmcp stdio --db-backend sqlite --db-name ./data.db # HTTP transport dbmcp http --db-backend mysql --db-user root --db-name mydb --host 0.0.0.0 --port 9001
DB_BACKEND=mysql DB_USER=root DB_NAME=mydb dbmcp stdio
Configuration is loaded with clear precedence:
CLI flags > environment variables > defaults
Environment variables are typically set by your MCP client (viaenvorenvFilein the server config).
A subcommand is required — runningdbmcpwith no subcommand prints usage help and exits with a non-zero status.
Database Options (shared across subcommands)
HTTP-only Options (only available withhttpsubcommand)
Lists accessible databases, paginated viacursor/nextCursor. SeeCursor Paginationfor iteration details. Not available for SQLite.
Lists tables in a database, paginated viacursor/nextCursor. SeeCursor Paginationfor iteration details.
Parameters:database(defaults to the active database; SQLite has nodatabaseparameter),cursor,search,detailed.
searchis an optional case-insensitiveLIKE/ILIKEpattern with%(any sequence) and_(single character) as wildcards — passusers%to match names beginning withusers, or%order%for substring matching. A bare word with no wildcards matches only an exact table name.
detailed(defaultfalse) switches the response shape:
- Brief(default) —tablesis a sorted JSON array of bare table-name strings.
- Detailed(detailed: true) —tablesis a JSON object keyed by table name; each value carries the table'sschema,kind,owner,comment,columns[],constraints[],indexes[], andtriggers[]. One call returns both the table list and the per-table metadata.
Lists views in a database, paginated viacursor/nextCursor. Available on MySQL/MariaDB, PostgreSQL (publicschema), and SQLite. Parameters:database(defaults to the active database; SQLite has nodatabaseparameter),cursor,search,detailed. SQLite returns the brief shape only —searchanddetailedare not accepted there.
searchis an optional case-insensitiveLIKE/ILIKEpattern with%(any sequence) and_(single character) as wildcards. Thesearchvalue must remain identical across paginated calls for cursor continuity.
detailed(defaultfalse) switches the response shape:
- Brief(default) —viewsis a sorted JSON array of bare view-name strings. View names are unique per schema, so no duplicates appear.
- Detailed(detailed: true) —viewsis a JSON object keyed by bare view name; each value carries the per-backend metadata payload. PostgreSQL exposesschema,owner,description,definition. MySQL/MariaDB exposesschema,definer,security,checkOption,updatable,characterSetClient,collationConnection,definition. See thelistViewsreferencefor source columns, enumerated value sets, and intentional omissions per backend.
SeeCursor Paginationfor iteration details.
Lists user-defined triggers on tables, paginated viacursor/nextCursor. Internal constraint and foreign-key triggers are excluded. Available on MySQL/MariaDB, PostgreSQL (publicschema), and SQLite. Parameters:database(defaults to the active database; SQLite has nodatabaseparameter),cursor,search,detailed.
searchis an optional case-insensitiveLIKE/ILIKEpattern with%(any sequence) and_(single character) as wildcards. Thesearchvalue must remain identical across paginated calls for cursor continuity.
detailed(defaultfalse) switches the response shape:
- Brief(default) —triggersis a sorted JSON array of bare trigger-name strings.
- Detailed(detailed: true) —triggersis a JSON object keyed by trigger name; each value carries the per-backend metadata payload (timing, events, definition, and backend-specific extras like PostgreSQLstatus/functionNameor MySQL/MariaDB session-context fields). See thelistTriggersreferencefor the full per-backend field list.
SeeCursor Paginationfor iteration details.
Lists user-defined SQL functions, paginated viacursor/nextCursor. PostgreSQL excludes aggregates, window functions, and procedures; MySQL/MariaDB excludes loadable UDFs (mysql.func). Available on MySQL/MariaDB and PostgreSQL (publicschema). Not available for SQLite. Parameters:database(defaults to the active database),cursor,search,detailed.
searchis an optional case-insensitiveLIKE/ILIKEpattern with%(any sequence) and_(single character) as wildcards. Thesearchvalue must remain identical across paginated calls for cursor continuity.
detailed(defaultfalse) switches the response shape:
- Brief(default) —functionsis a sorted JSON array of bare function-name strings. PostgreSQL overloads appear once per overload (duplicate name strings are expected).
- Detailed(detailed: true) —functionsis a JSON object keyed by function signature; each value carries the per-backend metadata payload (language, arguments, return type, definition, and backend-specific extras such as PostgreSQLvolatility/strict/parallelSafetyor MySQL/MariaDB session-context fields). PostgreSQL keys arename(arguments)(overloads disambiguate); MySQL/MariaDB keys are bare names (no overloading). See thelistFunctionsreferencefor the full per-backend field list.
SeeCursor Paginationfor iteration details.
Lists user-defined stored procedures, paginated viacursor/nextCursor. Available on MySQL/MariaDB and PostgreSQL (publicschema, PostgreSQL 11+). Not available for SQLite. Parameters:database(defaults to the active database),cursor,search,detailed.
searchis an optional case-insensitiveLIKE/ILIKEpattern with%(any sequence) and_(single character) as wildcards. Thesearchvalue must remain identical across paginated calls for cursor continuity.
detailed(defaultfalse) switches the response shape:
- Brief(default) —proceduresis a sorted JSON array of bare procedure-name strings. PostgreSQL overloads appear once per overload (duplicate name strings are expected).
- Detailed(detailed: true) —proceduresis a JSON object keyed by procedure signature; each value carries the per-backend metadata payload (language, arguments, security, definition, and backend-specific extras such as PostgreSQLowneror MySQL/MariaDBdeterministic/sqlDataAccess/session-context fields). PostgreSQL keys arename(arguments)(overloads disambiguate; zero-arg procedures key asname()); MySQL/MariaDB keys are bare names (no overloading). See thelistProceduresreferencefor the full per-backend field list.
SeeCursor Paginationfor iteration details.
Lists materialized views in thepublicschema, paginated viacursor/nextCursor. PostgreSQL only — not available for MySQL/MariaDB or SQLite. Parameters:database(defaults to the active database),cursor,search,detailed.
searchis an optional case-insensitiveILIKEpattern with%(any sequence) and_(single character) as wildcards. SQL meta-characters (',;,--) are bound as parameter values and never interpolated. Thesearchvalue must remain identical across paginated calls for cursor continuity.
detailed(defaultfalse) switches the response shape:
- Brief(default) —materializedViewsis a sorted JSON array of bare matview-name strings. Matview names are unique per schema, so no duplicates appear.
- Detailed(detailed: true) —materializedViewsis a JSON object keyed by bare matview name; each value carriesschema,owner,description(ornullwhen noCOMMENT ON MATERIALIZED VIEW),definition(the SELECT body verbatim frompg_matviews.definition),populated(falsefor matviews createdWITH NO DATAand never refreshed), andindexed(truewhen at least one index exists;REFRESH MATERIALIZED VIEW CONCURRENTLYadditionally requires a unique index). Detailed mode deliberately omits column metadata,tablespace, storage parameters, and unique-index detection — recoverable viadefinition,listTables(detailed=true), orreadQueryagainstpg_indexes. See thelistMaterializedViewsreferencefor source columns and operational semantics.
SeeCursor Paginationfor iteration details.
Executes a read-only SQL query (SELECT, SHOW, DESCRIBE, USE, EXPLAIN). Always enforces SQL validation as defence-in-depth. Parameters:query,database,cursor.SELECTresults paginate viacursor/nextCursor;SHOW,DESCRIBE,USE, andEXPLAINreturn a single page and ignorecursor. SeeCursor Paginationfor iteration details.
Executes a write SQL query (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP). Only available when read-only mode is disabled. Parameters:query,database.
Creates a database if it doesn't exist. Only available when read-only mode is disabled. Not available for SQLite. Parameters:database.
Drops an existing database. Refuses to drop the currently connected database. Only available when read-only mode is disabled. Not available for SQLite. Parameters:database.
Drops a table from a database. If the table has foreign key dependents, the database error is surfaced to the user. On PostgreSQL, acascadeparameter is available to force the drop withCASCADE. Only available when read-only mode is disabled. Parameters:database,table,cascade(PostgreSQL only).
Returns the execution plan for a SQL query. Supports an optionalanalyzeparameter for actual execution statistics (PostgreSQL and MySQL/MariaDB). In read-only mode, EXPLAIN ANALYZE is only allowed for read-only statements since it actually executes the query. SQLite uses EXPLAIN QUERY PLAN (no ANALYZE support). Always available regardless of read-only mode. Parameters:query,database,analyze(PostgreSQL/MySQL only).
- Read-only mode(default) — write tools hidden from AI assistant;readQueryenforces AST-based SQL validation
- Single-statement enforcement— multi-statement injection blocked at parse level
- Dangerous function blocking—LOAD_FILE(),INTO OUTFILE,INTO DUMPFILEdetected in the AST
- Identifier validation— database/table names validated against control characters and empty strings
- Origin + Host allowlists— server-side rejection (403) plus CORS preflight; configurable for HTTP transport
- SSL/TLS— configured via individualDB_SSL_variables
- PII redaction(opt-in, off by default)— when enabled, query tool output passes through a regex-based redactor that rewrites detected PII spans across46 built-in entity typesspanning seven categories: personal (email), financial (cards, IBAN, UK bank accounts, sort and US ABA routing codes, CVV), government IDs (SSN, ITIN, EIN, UK/US passports, NHS, NINO, SIN, VAT), contact (phone), network (IP, URL, MAC), digital identity (API keys, JWTs, PEM private keys, password hashes), and crypto wallets. Toggle:--pii/PII_ENABLE. Operator:--pii-operator/PII_OPERATOR— one ofreplace(default, entity-aware placeholders like<EMAIL_ADDRESS>),mask(length-preserving),redact(drop),hash(SHA-256 hex). Optional subset via--pii-categories/PII_CATEGORIES(comma-separated, e.g.financial,government); unset enables all built-ins. Scope: query tool output payloads only. SeePII configurationfor the full surface.
- ML/NER redaction(opt-in at runtime, off by default)— addsPERSON,LOCATION,ORGANIZATION,NATIONALITY_RELIGION_POLITICS, andFACILITYdetection that regex cannot catch, enabled via the--pii-ner/PII_NER_ENABLEtoggle plus a user-supplied model directory. Which entities are produced depends on the model's labels (CoNLL models give person/location/organization; OntoNotes-class models add NRP and facility). Inference usesONNX Runtime(model directory holdsconfig.json,tokenizer.json,model.onnx; recommended: the MIT-licenseddslim/bert-base-NERexported to ONNX, int8-quantized for speed). Fail-closed: a model that cannot load aborts startup and an inference error fails the request — never a silent fallback. Respects--pii-categories. English for v1.
- Credential redaction— database password is never shown in logs or debug output
# Unit tests cargo test --workspace --lib --bins # Integration tests (requires Docker) ./tests/run.sh # Filter by engine ./tests/run.sh --filter mariadb ./tests/run.sh --filter mysql ./tests/run.sh --filter postgres ./tests/run.sh --filter sqlite # With MCP Inspector npx @modelcontextprotocol/inspector ./target/release/dbmcp stdio # HTTP mode testing curl -X POST http://localhost:9001/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"0.1"}}}'
This is a Cargo workspace with the following crates:
cargo build # Development build cargo build --release # Release build (~7 MB) cargo test # Run tests cargo clippy --workspace --tests -- -D warnings # Lint cargo fmt # Format cargo doc --no-deps # Build documentation
This project is licensed under the MIT License — see theLICENSEfile for details.
A single-binary MCP server for MySQL, MariaDB, PostgreSQL, and SQLite
A Model Context Protocol (MCP) server that provides multi-database query execution capabilities with support for SQLite, PostgreSQL, and MySQL databases. Includes a built-in Web UI for managing database connections.
Enables AI assistants to interact with various databases through JDBC connections.
Production-grade Model Context Protocol (MCP) server for unified SQL database access. Connect multiple databases through a single MCP server with schema discovery, relationship mapping, caching, and safety controls.
Provides database access for SQLite, SQL Server, PostgreSQL, and MySQL.
Multi-database analysis MCP server (PostgreSQL, MySQL, SQLite). Inspects schemas, detects index problems, analyzes table bloat, and explains query plans for actionable database optimization.
A lightweight MCP server for any database with a JDBC driver. Built with Quarkus and requires Java 21+.
An MCP server that provides AI assistants with structured access to multiple databases simultaneously.
ORMCP provides a curated, object-oriented, MCP-compliant view of relational data in any JDBC-compliant database (e.g., PostgreSQL, MySQL, Oracle, SQL Server, DB2, SQLite) — improving reasoning clarity, reducing token usage, and establishing a clear governance boundary.
Interact with PostgreSQL, MySQL, MariaDB, and SQLite databases using SQLAlchemy.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





