mcp-java-sdk-examples
Health Pass
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Community trust — 32 GitHub stars
Code Pass
- Code scan — Scanned 2 files during light audit, no dangerous patterns found
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
A collection of MCP server examples developed by various Java SDKs
MCP Java SDK Examples
A collection of MCP examples developed with Java SDKs.
Requirements
- Java 17 or later
- Maven 3.9.16 or the included Maven Wrapper
What is MCP?
The Model Context Protocol (MCP) lets servers expose data and functionality to LLM applications in a standardized way. MCP servers can expose resources, tools, prompts, and more.
Examples
- JDBC Server - Exposes JDBC database metadata through an MCP resource
JDBC Server
The JDBC example includes an annotated-sdk implementation backed by a JDBC connection.
The packaged server starts in STDIO mode by default.
Implemented resource:
db://schema- Returns database product/version plus table and column metadata as JSON
JDBC configuration for the MCP server process:
JDBC_URLis requiredJDBC_USERNAMEis optionalJDBC_PASSWORDis optional
Bundled sample database:
mcp-server-jdbc/mcp-server-jdbc-common/src/test/resources/sqlite3.db
Build the MCP server jar first:
./mvnw -pl mcp-server-jdbc/mcp-server-jdbc-annotated-sdk -am package
On Windows PowerShell, use .\mvnw.cmd instead of ./mvnw.
The jar is created at:
mcp-server-jdbc/mcp-server-jdbc-annotated-sdk/target/mcp-server-jdbc-annotated-sdk.jar
Use these paths in the examples below:
<repo>- absolute path to this repository<jar>-<repo>/mcp-server-jdbc/mcp-server-jdbc-annotated-sdk/target/mcp-server-jdbc-annotated-sdk.jar<sqlite3.db>-<repo>/mcp-server-jdbc/mcp-server-jdbc-common/src/test/resources/sqlite3.db
For Windows paths in JSON/TOML, prefer forward slashes, for example C:/Users/me/code/mcp-java-sdk-examples/....
MCP Inspector
Start Inspector with the JDBC server as a STDIO server:
npx @modelcontextprotocol/inspector -e JDBC_URL=jdbc:sqlite:<sqlite3.db> -- java -jar <jar>
Open the Inspector URL printed in the terminal, then browse the db://schema resource.
Claude Desktop
Add the server to Claude Desktop MCP settings:
{
"mcpServers": {
"jdbc-mcp-server": {
"command": "java",
"args": ["-jar", "<jar>"],
"env": {
"JDBC_URL": "jdbc:sqlite:<sqlite3.db>"
}
}
}
}
Restart Claude Desktop, then browse the db://schema resource from the MCP tools/resources panel.
Codex
Add the server with the Codex CLI:
codex mcp add jdbc-mcp-server --env JDBC_URL=jdbc:sqlite:<sqlite3.db> -- java -jar <jar>
Or add it to ~/.codex/config.toml or a trusted project .codex/config.toml:
[mcp_servers.jdbc-mcp-server]
command = "java"
args = ["-jar", "<jar>"]
[mcp_servers.jdbc-mcp-server.env]
JDBC_URL = "jdbc:sqlite:<sqlite3.db>"
Cursor
Add this server in Cursor MCP settings:
{
"mcpServers": {
"jdbc-mcp-server": {
"command": "java",
"args": ["-jar", "<jar>"],
"env": {
"JDBC_URL": "jdbc:sqlite:<sqlite3.db>"
}
}
}
}
Cline
Open Cline MCP settings and add:
{
"mcpServers": {
"jdbc-mcp-server": {
"command": "java",
"args": ["-jar", "<jar>"],
"env": {
"JDBC_URL": "jdbc:sqlite:<sqlite3.db>"
}
}
}
}
VS Code
Create or update .vscode/mcp.json:
{
"servers": {
"jdbc-mcp-server": {
"type": "stdio",
"command": "java",
"args": ["-jar", "<jar>"],
"env": {
"JDBC_URL": "jdbc:sqlite:<sqlite3.db>"
}
}
}
}
For databases that require credentials, add them to the MCP server environment:
"env": {
"JDBC_URL": "jdbc:postgresql://localhost:5432/example",
"JDBC_USERNAME": "user",
"JDBC_PASSWORD": "password"
}
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found