feat: expand MCP server functionality with customer, catalogue, marketing, and user tools and integrate new health indicators and configuration models.
This commit is contained in:
@@ -14,6 +14,7 @@ Technology Stack: Java 25, Spring Boot 4.x, Spring AI 2.x, Spring WebSocket (STO
|
||||
## 1. Primary Roles & Responsibilities
|
||||
|
||||
`loyalty-agent` acts as the **BFF (Backend-For-Frontend)** and **AI Orchestration Layer**:
|
||||
|
||||
- **BFF & WebSocket Server**: Manages WebSocket/STOMP connections with the Frontend (`src/`), receiving chat requests and streaming LLM responses back to the UI in real time.
|
||||
- **AI Orchestrator**: Interacts with the Ollama LLM (`qwen3.5:4b`) via Spring AI `ChatClient`, routing user queries, managing prompt templates, and handling conversation state.
|
||||
- **MCP Client**: Connects to `loyalty-mcp-server` via the MCP SSE protocol (`http://localhost:9331/sse`) to dynamically load and invoke loyalty business tools.
|
||||
@@ -24,17 +25,20 @@ Technology Stack: Java 25, Spring Boot 4.x, Spring AI 2.x, Spring WebSocket (STO
|
||||
## 2. Protocol & Real-time Chat Messaging Flow (WebSocket STOMP)
|
||||
|
||||
### WebSocket Configuration (`config/WebSocketConfig.java`)
|
||||
|
||||
- **STOMP Endpoint**: `/ws` (Supports SockJS fallback)
|
||||
- **Application Destination Prefix**: `/app`
|
||||
- **User Destination Prefix**: `/user`
|
||||
- **Broker Prefixes**: `/topic`, `/queue`
|
||||
|
||||
### Messaging Flow
|
||||
|
||||
1. **Client Request**: Frontend sends a message to `/app/chat` with payload `{ content: string, conversationId: string }`.
|
||||
2. **Server Processing**: `AgentController` receives the message and delegates it to `LoyaltyAgentService`, which processes it via Spring AI `ChatClient`.
|
||||
3. **Event Streaming**: The server pushes events (`AgentEvent`) back to the client on `/user/queue/chat-events`.
|
||||
|
||||
### Event Types Sent to UI (`AgentEvent` Types)
|
||||
|
||||
- **`TOKEN`**: Text stream chunks returned in real time from the LLM. The UI appends these chunks sequentially for a typing effect.
|
||||
- **`TOOL_STATUS`**: Status update when executing a tool (tool name, status `RUNNING` / `COMPLETED` / `FAILED`, arguments/results). The UI renders an animated indicator badge.
|
||||
- **`DONE`**: Signals that the LLM has finished responding to the current request.
|
||||
@@ -51,7 +55,7 @@ Technology Stack: Java 25, Spring Boot 4.x, Spring AI 2.x, Spring WebSocket (STO
|
||||
- URL: `${MCP_SERVER_URL:http://localhost:9331/sse}`
|
||||
- Transport: SSE (Server-Sent Events)
|
||||
- **Loyalty Core Integration**:
|
||||
- Base URL: `${LOYALTY_CORE_BASE_URL:http://192.168.99.242:8081}`
|
||||
- Base URL: `${LOYALTY_CORE_BASE_URL:http://192.168.99.88:8081}`
|
||||
- Authentication: Keycloak OAuth2 Client Credentials (`KEYCLOAK_TOKEN_URI`, `KEYCLOAK_CLIENT_SECRET`)
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user