Now, the situation of developing MCP in Java is:
frame | JDK requirements |
---|---|
mcp-sdk | Need jdk17+ |
spring-ai-mcp-server | Requires jdk17 + |
spring-ai-mcp-client | Requires jdk17 + |
langchain4j-mcp-client | Need jdk17+ |
solon-ai-mcp-server | jdk8 + |
solon-ai-mcp-client | jdk8 + |
When I was communicating with people in the issue of the mcp-sdk warehouse. Someone once said that it is now the era of ia, how can we still use java8? However, MCP is a protocol framework that should be more universal and should take care of broader market demand.
The market situation is that (especially in our country) there are also a large number of jdk8 servers. Therefore, MCP (or MCP Server) can be developed using Java8, and this is MCP freedom!
Solon AI MCP (a dependency package)
Java AI (Agencies) Full-scene application development framework (supports various capabilities known to AI development. For example: LLM, Function Call, RAG, Embedding, Reranking, Flow, MCP Server, Mcp Client). It also supports java8, java11, java17, and java21.
Can be integrated with Solon or embedded in SpringBoot2, jFinal, and other frameworks.
Solon AI MCP Server Example (Supports Multi-Endpoints)
Here is an example of a Mcp tool service that checks the weather.
- Component construction (like MVC development)
@McpServerEndpoint(name="mcp-case1", sseEndpoint = "/case1/sse")
public class McpServerTool {
@ToolMapping(description = "Query weather forecast")
public String getWeather(@ToolParam(description = "City Location") String location) {
return "Sunny, 14 degrees";
}
}
- Native Java construction
McpServerEndpointProvider serverEndpoint = ()
.name("mcp-case2")
.sseEndpoint("/case2/sse")
.build();
(new MethodToolProvider(new McpServerTool()));
();
Solon AI MCP Client Example
McpClientToolProvider clientToolProvider = ()
.apiUrl("http://localhost:8080/case1/sse")
.build();
String rst = ("getWeather", ("location", "Hangzhou"));