WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Building MCP Servers with Open Liberty: A Practical Guide

By Tatsuya Miyazaki posted 5 days ago

  

The Model Context Protocol (MCP) has rapidly gained adoption in 2025 as a foundational technology for AI agents. While MCP's official Java SDK provides implementation capabilities, servlet-based development can present a learning curve for developers. Open Liberty addresses this challenge with a new beta feature that enables MCP server creation using familiar JAX-RS-style annotations.

What is MCP?

MCP is a protocol that allows AI agents to interact with external tools and data sources. Instead of building custom integrations for each AI platform, developers can create MCP servers that expose tools through a standardized interface.

Open Liberty's Simplified Approach

Open Liberty's mcpServer-1.0 beta feature introduces annotation-based MCP server development. 
@Tool(
    name = "get-user", 
    title = "Get User Information",
    description = "Retrieve name and role for specified user ID")
public String getUser(
    @ToolArg(
        name = "userid",
        description = "Target user's ID"
    ) String userId) {
    return service.getUser(userId).toString();
}
Using the official MCP Java SDK would require an understanding of several complex components:
* Creating and configuring TransportProvider instances
* Defining server capabilities and metadata
* Implementing tool specifications manually
* Managing CallToolResult objects
This complexity adds development overhead, especially when scaling to enterprise applications.
Liberty's declarative style mirrors JAX-RS REST API development, making it immediately familiar to Java developers.

Sample Application: Library Management

To demonstrate Open Liberty's MCP capabilities, I've created a library management application that exposes the following tools through MCP:
  • Retrieve library rules
  • Get user information
  • Search book catalog
  • Check borrowing history
  • Process book loans
  • Handle book returns
  • Add new users
  • Reset database

The application uses MariaDB for data persistence and implements business rules through AI agent logic rather than hard-coded validation.

Getting Started

Downloading Open Liberty Beta

You can download the beta version from the official Open Liberty website. On this page, scroll down to the "Download package" section and select the latest beta from the Betas tab. At the time of writing, 26.0.0.1-beta is the latest version.

Once downloaded, extract the archive and place it in a directory of your choice. For this guide, we'll assume it's placed at c:\Projects\wlp.

Downloading the Sample Application

Download the sample application using the following Git command:

git clone https://github.com/tatsuya-ibm/library-mcp

Modifying the Sample Application

Update the following section in pom.xml:

<properties>
    (omitted)
    <wlp-dir-path>C:\projects\wlp</wlp-dir-path>
    <mcp-jar-version>1.0.108</mcp-jar-version>
</properties>
Property Value
wlp-dir-path Change to the directory where you extracted Open Liberty
mcp-jar-version

Update to match the library version included in the extracted folder (differs by beta version). The version is XXX in the JAR file: (extracted_folder)\dev\api\ibm\io.openliberty.mcp_XXX.jar

Starting MariaDB

Start the MariaDB container:

podman run -d --name maria01 -e MYSQL_ROOT_PASSWORD=rootpwd -e MYSQL_DATABASE=db01 -e MYSQL_USER=usr01 -e MYSQL_PASSWORD=pwd01 -p 3306:3306 mariadb:latest

Starting the MCP Server

In the directory where you extracted the sample application, execute the startup command in PowerShell. Table definitions and test data insertion into the database occur automatically at startup.

./mvnw liberty:dev

Connecting to AI Agents

Register this MCP server in your available local AI agent tools. Here is a configuration example using Goose:

  • Navigate to Extensions > Add Custom extension
  • Configure with the following values
    • Type: Streamable HTTP
    • Endpoint: http://localhost:9080/librarymcp/mcp

AI Agent Interaction with the Library Application

Once connected, the AI agent can operate the library application autonomously. The following examples demonstrate how the agent interprets natural language requests and orchestrates tool calls without explicit programming.

Understanding Library Rules

The AI agent selects the appropriate tool based on the instruction and retrieves the library rules without being told which specific tool to use.

Book Recommendations

The agent orchestrates multiple tool calls in the proper sequence:

  1. Retrieves borrowing history
  2. Extracts categories from past loans
  3. Searches catalog using those categories as parameters
  4. Filters out previously borrowed titles
  5. Ranks by rating and returns top three

Checking Book Availability

Rather than calling a dedicated "check availability" tool, the AI gathers information needed to evaluate business rules and makes an autonomous decision. The book is currently borrowed by another user, so the agent correctly determines it cannot be loaned out. This demonstrates how AI handles rule logic that would traditionally require hard-coded validation.

Processing a Loan

The agent performs validation checks similar to the previous example. Finding no issues, it proceeds to execute the loan transaction. This showcases how MCP tools enable data modification operations that traditional RAG approaches cannot handle.

Returning a Book

The return process requires a rating parameter, which the user didn't provide. The agent recognizes the missing information, asks the user for the rating, and then completes the return transaction.
This section demonstrates three key capabilities:
 
  • Autonomous tool selection - The AI chooses appropriate tools based on natural language
  • Business rule interpretation - Rules defined in natural language are evaluated by AI rather than hard-coded logic
  • Data modification - Unlike RAG systems, MCP enables write operations and transaction processing

Conclusion

We confirmed that MCP implementation is easily achievable with Open Liberty and that the collaboration between AI agents and Java applications can provide new user experiences.

0 comments
1 view

Permalink