About Spring Ai Mcp
Spring Ai Mcp is a Spring AI and MCP chat example for interacting with person, account, and transaction microservices through natural language. It combines a chat client with multiple MCP services and maintains context across interactions.
Key features
- 01Natural-language service interaction
- 02Unified chat interface
- 03Real-time communication with multiple services
- 04Support for adding microservices
- 05Context across chat interactions
Use cases
- 01Retrieve personal details
- 02View a person's accounts and balances
- 03Query transactions for accounts
MCP support
The person, account, and transaction microservices implement MCP. The Spring AI chat client converts natural-language requests into calls to the relevant services.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMESpring AI MCP (Model Context Protocol)
This project demonstrates how to implement a chat-based interface for communicating with microservices using Spring AI and MCP (Model Context Protocol). The system allows users to interact with various microservices through natural language chat, making it easier to perform operations across different services by providing contextual understanding and model-driven interactions.
Project Structure
The project consists of the following components:
- chat-client: A Spring Boot application that provides the chat interface for users to interact with microservices
- person-mcp-service: Microservice for managing person-related operations
- account-mcp-service: Microservice for handling account-related operations
- transaction-mcp-service: Microservice for processing transaction-related operations
Prerequisites
- Java 21
- Maven 3.8+
- Spring Boot 3.5.0
- Spring AI 1.0.0
Getting Started
- Clone the repository:
git clone https://github.com/yourusername/spring-ai-mcp.git
cd spring-ai-mcp
- Build the project:
mvn clean install
- Start the services:
# Start each service in separate terminals
mvn spring-boot:run -pl person-mcp-service
mvn spring-boot:run -pl account-mcp-service
mvn spring-boot:run -pl transaction-mcp-service
mvn spring-boot:run -pl chat-client
Architecture
The project follows a microservices architecture where:
- Each microservice (person, account, transaction) implements the Model Context Protocol (MCP)
- The chat client uses Spring AI to:
- Process natural language input
- Convert user requests into appropriate model context calls
- Handle responses from microservices
- Present results in a user-friendly format
- Maintain context across multiple interactions
Features
- Natural language processing for service interactions
- Unified chat interface for all microservices
- Real-time communication with multiple services
- Seamless integration of new microservices
Usage
- Access the chat interface through the chat-client application
- Type your request in natural language
- The system will:
- Parse your request
- Identify the relevant microservice(s)
- Execute the necessary operations
- Return the results in a conversational format
Sample Chat Interactions
Below are some example conversations with the AI Assistant, demonstrating how the Model Context Protocol enables seamless, contextual banking operations through chat:
1. Viewing Personal Details
The user requests personal details for John Smith. The assistant provides the ID, first name, and last name.
2. Querying Accounts for a Person
The user asks to see accounts belonging to John Smith. The assistant lists all accounts with their balances.
3. Viewing Transactions for Accounts
The user asks to see transactions for the previously listed accounts. The assistant responds with account and transaction details, maintaining context from earlier messages.
Development
Adding a New Microservice
- Create a new module in the project
- Implement the MCP protocol
- Add the module to the parent pom.xml
- Update the chat client to handle the new service's operations
Configuration
Each service can be configured through its respective application.properties or application.yml file. Common configurations include:
- Service ports
- Database connections
- AI model settings
- Model Context Protocol settings
- Context management parameters
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support, please open an issue in the GitHub repository or contact the development team.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.