Purpose
mcp-jdbc-server is a lightweight Java-based MCP (Model Context Protocol) server for connecting to generic database management systems (DBMS) via JDBC. It is built on Quarkus and is compatible with Virtuoso DBMS as well as any database backend that provides a JDBC driver. Its goal is to provide standardized database access capabilities for MCP client applications.
Main Capabilities
The server exposes the following tools to MCP client applications:
- jdbc_get_schemas: Retrieves and returns a list of all schema names in the connected database.
- jdbc_get_tables: Retrieves information about tables in the specified schema (or the default schema) and returns a JSON string containing fields such as TABLE_CAT, TABLE_SCHEM, TABLE_NAME, TABLE_TYPE.
- jdbc_filter_table_names: Filters by name substring and returns matching table information.
- jdbc_describe_table: Returns detailed column information for the specified table, including column names, data types, nullability, primary keys and foreign keys, etc. (such as COLUMN_NAME, TYPE_NAME, COLUMN_SIZE, IS_NULLABLE).
- jdbc_query_database: Executes standard SQL queries and returns results in JSON format.
- jdbc_query_database_md: Executes standard SQL queries and returns results in Markdown table format, suitable for reports and visualization.
- jdbc_query_database_jsonl: Executes standard SQL queries and returns results in JSON Lines (JSONL) format, one JSON object per line, suitable for structured responses.
- jdbc_spasql_query (Virtuoso-specific): Executes SPASQL (SQL/SPARQL hybrid) queries and returns results, supporting max_rows (default 20) and timeout (default 30000 milliseconds) parameters.
- jdbc_sparql_query (Virtuoso-specific): Executes SPARQL queries and returns results, supporting format (default 'json') and timeout (default 30000 milliseconds) parameters.
- jdbc_virtuoso_support_ai (Virtuoso-specific): Calls the Virtuoso-specific AI assistant function, passing in a prompt and an optional API key.
Most of the above tools support optional user, password, and url parameters; the default username and password are both "demo".
Usage
Running this MCP server requires Java 21 or later.
- Clone the repository.
- Override the default environment variables via a .env file to match local preferences.
- For Claude Desktop users using Virtuoso and its JDBC driver, add the corresponding configuration in claude_desktop_config.json; users using other JDBC drivers or driver combinations must also add a configuration adapted to their local environment in claude_desktop_config.json.
- Install the JDBC driver and ensure its JAR file is registered with the host operating system's Java Virtual Machine (JVM) via $CLASSPATH, for example:
export CLASSPATH=$CLASSPATH:/path/to/driver1.jar:/path/to/driver2.jar:/path/to/driverN.jar
For basic usage and troubleshooting, you can use MCP Inspector:
- Install:
npm install -g @modelcontextprotocol/inspector - Start:
npx @modelcontextprotocol/inspector java -jar /path/to/mcp-jdbc-server/MCPServer-1.0.0-runner.jar - Access the URL returned by Inspector to troubleshoot MCP server interaction issues.
You can also start Inspector with the following command-line arguments:
npx @modelcontextprotocol/inspector java -cp MCPServer-1.0.0-runner.jar:/path/to/driver1.jar:/path/to/driver2.jar:/path/to/driverN.jar io.quarkus.runner.GeneratedMain
The JDBC driver URL template examples given in the documentation:
- Oracle JDBC Driver URL Template:
jdbc:oracle:thin:@<hostname>:[port]:<SERVICEID> - Informix JDBC Driver URL Template:
jdbc:informix-sqli://<hostname>:<port>/<database>:<INFORMIXSERVER>=<SERVICEID>
Applicable Scenarios
Applicable to scenarios that require accessing a database through an MCP client application, including: browsing database schemas and table structures, finding tables by name, viewing table column definitions and primary/foreign keys, executing SQL queries and obtaining results in JSON/Markdown/JSONL format. For Virtuoso users, SPASQL and SPARQL queries can also be executed, as well as AI assistant functions called.
Limitations
- Requires Java 21 or later.
- Requires the corresponding JDBC driver to be installed for the target database and $CLASSPATH to be properly configured.
- SPASQL and SPARQL queries and AI assistant calls are Virtuoso-specific features and are not supported by other database backends.
- The materials do not provide information such as fees, pricing, platform support scope, performance metrics, or effect guarantees.