Introduction
In the part 1 of this series, we introduced Spring AI and it's concepts by building the conference tool application using Amazon Bedrock Converse API and used it to the model using natural language.
In this part of the series, we'll run Model Context Protocol (MCP) server with the defined tools and use Model Context Protocol Inspector and Amazon Q Developer plugin in the Visual Studio Code as MCP clients to list the available tools and to talk to our application using natural language for searching for the conferences by topic and start date range. We'll first focus on the STDIO transport protocol and explore the Server-Sent Events (SSE) later.
Sample Application
Let's spend some words explaíning Model Context Protocol (MCP). MCP is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you're building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need.
Spring AI offers MCP support for the Client and Server. We'll focus on the MCP Server support in this article. Let's go to Spring Initializr to create our demo project. I added 2 dependencies:
- Spring Web
- Model Context Protocol Server
fill some other data (I selected Maven, Java 21 support and Java packaging):
Then I generated the artifact. You can find this sample application as spring-mcp-conference-search in my GitHub account.
The relevant dependencies in the pom.xml are those:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
</dependency>
The Spring AI MCP Server Boot Starter provides auto-configuration for setting up an MCP server in Spring Boot applications. It enables seamless integration of MCP server capabilities with Spring Boot’s auto-configuration system.
The MCP Server Boot Starter offers:
- Automatic configuration of MCP server components
- Support for both synchronous and asynchronous operation modes
- Multiple transport layer options
- Flexible tool, resource, and prompt specification
- Change notification capabilities
We'll first focus on the STDIO transport and use Server-Sent Events (SSE) in the next article of this series.
Global configuration is provided in the application.properties file:
spring.application.name=spring-mcp-conference-search
spring.main.web-application-type=none
spring.ai.mcp.server.stdio=true
spring.ai.mcp.server.name=spring-mcp-conference-search
spring.ai.mcp.server.version=0.0.1
# Disable banner and logging for STDIO transport
spring.main.banner-mode=off
logging.level.root=OFF
Please uncomment everything related to the STDIO or copy the whole configuration from the application-stdio.properties. Here we define that we use STDIO transport protocol and that's why we need to disable banner and logging to the console,as we don't run any server on our own.
We'll re-use the ConferenceSearchTool from part 1 and that's why we copied the classes and other files listed below. Please refer to the explanations in the part 1, especially what the tools are and how to implement them.
- Conference
- Conferences
- ConferenceSearchTool. I refactored it a bit to provide 3 tools: All_Conference_Search_Tool, Conference_Search_Tool_By_Topic and Conference_Search_Tool_By_Topic_And_Date
- conferences.json
Now we only need to expose the tools defined in the ConferenceSearchTool to the MCP server. We can do it by defining a bean in the Java class annotated with @SpringBootApplication, see SpringMcpConferenceSearchApplication :
@Bean
public List<ToolCallback> conferenceSearchTools(ConferenceSearchTool conferenceSearchTool) {
return List.of(ToolCallbacks.from(conferenceSearchTool));
}
We inject the instance of the ConferenceSearchTool and use it to create org.springframework.ai.tool.ToolCallbacks list (of course you can pass multiple tools as an argument):
We're done with the implementation (it's that simple), so let's now build the application with mvn clean package
.
Let's first use MCP Inspector to inspect our tools. To run it, we need npx to be installed which is generally automatically installed with the newer version of the Node.js. Then we need to execute npx @modelcontextprotocol/inspector
. It may take some time to install modelcontextprotocol/inspector in case it's not there, but after it it will run locally and the default browser opens automatically. Please select STDIO as a transport type, java as a command and -jar {PATH_TO_YOUR_JAR_FILE}' For my case on Windows it's -jar C:\source-code-java\SpringAIWithAmazonBedrock\spring-mcp-conference-search\target\spring-mcp-conference-search-0.0.1-SNAPSHOT.jar. Please don't forget to use \\ to escape the \.
Overall it looks like this :
Then press the "Connect" button. In case we're are successfully connected it should look like this:
Then we can go to the "Tools" section and list the tools:
We see all our 3 tools listed there:
There is no LLM involved, so we need to select the tool and manually enter the required parameters and then hit the "Run Tool" button:
We see that our tools are in place. Let's now use Amazon Q Developer and its MCP Client to talk to our MCP server using natural language. You can use Claude Desktop or Cursor or others instead.
Amazon Q Developer is a generative artificial intelligence (AI) powered conversational assistant that can help you understand, build, extend, and operate AWS applications. You can ask questions about AWS architecture, your AWS resources, best practices, documentation, support, and more. Amazon Q is constantly updating its capabilities so your questions get the most contextually relevant and actionable answers. You can use Amazon Q Developer in the CLI or how we'll do it as Visual Studio Code plugin. The reason for that is mainly that I use Windows, and it's not trivial to install Amazon Q Developer CLI on Windows.
The following Anthropic models are currently available for chat sessions:
- Claude 3.7 Sonnet (default)
- Claude Sonnet 4
We first need to configure a MCP server. Click on "Configure MCP Server" :
Then click on "Add new MCP Server" :
It works the same as with the MCP inspector. You have to provide server name, protocol (STDIO) and command arguments :
Alternatively you can adjust and copy the content of the mcp-stdio.json file which in my case looks like this:
{
"mcpServers": {
"conference-search-tool": {
"command": "java",
"args": [
"-jar",
"C:\\source-code-java\\SpringAIWithAmazonBedrock\\spring-mcp-conference-search\\target\\spring-mcp-conference-search-0.0.1-SNAPSHOT.jar"
]
}
}
}
into your .aws\amazonq\mcp.json file and configuration will be loaded from there automatically. Don't forget to adjust the arguments (path to the application jar file).
In both cases MCP server should be recognized:
Now let's chat with our application exposed as a MCP server. We first select Claude Sonnet 4 as the model to be used for chatting. It's also important to ensure that the access to the model in use is enabled in the Amazon Bedrock. You can check it and enable access to the model on the Amazon Bedrock Model access page :
When we ask to provide the overview of the available conferences:
LLM correctly suggested using All_Conference_Search_Tool tool for that. We confirm it by clicking on "Run" and get correctly all 10 conferences back as a result:
Let's ask to provide an overview of the conferences with the Java topic. The same story: Conference_Search_Tool_By_Topic tool was correctly identified to do the job and by confirming it 2 Java conferences correctly appeared in the response:
Let's ask to provide the list of AWS conferences taking place between today and December 10, 2025. And here we go : Conference_Search_Tool_By_Topic_And_Date tool was correctly identified 2 conferences were delivered as a response:
Claude Sonnet 4 could figure out what the date is today, as we didn't provide the tool for that. But was this date correct? Let's ask to provide the list of AWS conferences taking place in the next 6 months starting from today.
Ok, the date for "now" was indeed wrong (the date I did this was August 8, 2025), so we need to be careful when providing such instructions and put the conference start date explicitly instead of saying "now". But LLM could correctly add 6 months to the date without explicitely providing the calculator tool.
Now let's change the date range and ask to provide the list of AWS conferences taking place between November 30 and December 10, 2025. Only one (Re:Invent) correctly remained and the Serverless Days Sao Paolo is not in the list (it takes place on November 8, 2025).
Now let's ask the following question: "I live in Bonn, Germany. Please provide me with the list of the conferences with the Java topic taking place between November 9, 2025 and April 13, 2026 in the city where I live or nearby."
Brilliant stuff! Claude Sonnet 4 was able to figure out 2 things: there is no conference in Bonn, but 1 (JCON) in Cologne which is nearby and even provided the information that Cologne is only 20-30 away by train from Bonn (which is true). Moreover the conference takes place a bit outside of the date range I asked for (7 days) and LLM pointed out to this fact. Claude Sonnet 4 is a really powerful model.
There is more to explore here and we only used one tool (or a list of the related conference tools). The real-world applications are more powerful and make use of multiple and completely different tools. But you got the idea.
Conclusion
In this part of the series, we ran Model Context Protocol (MCP) server with the defined tools and used Model Context Protocol Inspector and Amazon Q Developer plugin in the Visual Studio Code as MCP clients to list the available tools. We also talked to our application using natural language to search for the conferences by topic and start date range. We focused on the STDIO transport protocol.
In the next part of the series, we'll explore MCP Server-Sent Events (SSE) transport protocol. With SSE we can expose our application as MCP Server to be accessible for everybody.
Top comments (0)