What JDBC MCP Server does
JDBC MCP Server gives MCP clients read-only access to relational databases through JDBC. It combines SQL execution with database metadata and analysis tools, so an agent can discover a schema, construct a query, check it before execution, and investigate its performance.
Built-in database handling covers PostgreSQL 11+, Oracle 12c+, SQL Server 2012+, Firebird 3+, and SQLite. Other JDBC-compatible databases can be used with an external driver JAR. A single server process can expose any number of named database connections.
The server is suited to data questions, unfamiliar-schema exploration, SQL review, query tuning, and schema or index audits. It is not intended for data modification: its SQL guard accepts a single SELECT, WITH, or EXPLAIN statement, and database-side read-only protections can add another layer where supported.
How it works
The server uses the MCP stdio transport. An MCP client starts the Java process and communicates with it over standard input and output; no network port is required. Connections are created on first use, and each tool identifies the target database with a connection name.
Database definitions live in connections.json, normally under ~/.jdbc-mcp-server/ on the host or /data/connections.json in the Docker image. Each entry contains a JDBC URL and may include credentials, a default schema, a description, and schema settings for the structure snapshot. The engine is inferred from the URL prefix. Generic JDBC connections also specify driverPath.
Query tools support positional ? parameters through params and named :name parameters through namedParams. Limits and timeouts can be supplied for query execution; benchmarking requires both a row limit and a timeout. PostgreSQL plan analysis can use EXPLAIN ANALYZE when requested.
Setup and configuration
Obtain the JAR from the latest project release, build it with ./gradlew bootJar, use the published Docker image, or run it through JBang. Java 21 or newer is required for the JAR. The bundled drivers cover the built-in database engines; an external driver JAR is needed for another JDBC database.
A minimal MCP client registration runs:
{
"command": "java",
"args": ["-jar", "/absolute/path/jdbc-mcp-server.jar"],
"env": {}
}
The connection file can contain several databases, each keyed by a name. The url field is required. Credentials may be placed in the connection definition, including passwords that reference ${VAR} values. Use a database account with read-only permissions, and restrict access to the connection file because it can contain credentials.
Tools and capabilities
- Execute SELECT, WITH, and EXPLAIN statements with parameters, row limits, and timeouts.
- Return execution plans for PostgreSQL, Oracle, and SQL Server using each engine's plan facilities.
- Summarize costly plan nodes, large-table scans, estimate errors, risky nested loops, and disk sort spills.
- Validate SQL without running it, inspect its parsed structure, and report parser or syntax-related findings.
- Lint queries for issues such as unknown objects,
SELECT *, unconditional joins, and index coverage concerns.
- Resolve query lineage through tables, views, materialized views, and available routine source.
- Measure query wall-clock timings and compare cold and warm benchmark runs.
- List schemas, tables, views, routines, sequences, triggers, and view or routine definitions.
- Describe tables with columns, keys, indexes, foreign keys, checks, allowed values, and trigger metadata.
- Build schema context, table relationship paths, graph metrics, and DOT/Graphviz output.
- Search application-query usage catalogs and retrieve queries associated with a table.
Tool groups can be disabled individually. The server also maintains a per-connection SQLite-based structure snapshot and optional usage catalog for schema and query-context operations.
Limitations and notes
The write-protection design combines a JSqlParser AST check with session-, transaction-, or file-level read-only modes where the database supports them. A read-only database user remains the recommended protection because it does not depend on the server's safeguards.
Plan behavior and available metadata vary by database engine. For example, PostgreSQL estimate-versus-reality analysis requires analyze=true, while generic JDBC databases rely on JDBC metadata and the capabilities of their external driver. The server keeps query execution bounded when limit and timeoutSeconds are used; benchmark calls require both values and do not permit unbounded execution.
The stdio design means the MCP client must be able to launch the Java process or an equivalent Docker or JBang command. Connection credentials are configured outside the client registration, in the server's connection file.