# JDBC MCP Server [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/igorolv/jdbc-mcp-server  
**GitHub Stars:** 3  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/jdbc-mcp-server

## Description
Read-only PostgreSQL, Oracle and SQL Server access for AI agents: SQL, plans, schema, index stats

## Tools
Capabilities this server exposes over MCP:

- **executeQuery** — Execute a `SELECT`, `WITH`, or `EXPLAIN` statement. Parameters: `sql`, `params` (array for `?`) or `namedParams` (object for `:name`), optional `paramTypes`, `limit`, `timeoutSeconds`. The result is marked with `truncated: true` if the row limit is hit
- **explainQuery** — Return the execution plan. PostgreSQL: `EXPLAIN (FORMAT TEXT)`. Oracle: `EXPLAIN PLAN FOR` plus `DBMS_XPLAN.DISPLAY`. SQL Server: `SET SHOWPLAN_TEXT ON` on the same session. Parameters can be passed as `params` (`?`) or `namedParams` (`:name`), with optional `paramTypes`. `analyze=true` on PostgreS…
- **analyzePlan** — Compact LLM-oriented plan summary instead of a large raw plan dump: highest-cost nodes, full scans on large tables, estimate errors (planner vs. reality, requires `analyze=true` on PostgreSQL), risky nested loops with large outer input, and disk sort spills. PostgreSQL: `EXPLAIN (FORMAT JSON)` / `E…
- **validateQuery** — Validate syntax without execution: read-only guard plus driver `prepareStatement`, with a JSqlParser-derived `inspection` summary when parsing succeeds. Parameters can be passed as `params` (`?`) or `namedParams` (`:name`), with optional `paramTypes`. Useful for LLM self-correction
- **inspectQuery** — Parse SQL through JSqlParser without touching the database and return an AST summary: tables, aliases, CTEs, select items, joins, predicates, order by, columns, parameters, features, and parser warnings
- **queryLint** — Parse SQL and combine the AST with metadata, index, and FK checks. Returns advisory warnings such as unknown tables or columns, `SELECT *`, joins without conditions, FKs without supporting indexes, and predicate/order-by columns that are not leading index columns. SQL is not executed
- **resolveQueryLineage** — Resolve direct objects referenced by a query and recursively expand database views/materialized views to underlying physical tables. Function/procedure expansion is best-effort: embedded `SELECT` / `WITH` statements are extracted from routine source when available. Parameters: `sql`, `schema`, `exp…
- **benchmarkQuery** — Run the query `coldRuns + warmRuns` times (defaults to 1 cold + 3 warm) and return wall-clock `min`, `median`, and `max` for warm runs; cold runs are reported separately. Parameters can be passed as `params` (`?`) or `namedParams` (`:name`), with optional `paramTypes`. `limit` and `timeoutSeconds`…
- **timedQuery** — Regular `executeQuery` plus wall-clock `elapsed_ms`. Parameters can be passed as `params` (`?`) or `namedParams` (`:name`), with optional `paramTypes`. On PostgreSQL, it also captures `pg_stat_statements` snapshots before and after the query; the diff shows which query IDs added `calls`, `total_exe…
- **listSchemas** — List schemas. System schemas are hidden by default; use `includeSystem=true` to show all
- **listTables** — List tables and views in a schema. Parameters: `schema`, `namePattern` (with `%` / `_`), `types` (comma-separated, for example `TABLE,VIEW,MATERIALIZED VIEW`)
- **describeTable** — Full object description in one call: columns, primary key, unique constraints, indexes, outgoing/incoming FKs, CHECK constraints and allowed values, plus compact trigger metadata
- **getTriggerDefinition** — Trigger body for one named trigger. Parameters: `schema`, `table`, `trigger
- **getViewDefinition** — SQL definition of a view
- **listRoutines** — Functions, procedures, and packages in a schema
- **getRoutineDefinition** — Function or procedure source code. On Oracle, all `ALL_SOURCE` lines are concatenated in order
- **listSequences** — Sequences in one schema, or across schemas when `schema` is omitted
- **searchObjects** — Case-insensitive substring search across non-system tables, views, routines, sequences, and synonyms
- **tableContext** — Context around one table: the table itself, FK parents, and optionally child tables and relationship edges. FK traversal uses the requested depth (default 1, max 4). Parameters: `schema`, `table`, `depth`, `includeIncoming`, `includeStats`, `includeObserved
- **findJoinPaths** — Find JOIN paths between two tables through FKs. The graph is traversed in both directions and each edge includes `joinCondition` and a typed `evidence` bundle (see *Edge evidence* below). Parameters: `fromSchema` / `fromTable`, `toSchema` / `toTable`, `maxDepth` (default/max 4), `maxPaths` (default…
- **schemaBrief** — Plain-text full-schema map for SQL authoring: all matching tables/views with column counts, PK, incoming/outgoing relationship counts, key-like columns, central/isolated tables, and capped key FK relationships. Use this first when relevant tables are unknown; follow with `queryContext` for detailed…
- **schemaGraph** — Schema relationship graph metrics: nodes with in/out degree and classification, edges, central tables, isolated tables, connected components, and cycle hints. Optionally includes the shortest path between two tables
- **schemaLint** — Schema lint audit: missing primary keys, FKs without indexes, FK type mismatches, nullable unique constraints, status/type columns without CHECK constraints, orphan `*_id` columns, missing remarks, isolated tables, and wide tables. Checks are configurable through `checks
- **queryContext** — Build compact SQL-authoring context from search terms and/or explicit tables. Finds relevant tables and columns using declared schema names/comments plus usage-catalog semantic evidence when available, includes constraints and allowed values, relationships and JOIN paths between selected tables, an…
- **schemaGraphDot** — DOT/Graphviz representation of the schema relationship graph. Nodes are tables with all columns and types (`PK` and `FK` marked inline), edges include JOIN conditions. Parameters: `schema`, `tables` (optional comma-separated filter)
- **usageCatalogStatus** — Current catalog state (`not_started`, `indexing`, `ready`, `failed`, or `invalidated`), enabled flag, and configured sources
- **invalidateUsageCatalogCache** — Drop the runtime index. The next lookup rebuilds it synchronously from configured files and database-native objects
- **getQuery** — Full record selected by `sourceKind`, `sourcePath`, and optional `sourceUnit`: header, parameters, parsed tables/columns/join pairs, outputs, and field usages
- **listQueries** — Paginated listing with optional filters: `sourcePath` (LIKE — `%` / `_` allowed), `sourceKind`, `businessDomain`, `tag`, `parseStatus`, `searchText`, `limit`, `offset
- **findQueriesByTable** — All catalog queries that reference a given table. Case-insensitive matching against alias-resolved, uppercased table names. Optional `schema` filter
- **findQueriesByColumn** — All catalog queries that reference a given column, with the SQL `context` of the reference (`select` / `where` / `join` / `order_by` / `having`). Optional `schema` and `table` filters
- **observedRelationships** — Aggregate observed equi-join pairs across stored queries, grouped by `(left_table.left_column = right_table.right_column)` with `support` count and contributing query uids. Non-equi joins (BETWEEN, function-based) are excluded. The same data feeds the `observedQuery` layer of the relationship `evid…
- **listKnownTags** — Tags currently used in the catalog, with query counts. Lets the agent reuse a stable vocabulary across ingest calls
- **listKnownDomains** — Same for `businessDomain` values
- **listKnownKinds** — Source-kinds currently used in the catalog with their query counts. Helps the agent discover valid values for `listQueries` `sourceKind` filter
- **rebuildCatalog** — Rebuild the persistent structure snapshot and usage index for comma-separated `schemas` (or the configured/default scope), checkpoint SQLite WAL, and return the distributable `<catalog>.db` path and the connection it was built for
- **listConnections** — List the databases this server serves: `name` (the value to pass as `connection`), `description`, engine kind, default schema, whether a local catalog file already exists, and whether the pool has been built in this process
- **sampleRows** — Return a few rows from a table or view (`LIMIT` / `FETCH FIRST` / `TOP` depending on database). Parameters: `schema`, `table`, `limit` (default 10, max 100)
- **columnStats** — Basic column statistics: `total_rows`, `non_null_rows`, `distinct_values`, `min`, `max`. A cheap one-shot aggregate when only extremes are needed
- **columnDistribution** — Top-N most frequent values of a column plus their share. Surfaces skew, for example `70%` of rows with `status='OK'`, where an index on `status` alone is not useful. Parameters: `schema`, `table`, `column`, `topN` (default 20, max 1000)
- **columnHistogram** — Percentiles P25 / P50 / P75 / P90 / P95 / P99 plus `min`, `max`, and null count. Uses SQL:2003 `WITHIN GROUP`: `percentile_cont` for numeric types and `percentile_disc` for all others, including dates, timestamps, and text
- **nullRatio** — One scan for null / non-null counts across every table column. Columns are sorted by descending `null_ratio`. `sparse=true` marks columns where more than 50% of rows are null, which may be candidates for a partial index
- **estimateSelectivity** — Estimate how many rows a predicate would return **without executing the query**, using `EXPLAIN` on `SELECT 1 FROM t WHERE <predicate>`. Returns estimated rows, baseline row count without the filter, and selectivity. Useful for placing the most selective predicate first in a composite index
- **joinCardinality** — Estimate the output row count of a `JOIN` without executing it. Returns planner estimate, per-side row counts, and `selectivity_vs_cartesian`. Supports `INNER`, `LEFT`, `RIGHT`, and `FULL
- **tableStats** — Table and index sizes in bytes, estimated row count, dead tuples on PostgreSQL, last vacuum/analyze, and seq/idx scan counters. On Oracle, also includes best-effort `DBA_SEGMENTS` data when available
- **indexStats** — Per-index size, scan counter, columns, unique/primary flag, and index type. PostgreSQL extras: `idx_tup_read/fetch`, `pg_get_indexdef`. Oracle extras: `distinct_keys`, `clustering_factor`, `blevel`, `leaf_blocks`, `last_analyzed
- **unusedIndexes** — Indexes with zero scans on PostgreSQL (`pg_stat_user_indexes`). PK and UNIQUE indexes are excluded. On Oracle, returns a diagnostic note because `ALL_INDEXES` does not expose usage counters; `DBA_INDEX_USAGE` 12.2+ or `V$OBJECT_USAGE` with `ALTER INDEX ... MONITORING USAGE` is needed
- **redundantIndexes** — Indexes whose column list is a strict prefix of another index on the same table. Unique indexes are not reported because dropping them would remove a constraint. Index type must match
- **fkIndexCoverage** — Foreign keys on the child side that lack a supporting index, a classic cause of slow `DELETE` / `UPDATE CASCADE` and slow JOINs. The result includes `suggested_index_columns` ready for `CREATE INDEX

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/igorolv/jdbc-mcp-server), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Install:

```sh
./gradlew bootJar   # → build/libs/jdbc-mcp-server.jar
```

2. Add to Claude Code:

```sh
claude mcp add --scope user jdbc -- java -jar /path/to/jdbc-mcp-server.jar
```

3. Add to Codex:

```sh
codex mcp add jdbc -- java -jar /path/to/jdbc-mcp-server.jar
```

## Documentation

## 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:

```json
{
  "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.

_Full upstream README: https://allmcps.com/mcp/jdbc-mcp-server/readme_

