A Spring Boot application demonstrating a Medical Care Platform (MCP) with AI tool integration via the Model Context Protocol. This project manages patients and their medical reports, and exposes AI-enabled service methods for use in AI workflows and assistants like Claude Desktop.
This project is a well-structured Spring Boot application for a Medical Care Platform (MCP) with AI tool integration via MCP. It features:
- JPA entities for
Patient
andMedicalReport
- DTOs for clean data transfer
- Service layer with MCP tool annotations
- Spring Data JPA repositories
- Example data initialization
- Ready for extension and AI integration
- Patient and Medical Report management using JPA entities and repositories
- DTOs for clean data transfer
- Service layer with AI tool annotations for Model Context Protocol (MCP) integration
- RESTful structure, ready for extension
- Example data initialization for quick start
src/
main/
java/
com/springai_mcp/
SpringAiMcpApplication.java
dto/PatientDTO.java
entity/Patient.java, MedicalReport.java
repository/PatientRepository.java, MedicalReportRepository.java
service/MedicalService.java
resources/
application.properties
test/
java/
com/springai_mcp/SpringAiMcpApplicationTests.java
- Entities:
Patient
andMedicalReport
are JPA entities with relationships. - DTOs:
PatientDTO
is used for transferring patient data. - Repositories: Standard Spring Data JPA repositories for CRUD operations.
- Service:
MedicalService
provides business logic and is annotated for AI tool integration using MCP. - Main Application: Registers tool callbacks for AI workflows, making service methods available to AI agents.
-
Build:
Run./mvnw clean install
(ormvnw.cmd
on Windows). -
Run:
Execute./mvnw spring-boot:run
or run the generated JAR intarget/
. -
Test:
Run./mvnw test
to execute unit tests.
- Add more services and annotate methods with
@Tool
for MCP/AI integration. - Register additional services in
SpringAiMcpApplication
as tool callbacks.
Example Tool Registration:
@Bean
public List<ToolCallback> medicalTools(MedicalService medicalService, AnotherService anotherService) {
return List.of(
ToolCallbacks.from(medicalService),
ToolCallbacks.from(anotherService)
);
}
Use these prompts in Claude Desktop (or any MCP-compatible AI agent) to interact with the Spring AI MCP app:
- "List all patients."
- "Get information about patient named John Doe."
- "Show all medical reports for patient ID 1."
- "Add a new medical report for patient ID 2 with diagnosis 'Diabetes' and content 'Patient diagnosed with Type 2 Diabetes.'"
- "Update medical report ID 3 with diagnosis 'Recovered' and content 'Patient has fully recovered.'"
- "Who are the patients born after 1990?"
- "Add a female patient named Jane Smith, born on 1990-08-22."
You can customize these prompts based on the tool methods exposed by your services.
To use your Spring AI MCP server with Claude Desktop, follow these steps:
-
Build and Start the MCP Server
- Open a terminal in your project directory.
- Run the following command to build and start the server:
Or, run the JAR directly:
./mvnw clean install ./mvnw spring-boot:run
java -jar target/spring-ai-mcp.jar
-
Configure Claude Desktop
-
Open Claude Desktop.
-
Go to the settings or integrations section.
-
Add a new MCP server/tool integration.
-
For the server command, use:
java -jar D:/AI_ML/Spring-AI-MCP/spring-ai-mcp/target/spring-ai-mcp.jar
(Adjust the path if your JAR is elsewhere.)
-
If Claude Desktop asks for a config file, use the provided
claude_desktop_config.json
:{ "mcpServers": { "spring-ai-mcp-server": { "command": "java", "args": [ "-jar", "D:/AI_ML/Spring-AI-MCP/spring-ai-mcp/target/spring-ai-mcp.jar" ] } } }
-
-
Test the Connection
- In Claude Desktop, select the Spring AI MCP tool.
- Try example prompts such as:
- "List all patients."
- "Add a new medical report for patient ID 2 with diagnosis 'Diabetes'."
-
Extend and Customize
- Add more annotated service methods in your Spring Boot app for new capabilities.
- Register additional services in
SpringAiMcpApplication
as tool callbacks.
Refer to your AI agent’s documentation for details on adding and configuring external tools.
MIT