Introduction to Agentic Mesh
Agentic Mesh represents a new paradigm in distributed AI systems where multiple specialized AI agents work together in a coordinated network. Unlike traditional monolithic AI systems, an Agentic Mesh distributes capabilities across multiple specialized servers, each handling specific domains while maintaining the ability to communicate and collaborate.
Project Overview: A Four-Server Agentic Mesh Implementation
This project demonstrates a practical implementation of an Agentic Mesh using four specialized servers:
- Dessert Server: Manages dessert-related queries and recipes
- Gym Server: Handles fitness and workout related operations
- Restaurant Server: Manages restaurant bookings and cuisine information
- Yoga Server: Provides yoga-related guidance and poses
Each server operates independently but can be combined into a mesh for complex queries that span multiple domains.
Technical Architecture
Protocol Support
The implementation supports two key protocols:
- MCP (Model Context Protocol): Enables interaction with AI models and tools
- A2A (Agent-to-Agent): Google's protocol for communication between AI agents
Server Configuration
Each server is implemented as a Spring Boot application with:
- Unique port assignments (7863-7866)
- Independent configuration through properties files
- Domain-specific service implementations
- JSON-RPC endpoints for tool invocation
Server Implementations
1. Dessert Server (Port 7863)
@Agent(groupName = "dessertOperations")
public class DessertService {
@Action(description = "Find popular Indian sweets")
public String findIndianSweets() {
return "Popular Indian Sweets: Gulab Jamun, Jalebi, Rasgulla...";
}
}
2. Gym Server (Port 7864)
@Agent(groupName = "gymOperations")
public class GymService {
@Action(description = "Find a trainer for specific workout")
public String findTrainer(String workoutType) {
// Implementation for trainer matching
}
}
3. Restaurant Server (Port 7865)
@Agent(groupName = "restaurantOperations")
public class RestaurantService {
@Action(description = "Make a restaurant reservation")
public String makeReservation(String restaurant, String date, String time) {
// Reservation logic
}
}
4. Yoga Server (Port 7866)
@Agent(groupName = "yogaOperations")
public class YogaService {
@Action(description = "Get meditation techniques")
public String getMeditationTechniques() {
return "Meditation Techniques: Mindfulness, Transcendental...";
}
}
Mesh Integration
The real power of this implementation lies in its mesh capabilities. Using the AgentCatalog
and AgenticMesh
classes, you can:
- Connect to multiple servers simultaneously
- Process queries across different domains
- Combine results for comprehensive responses
Example of mesh integration:
@Log
public class MeshClient {
public static void main(String[] args) {
AgentCatalog agentCatalog = new AgentCatalog();
// Connect to multiple servers
agentCatalog.addAgent("http://localhost:7863/"); // Dessert Server
agentCatalog.addAgent("http://localhost:7865/"); // Restaurant Server
// Process cross-domain query
String answer = agentCatalog.processQuery("Find a restaurant that serves good Gulab Jamun")
.getTextResult();
}
}
Testing and Integration
Tool Discovery
Each server exposes its capabilities through a tools/list endpoint:
curl -H "Content-Type: application/json" `
-d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":9}' `
http://localhost:7863/
Tool Invocation
Tools can be called using JSON-RPC format:
curl -H "Content-Type: application/json" `
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "findIndianSweets",
"arguments": {
"provideAllValuesInPlainEnglish": {}
}
},
"id": 25
}' `
http://localhost:7863/
Integration with AI Platforms
The implementation includes integration with Claude Desktop, allowing AI models to directly interact with the mesh:
{
"mcpServers": {
"yogaserver": {
"command": "java",
"args": [
"-jar",
"mcp-connector-full.jar",
"http://localhost:7866"
],
"timeout": 30000
}
}
}
Benefits of This Architecture
- Modularity: Each server is independently deployable and maintainable
- Scalability: New domains can be added by implementing new servers
- Flexibility: Servers can be combined in different ways for various use cases
- Domain Specialization: Each server can be optimized for its specific domain
- Protocol Support: Dual support for MCP and A2A enables broad compatibility
Use Cases
- Cross-Domain Queries: "Find a gym near a restaurant that serves healthy desserts"
- Complex Workflows: Booking a yoga session followed by a restaurant reservation
- Integrated Experiences: Combining workout plans with dietary recommendations
Conclusion
This implementation demonstrates how Agentic Mesh can be practically realized using Spring Boot and modern protocols. The architecture provides a flexible, scalable framework for building distributed AI systems that can handle complex, multi-domain queries while maintaining modularity and ease of maintenance.
The project serves as a blueprint for building similar systems, showing how to:
- Implement domain-specific AI agents
- Configure inter-agent communication
- Set up protocol support
- Create mesh integrations
- Handle cross-domain queries
This approach to AI system architecture represents a significant step forward in building more flexible, maintainable, and powerful AI solutions.
Code for the article is here
Top comments (0)