A very simple MCP (Model Context Protocol) server written in Java for querying and inspecting SQL databases (PostgreSQL, Oracle, SQL Server, MySQL, MariaDB, SQLite).
Features
Support for PostgreSQL, Oracle, SQL Server, MySQL, MariaDB, and SQLite
A very simple MCP (Model Context Protocol) server written in Java for querying and inspecting SQL databases
Execute custom SQL queries (SELECT only by default, set JMCP_QUERY_SELECT_ONLY=false to allow INSERT, UPDATE, DELETE, etc.)
Two connection modes: Stdio (direct launch) and HTTP/SSE (remote connection)
Requirements
Java 21 or higher
Maven 3.6+
Access to a PostgreSQL, Oracle, SQL Server, MySQL, MariaDB, or SQLite database
Build
mvn clean package
Configuration
Set the following environment variables:
Variable
Required
Default
Description
JMCP_JDBC_URL
Yes
-
JDBC connection URL
JMCP_DB_USERNAME
Yes (not for SQLite)
-
Database username
JMCP_DB_PASSWORD
Yes (not for SQLite)
-
Database password
JMCP_MODE
No
stdio
Server mode: stdio or http
JMCP_HTTP_PORT
No
3000
HTTP server port (only for http mode)
JMCP_QUERY_SELECT_ONLY
No
true
If true, only SELECT queries are allowed. If false, allows INSERT, UPDATE, DELETE, etc.
JDBC URL Examples
PostgreSQL:
jdbc:postgresql://localhost:5432/mydb
Oracle:
jdbc:oracle:thin:@localhost:1521:ORCL
SQL Server:
jdbc:sqlserver://localhost:1433;databaseName=mydb
MySQL:
jdbc:mysql://localhost:3306/mydb
MariaDB:
jdbc:mariadb://localhost:3306/mydb
SQLite:
jdbc:sqlite:/path/to/database.db
Running & Connecting to the MCP Server
After building the server, you need to configure your MCP client to connect to it. There are two connection modes:
Mode 1: Stdio (Direct Launch)
MCP client launches the server as a subprocess, reading JSON-RPC messages from stdin and writing responses to stdout. This is the default mode used by Claude Desktop and other MCP clients that launch the server directly.
Configuration for Claude Desktop
Add the following to your Claude Desktop configuration file:
Important: Replace C:\\path\\to\\java-mcp-sql-server-1.0.0.jar with the actual path to your compiled JAR file (use double backslashes \\ on Windows).
Mode 2: HTTP/SSE (Remote Connection)
The server starts an HTTP server with SSE (Server-Sent Events) support, allowing MCP clients to connect to a running instance instead of launching a new process.