Skip to content

AI-powered chat assistant for banking microservices using Spring AI and Model Context Protocol (MCP). Interact with your microservices through natural language chat, view accounts, personal details, and transactions—all in one unified interface.

Notifications You must be signed in to change notification settings

rifatcakir/spring-ai-mcp

Repository files navigation

# Spring 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

  1. Clone the repository:
git clone https://github.com/yourusername/spring-ai-mcp.git
cd spring-ai-mcp
  1. Build the project:
mvn clean install
  1. 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:

  1. Each microservice (person, account, transaction) implements the Model Context Protocol (MCP)
  2. 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

  1. Access the chat interface through the chat-client application
  2. Type your request in natural language
  3. 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

Sample: Show personal details for John Smith

The user requests personal details for John Smith. The assistant provides the ID, first name, and last name.

2. Querying Accounts for a Person

Sample: Show accounts for John Smith

The user asks to see accounts belonging to John Smith. The assistant lists all accounts with their balances.

3. Viewing Transactions for Accounts

Sample: Show 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

  1. Create a new module in the project
  2. Implement the MCP protocol
  3. Add the module to the parent pom.xml
  4. 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

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. 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.

About

AI-powered chat assistant for banking microservices using Spring AI and Model Context Protocol (MCP). Interact with your microservices through natural language chat, view accounts, personal details, and transactions—all in one unified interface.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published