Skip to content

Commit 8d0f42c

Browse files
committed
Refactor examples to JDBC MCP server
1 parent 7adf096 commit 8d0f42c

59 files changed

Lines changed: 847 additions & 4079 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ root = true
44
charset = utf-8
55
end_of_line = lf
66
insert_final_newline = true
7-
trim_trailing_whitespace = true
7+
trim_trailing_whitespace = true
8+
9+
[*.java]
10+
ij_java_names_count_to_use_import_on_demand = 65535
11+
ij_java_class_count_to_use_import_on_demand = 65535
12+
ij_java_packages_to_use_import_on_demand = unset

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text eol=lf
2+
3+
*.bat text eol=crlf
4+
*.cmd text eol=crlf

.gitignore

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77

88
# Maven build files
99
target/
10-
dependency-reduced-pom.xml
1110

12-
# FastAgent files
13-
fastagent.secrets.yaml
14-
fastagent.config.yaml
15-
fastagent.jsonl
16-
17-
# Python build files
18-
build/
19-
*.egg-info/
11+
# Test files
12+
*.db
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
wrapperVersion=3.3.4
2+
distributionType=only-script
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.16/apache-maven-3.9.16-bin.zip

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 https://github.com/codeboyzhou <imzhouchen@gmail.com>
3+
Copyright (c) 2025 https://github.com/thought2code
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,43 @@
1-
# MCP Server Examples
1+
# MCP Java SDK Examples
22

3-
A collection of MCP examples developed by various SDKs. As of now, the following SDKs are supported.
4-
5-
- [Declarative MCP Java SDK](https://github.com/codeboyzhou/mcp-declarative-java-sdk) (lightweight and easier to use)
6-
- [Official MCP Java SDK](https://github.com/modelcontextprotocol/java-sdk)
7-
- [Spring AI MCP SDK](https://docs.spring.io/spring-ai/reference/api/mcp/mcp-server-boot-starter-docs.html)
3+
A collection of MCP examples developed with Java SDKs.
84

95
## Requirements
106

11-
- Java 17 or later (Restricted by MCP Java SDK)
7+
- Java 17 or later
8+
- Maven 3.9.16 or the included Maven Wrapper
129

1310
## What is MCP?
1411

15-
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) lets you build servers that expose data and functionality to LLM applications in a secure, standardized way. Think of it like a web API, but specifically designed for LLM interactions. MCP servers can:
12+
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) lets servers expose data and functionality to LLM applications in a standardized way. MCP servers can expose resources, tools, prompts, and more.
1613

17-
- Expose data through **Resources** (think of these sort of like GET endpoints; they are used to load information into the LLM's context)
18-
- Provide functionality through **Tools** (sort of like POST endpoints; they are used to execute code or otherwise produce a side effect)
19-
- Define interaction patterns through **Prompts** (reusable templates for LLM interactions)
20-
- And more!
14+
## Examples
2115

22-
You can start exploring everything about **MCP** from [here](https://modelcontextprotocol.io).
16+
- [JDBC Server](mcp-server-jdbc) - Exposes JDBC database metadata through an MCP resource
2317

24-
## Examples
18+
## JDBC Server
19+
20+
The JDBC example currently includes an annotated-sdk implementation backed by SQLite.
21+
22+
Implemented resource:
23+
24+
- `db://schema` - Returns database product name and version as JSON
25+
26+
Default database configuration:
27+
28+
- `JDBC_URL` defaults to `jdbc:sqlite:./test.db`
29+
- `JDBC_USERNAME` is optional
30+
- `JDBC_PASSWORD` is optional
31+
32+
Run the server:
2533

26-
If you are looking for servers implemented with Typescript MCP SDK or Python MCP SDK, see [here](https://github.com/modelcontextprotocol/servers).
34+
```powershell
35+
.\mvnw.cmd -pl mcp-server-jdbc/mcp-server-jdbc-annotated-sdk -am compile exec:java -Dexec.mainClass=com.github.thought2code.mcp.server.jdbc.annotated.JdbcMcpServer
36+
```
2737

28-
These servers aim to demonstrate MCP features and the MCP Java SDK.
38+
Run with a custom SQLite database:
2939

30-
- [Filesystem](https://github.com/codeboyzhou/mcp-java-sdk-examples/blob/main/mcp-server-filesystem/README.md) - Secure file operations with configurable access controls
40+
```powershell
41+
$env:JDBC_URL = "jdbc:sqlite:C:\path\to\database.db"
42+
.\mvnw.cmd -pl mcp-server-jdbc/mcp-server-jdbc-annotated-sdk -am compile exec:java -Dexec.mainClass=com.github.thought2code.mcp.server.jdbc.annotated.JdbcMcpServer
43+
```

agent/agent.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

agent/fastagent.config.yaml.example

Lines changed: 0 additions & 36 deletions
This file was deleted.

agent/fastagent.secrets.yaml.example

Lines changed: 0 additions & 11 deletions
This file was deleted.

agent/pyproject.toml

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)