Database Access for AI Agents: MCP Server with JDBC
AI agents are only as capable as the data they can reach. mcp-server-generic-jdbc is an open-source MCP server that gives AI assistants safe, configurable read access to relational databases — PostgreSQL, MySQL, Oracle, and more — with zero custom code.
Anthropic's Model Context Protocol (MCP) defines a standard interface for AI assistants to use external tools and data sources. What was missing was a generic, database-agnostic solution for classic JDBC databases. mcp-server-generic-jdbc fills exactly that gap.
The Problem — AI Agents Without Database Access
AI agents can only be productive when they can reach the data that matters. In most organisations, that data lives in relational databases that are not natively accessible to AI tooling. Integrating them typically requires custom connectors, proprietary middleware, or one-off glue code — all of which add maintenance burden.
Without a standard approach, every database–agent pairing becomes its own project. That doesn't scale, and it ties up engineering capacity that's needed elsewhere.
Three MCP Tools for Complete Read Access
The server exposes three MCP tools that together give an agent full read access to any connected JDBC database:
list_tables: Returns all accessible tables — the first step for an agent exploring an unfamiliar database.describe_table: Returns column names and data types for a given table, so the agent can write informed queries.execute_sql: Executes SELECT queries and returns results. Destructive operations likeDROP,DELETE, andUPDATEare blocked by built-in SQL validation, enforcing read-only access regardless of database permissions.
Tool descriptions can be customised via environment variables (MCP_TOOL_*_DESCRIPTION) so the agent understands the purpose and contents of the database.
Configuration — Environment Variables Only
There is no code to write. The entire setup is driven by environment variables:
DB_KIND: Database type (e.g.postgresql,mysql)DB_URL: JDBC connection stringDB_USER/DB_PASS: Credentials
Three deployment modes are available: live-reload development mode (./mvnw quarkus:dev), Docker Compose for production, and a standalone executable JAR. The deployment directory includes ready-to-use example configurations.
Supported Databases
JDBC's broad ecosystem means the server works with PostgreSQL, MySQL, MariaDB, Microsoft SQL Server, and Oracle out of the box. Any database with an available JDBC driver can be added to the mix.
The implementation is built on Java 21 and the Quarkus framework, which enables compact container images and fast startup times — both valuable in server-adjacent deployment scenarios.
View on GitHub
Full source code, deployment examples, and an AGENTS.md with guidance for agent usage are available in the repository:
GitHub: mcp-server-generic-jdbcConclusion
mcp-server-generic-jdbc turns database integration for AI agents from a coding problem into a configuration problem. For teams looking to ground AI assistants in real operational data, it's a practical and secure starting point.
Integrating AI agents into your database infrastructure?
We can help you design and build AI workflows that access your existing systems safely and effectively. Get in touch.
Get in Touch