springaimcpserverdemo

mni9840/springaimcpserverdemo

3.1

If you are the rightful owner of springaimcpserverdemo and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This document provides a structured summary of a Model Context Protocol (MCP) server implemented using the Spring AI framework, designed to expose tools for use by external LLM Chat Bots/LLM.

Tools
1
Resources
0
Prompts
0

An example of Java MCP server implementation using Spring AI framework for exposing tools to be used by external LLM Chat Bots/LLM.

Pre-req: Java 17

Steps:

  1. Downlaod project from repo.
  2. Get a free key from https://financialmodelingprep.com
  3. Add the key in application.properties. Better to use environment variable and read the value from there.
  4. Build the server: /mvnw clean install It will create the JAR in target prohect folder
  5. Run Spring Boot application (MCP server) from terminal: java -jar /ADD/COMPLETE/PATH/TO/JAR/springaimcpserverdemo/target/springaimcpserverdemo-0.0.1-SNAPSHOT.jar

Should see the following in terminal:

2025-08-22T15:32:16.173-04:00 INFO 3202 --- [springaimcpserverdemo] [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port 8081 (http)

2025-08-22T15:32:16.270-04:00 INFO 3202 --- [springaimcpserverdemo] [ main] c.e.s.service.MCPToolProviderService : MCPToolService initialized with stock API Base URI: https://financialmodelingprep.com/stable and API Key: ZJdQVjTqaaozdTTdFTQhzDbGEyN7xjMr 2025-08-22T15:32:16.443-04:00 INFO 3202 --- [springaimcpserverdemo] [ main] o.s.a.m.s.a.McpServerAutoConfiguration : Enable tools capabilities, notification: true 2025-08-22T15:32:16.468-04:00 INFO 3202 --- [springaimcpserverdemo] [ main] o.s.a.m.s.a.McpServerAutoConfiguration : Registered tools: 1 2025-08-22T15:32:16.468-04:00 INFO 3202 --- [springaimcpserverdemo] [ main] o.s.a.m.s.a.McpServerAutoConfiguration : Enable resources capabilities, notification: true 2025-08-22T15:32:16.468-04:00 INFO 3202 --- [springaimcpserverdemo] [ main] o.s.a.m.s.a.McpServerAutoConfiguration : Enable prompts capabilities, notification: true 2025-08-22T15:32:16.468-04:00 INFO 3202 --- [springaimcpserverdemo] [ main] o.s.a.m.s.a.McpServerAutoConfiguration : Enable completions capabilities 2025-08-22T15:32:16.492-04:00 INFO 3202 --- [springaimcpserverdemo] [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8081 (http) with context path '/' 2025-08-22T15:32:16.499-04:00 INFO 3202 --- [springaimcpserverdemo] [ main] c.e.s.SpringaimcpserverdemoApplication : Started SpringaimcpserverdemoApplication in 0.826 seconds (process running for 0.993)

Above logs show that MCP server is running at 8081 port exposing endpoint: /sse It also indicates that there is 1 tool added in the server implementation which retrives stock price information form the external site to provide relevant context to external LLM.

  1. Let's test the MCP server running. Access endpoint from postman or browser: http://localhost:8081/sse

Response was:

/mcp/message?sessionId=43beb537-299c-4bc7-88fd-dd79db452516 Connected to http://localhost:8081/sse

So, we have successfully started a MCP server with 1 tool and it's ready to serve external LLM based on requests made from external MCP client. We will implement MCP client in another repo (springmcpclientdemo).