Content
# 🤖 AI AnswerBot with Task Routing (Mini MCP Agent System)
A sophisticated AI assistant system that routes user questions to specialized agents using MCP-style task routing. The system consists of microservices deployed on Kubernetes with Docker containerization.
## 🎯 Overview
This project implements a mini AI agent system that:
- Takes user input (questions or commands)
- Routes them to different specialized agents based on task type
- Each agent is a separate Python microservice
- All agents are containerized with Docker
- Full deployment with Kubernetes
## 🏗️ Architecture
```
User Question → Router (MCP-style) → Specialized Agent → Response
```
### Agents
| Agent | Purpose | Example Questions |
|-------|---------|------------------|
| **MathAgent** | Solve mathematical problems | "What is 12 + 45?", "Calculate 100 / 5" |
| **WeatherAgent** | Provide weather information | "Weather in London?", "Temperature in Tokyo?" |
| **QnAAgent** | Answer general questions | "What is AI?", "How are you?" |
## 📦 Project Structure
```
ai-answerbot/
├── math-agent/
├── weather-agent/
├── qna-agent/
├── router/
├── k8s/
├── docker-compose.yml
├── deploy.sh
└── README.md
```
## 🚀 Quick Start
### Prerequisites
- Docker & Docker Compose
- Kubernetes (Minikube or Docker Desktop)
- kubectl CLI
- curl (for testing)
### Option 1: Docker Compose (Recommended for Development)
```bash
# Build and deploy all services
./deploy.sh docker
# The router will be available at http://localhost:8000
```
### Option 2: Kubernetes Deployment
```bash
# Build images and deploy to Kubernetes
./deploy.sh k8s
# The router will be available at http://localhost:30080
```
## 🧪 Testing the System
### Automated Tests
```bash
# Run automated tests
./deploy.sh test
```
### Manual Testing
#### Math Questions
```bash
curl -X POST http://localhost:8000/ask \
-H "Content-Type: application/json" \
-d '{"question": "What is 25 + 17?"}'
```
#### Weather Questions
```bash
curl -X POST http://localhost:8000/ask \
-H "Content-Type: application/json" \
-d '{"question": "What is the weather in Paris?"}'
```
#### General Questions
```bash
curl -X POST http://localhost:8000/ask \
-H "Content-Type: application/json" \
-d '{"question": "What is artificial intelligence?"}'
```
## 🔍 Example Responses
### Math Agent Response
```json
{
"agent": "MathAgent",
"question": "What is 25 + 17?",
"expression": "25 + 17",
"result": 42.0,
"router_info": {
"selected_agent": "math",
"routing_reason": "Question contains mathematical expressions or calculation keywords"
}
}
```
### Weather Agent Response
```json
{
"agent": "WeatherAgent",
"question": "What is the weather in Paris?",
"city": "Paris",
"weather": {
"temperature": "18°C",
"condition": "Rainy",
"humidity": "85%"
},
"response": "The weather in Paris is Rainy with a temperature of 18°C and humidity of 85%.",
"router_info": {
"selected_agent": "weather",
"routing_reason": "Question contains weather-related keywords or city names"
}
}
```
## 🎮 Deployment Commands
```bash
# Build Docker images only
./deploy.sh build
# Deploy with Docker Compose
./deploy.sh docker
# Deploy to Kubernetes
./deploy.sh k8s
# Run tests
./deploy.sh test
# Clean up all resources
./deploy.sh clean
# Show help
./deploy.sh help
```
## 🔧 Router Logic (MCP-Style)
The router uses intelligent pattern matching to determine the appropriate agent:
### Math Detection
- Patterns: Arithmetic expressions (`12 + 45`, `100 / 5`)
- Keywords: calculate, solve, add, subtract, multiply, divide, math
### Weather Detection
- Keywords: weather, temperature, forecast, rain, sunny, cloudy
- Cities: New York, London, Tokyo, Paris, Sydney
### Default Routing
- All other questions go to the QnA Agent for general responses
## 🏥 Health Monitoring
Each service provides health endpoints:
```bash
# Check router health
curl http://localhost:8000/health
# Check individual agents (Docker Compose)
curl http://localhost:8001/health # Math Agent
curl http://localhost:8002/health # Weather Agent
curl http://localhost:8003/health # QnA Agent
```
## 📊 Service Discovery
View available agents and their capabilities:
```bash
curl http://localhost:8000/agents
```
## 🛠️ Technologies Used
- Backend: Python 3.10 + FastAPI
- Containerization: Docker & Docker Compose
- Orchestration: Kubernetes
- HTTP Client: Requests library
- API Documentation: Automatic OpenAPI/Swagger docs
## 📈 Scaling & Production
### Kubernetes Features Implemented
- Deployments: Automated rolling updates
- Services: Load balancing and service discovery
- Health Checks: Liveness and readiness probes
- Resource Limits: Memory and CPU constraints
- NodePort: External access to router service
### Horizontal Scaling
```bash
# Scale agents independently
kubectl scale deployment math-agent --replicas=3
kubectl scale deployment weather-agent --replicas=2
```
## 🔮 Future Enhancements
- [ ] Add authentication and authorization
- [ ] Implement actual weather API integration
- [ ] Add more sophisticated NLP for better routing
- [ ] Include monitoring and logging (Prometheus/Grafana)
- [ ] Add caching layer (Redis)
- [ ] Implement rate limiting
- [ ] Add more specialized agents (TranslationAgent, SummaryAgent)
## 📝 API Documentation
When running, visit these URLs for interactive API documentation:
- Router: `http://localhost:8000/docs`
- Math Agent: `http://localhost:8001/docs`
- Weather Agent: `http://localhost:8002/docs`
- QnA Agent: `http://localhost:8003/docs`
## 🐛 Troubleshooting
### Common Issues
1. Port conflicts: Ensure ports 8000-8003 are available
2. Kubernetes connection: Verify `kubectl cluster-info` works
3. Docker issues: Check `docker ps` and `docker logs <container>`
### Logs
```bash
# Docker Compose logs
docker-compose logs -f
# Kubernetes logs
kubectl logs -f deployment/router
kubectl logs -f deployment/math-agent
```
Connection Info
You Might Also Like
awesome-mcp-servers
A collection of MCP servers.
git
A Model Context Protocol server for Git automation and interaction.
Appwrite
Build like a team of hundreds
TrendRadar
TrendRadar: Your hotspot assistant for real news in just 30 seconds.
oh-my-opencode
Background agents · Curated agents like oracle, librarians, frontend...
cc-switch
All-in-One Assistant for Claude Code, Codex & Gemini CLI across platforms.