mcpField
L
Lightweight Java MCP SDK: AJ-MCP

Lightweight Java MCP SDK: AJ-MCP

Local
mcp.ajaxjs.comDeveloper Tools35Updated 4w ago

About 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

  1. 01Supports Java 8 and later versions
  2. 02Supports STDIO, HTTP/SSE and Streamable HTTP transports
  3. 03Negotiates among several MCP protocol revisions
  4. 04Declares tools and features through annotations

Use cases

  1. 01Wrapping an existing Java service as MCP tools or prompts
  2. 02Adding MCP to a Spring Boot 2.x or Servlet application
  3. 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.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

AJ-MCP

A Lightweight Java MCP SDK

License: GPL v3 GitHub code size in bytes GitHub repo size Ask DeepWiki Email 中文


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, and 2025-06-18 with 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.

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

ModulePurposeCurrent version
aj-mcp-commonShared JSON-RPC messages, MCP protocol models, content types, version metadata, and JSON utilities1.9
aj-mcp-clientSynchronous client API and STDIO, HTTP/SSE, and Streamable HTTP transports1.7
aj-mcp-serverAnnotation-based feature discovery, request dispatch, errors, sessions, and server transports1.6
samplesSTDIO, 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

Awesome MCP Servers | TypeScript SDK | MCP Documentation

Comments

Markdown supported

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.