Lightweight Java MCP SDK: AJ-MCP
LocalAbout Lightweight Java MCP SDK: AJ-MCP
AJ-MCP is a lightweight Java SDK for building MCP clients and servers. It targets existing systems that must stay on Java 8 or Spring Boot 2.x, with a small API built on Jackson and OkHttp.
Key features
- 01Supports Java 8 and later versions
- 02Supports STDIO, HTTP/SSE and Streamable HTTP transports
- 03Negotiates among several MCP protocol revisions
- 04Declares tools and features through annotations
Use cases
- 01Wrapping an existing Java service as MCP tools or prompts
- 02Adding MCP to a Spring Boot 2.x or Servlet application
- 03Connecting a Java desktop or server app to a local STDIO MCP process
MCP support
This project is an MCP SDK for building servers that expose capabilities to MCP clients and clients that connect to MCP servers.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEAJ-MCP
A Lightweight Java MCP SDK
AJ-MCP is a lightweight Model Context Protocol (MCP) SDK for Java. It provides a small, direct API for building MCP clients and servers, especially for existing systems that must remain on Java 8 or Spring Boot 2.x.
- Supports Java 8 and above, and supports Spring Boot 2.x.
- Lightweight and small, with Jackson JSON and OkHttp as its main runtime dependencies.
- Easy to use and extend, with examples and bilingual documentation.
- Supports STDIO, the legacy HTTP/SSE transport, and Streamable HTTP.
- Implements MCP protocol revisions
2024-11-05,2025-03-26, and2025-06-18with version negotiation. - Covers tools, resources, resource templates, prompts, completion, pagination, subscriptions, cancellation, logging, roots, sampling, and elicitation.
Check out these three projects of MCP SDK components:
The independent AJ MCP Next project targets 2026-07-28 on Java 8 using AJ Util.
It has core/client/server modules with STDIO and sessionless HTTP adapters, separate from this legacy SDK.
- AJ MCP Common, Common library for AJ-MCP, it contains the implementation of the Model Context Protocol and some other common classes.
- AJ MCP Client, MCP Client SDK.
- AJ MCP Server, MCP Server SDK.
- Samples for both client and server.
- Spring Streamable HTTP sample, with a dedicated
StreamableHttpClientExampleinsamples/client(Java 8).
For further information, please refer to the User Manual website.
When to use AJ-MCP
AJ-MCP is intended for Java applications that need to expose existing business capabilities to AI clients, or consume MCP servers without upgrading the entire application stack. Typical uses include:
- wrapping an existing Java service as MCP tools, resources, or prompts;
- connecting a Java desktop or server application to a local STDIO MCP process;
- integrating MCP into Spring Boot 2.x or a Servlet-based application;
- supporting clients that negotiate different MCP protocol revisions.
JSON-RPC batch messages are intentionally not supported.
Modules
| Module | Purpose | Current version |
|---|---|---|
aj-mcp-common | Shared JSON-RPC messages, MCP protocol models, content types, version metadata, and JSON utilities | 1.9 |
aj-mcp-client | Synchronous client API and STDIO, HTTP/SSE, and Streamable HTTP transports | 1.7 |
aj-mcp-server | Annotation-based feature discovery, request dispatch, errors, sessions, and server transports | 1.6 |
samples | STDIO, Spring Boot/SSE, and embedded Tomcat examples | — |
The client and server artifacts already depend on aj-mcp-common; applications normally add only the artifact they use.
Quick start
Expose a tool from a Java 8 server
Add the server dependency:
<dependency>
<groupId>com.ajaxjs</groupId>
<artifactId>aj-mcp-server</artifactId>
<version>1.6</version>
</dependency>
Declare a service and start it over STDIO:
@McpService
public class GreetingTools {
@Tool(description = "Greets a user")
public String greet(@ToolArg("name") String name) {
return "Hello, " + name;
}
}
public static void main(String[] args) {
FeatureMgr features = new FeatureMgr();
features.init("com.example.mcp");
McpServer server = new McpServer();
server.setFeatureMgr(features);
server.setServerConfig(new ServerConfig());
server.setTransport(new ServerStdio(server));
server.start();
}
Keep standard output reserved for JSON-RPC messages when using STDIO; send application logs to standard error or a log file. See the server README for tools, resources, prompts, and HTTP transports.
Connect from a Java client
<dependency>
<groupId>com.ajaxjs</groupId>
<artifactId>aj-mcp-client</artifactId>
<version>1.6</version>
</dependency>
try(McpClient client = McpClient.createStdioMcpClient("java", "-jar", "/path/to/mcp-server.jar")) {
client.listTools().forEach(tool ->System.out.println(tool.getName()));
String result = client.callTool("greet", "{\"name\":\"AJ-MCP\"}");
System.out.println(result);
}
Always close a client so its streams, HTTP connections, pending requests, worker threads, and optional child process are released. See the client README for HTTP transports and additional APIs.
Build from source
Use Maven with JDK 8 or JDK 17:
mvn test
To build only one module and its dependencies:
mvn -pl aj-mcp-client -am test
mvn -pl aj-mcp-server -am test
Why MCP?
The Model Context Protocol opens up exciting possibilities for building intelligent applications using your application data with your favourite programming language and framework. With AJ MCP Servers, you have a powerful foundation to create your own Java based servers that can bridge AI with any data source or system you can imagine.
Whether you want to connect to your favorite database, integrate with your company’s internal systems, or build something completely new - the sky truly is the limit! The simplicity of implementing MCP servers with AJ means you can focus on the creative aspects rather than the plumbing.
So what are you waiting for? Grab the code, fire up your IDE, and start building your own MCP server today. The future of AI-powered applications is here, and you can be part of shaping it!
Have Fun!
Links
User Manual | Github | Gitcode
Helpful links for MCP
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.