Java Now Speaks Model Context Protocol
Written by Nikos Vaggalis   
Tuesday, 18 February 2025

The Java SDK implementation of the Model Context Protocol gets to pre-release version 0.70, opening the way for Java to enjoy transparent interoperability with AI services.

The official Java SDK is actually the same as Spring AI MCP which is now deemed mature enough to become Java's official SDK. The Model Context Protocol (MCP) is of course an open protocol developed by Anthropic, which enables seamless integration with language models and AI tools from a variety of programming languages. The protocol is already picking up steam quickly as it can be used to build a variety of applications:

  • Search the web with AI
  • Research
  • Query and analyze databases directly
  • Navigate websites, fill forms, and capture screenshots programmatically

At its core, MCP follows a client-server architecture where a host application can connect to multiple servers, with MCP Servers being lightweight programs that each expose specific capabilities through the standardized Model Context Protocol. Thus they function as the standardized interface and the foundational layer for Large Language Models (LLMs) to interact with data sources, tools, and AI agents.

Examples of MCP servers:

Filesystem MCP Server
Node.js server implementing Model Context Protocol (MCP) for filesystem operations.

SQLite MCP Server
Provides database interaction and business intelligence capabilities through SQLite. This server enables running SQL queries, analyzing business data, and automatically generating business insight memos.

Time MCP Server
Provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.

Sequential Thinking MCP Server
Provides for dynamic and reflective problem-solving through a structured thinking process.

As far as clients who consume those services offered by the servers goes, there's :

Claude Desktop
The original MCP-compatible client, powered by Anthropic's. It works much like the web-based Claude.ai, but is additionally compatible with local (stdio-based) MCP servers. Useful for generalist use cases to interface with knowledge or the web at large. MCP features supported: Resources, Prompts, Tools.

Cline
Autonomous coding agent right in your IDE, capable of creating/editing files, executing commands, using the browser, and more with your permission every step of the way. MCP features supported: Resources, Tools.

Windsurf IDE
An agentic IDE.

etc

Now back to Java. The initial Spring AI MCP project began just last November as the offspring of a collaboration between Anthropic and the Spring team. While it initially was labeled as experimental, it deemed so good that it finally turned out in the official Java sdk.

The main components of the MCP SDK aside, Server and Client, there's two more :

  • Session Layer (McpSession) which Manages communication patterns and state using DefaultMcpSession implementation

    and the

  • Transport Layer (McpTransport) which Handles JSON-RPC message serialization/deserialization via: StdioTransport (stdin/stdout) in the core module HTTP SSE transports in dedicated transport modules (Java HttpClient, Spring WebFlux, Spring WebMVC)

The SDK supports both synchronous and asynchronous APIs, allowing for flexible integration in different application contexts. For instance to create a server with custom configuration and the sync api :

McpSyncServer syncServer = McpServer.sync(transport)
.serverInfo("my-server", "1.0.0")
.capabilities(ServerCapabilities.builder()
.resources(true) // Enable resource support
.tools(true) // Enable tool support
.prompts(true) // Enable prompt support
.logging() // Enable logging support
.build())
.build();4

// Initialize the server
syncServer.initialize();

to create server with custom configuration and the async api :

McpAsyncServer asyncServer = McpServer.async(transport)
.serverInfo("my-server", "1.0.0")
.capabilities(ServerCapabilities.builder()
.resources(true) // Enable resource support
.tools(true) // Enable tool support
.prompts(true) // Enable prompt support
.logging() // Enable logging support
.build())
.build();

// Initialize the server
asyncServer.initialize()
.doOnSuccess(v -> logger.info("Server initialized"))
.subscribe();


Of course the clients too have to support the relevant api.

To get started, there's a great demo application showcasing the integration of Spring AI with SQLite databases using the Model Context Protocol (MCP) which enables natural language interactions with SQLite databases through a command-line interface. It uses the SQLite MCP-Server to enable running SQL queries, analyzing business data, and automatically generating business insight memos.

The MCP Java SDK comes at the right time when, as highlighted by the recent Azure Survey that we covered in Where's Java Going In 2025?, Java aims to compete with Python in enterprise settings that incorporate AI. The new SDK is certainly going to drive adoption of Java further.

springlogo

More Information

Announcing Spring AI MCP: A Java SDK for the Model Context Protocol

Introducing the Model Context Protocol Java SDK

MCP Java SDK 

Related Articles

Where's Java Going In 2025?   

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Artists Opposed To Auction Of AI-Augmented Artworks
16/02/2025

This week Christie's is running its inaugural AI art auction. With the title Augmented Intelligence, it is billed as the first ever artificial intelligence-dedicated sale at a major auction  [ ... ]



Google Slashes Code Migration Time With Gemini
22/01/2025

Google computer scientists have given details of the way in which Google is using AI to dramatically reduce the time required for code migrations. In the case of a switch between two Java time librari [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Wednesday, 19 February 2025 )