A FastAPI-based backend system that processes natural language commands into structured actions for SaaS services.
- Natural language command processing
- Modular adapter architecture for service integration
- API key authentication
- Command status tracking
- Extensible design for adding new service adapters
backend/
├── app/
│ ├── adapters/ # Service adapters
│ ├── models/ # Data models
│ ├── services/ # Core services
│ └── main.py # FastAPI application
├── tests/ # Unit tests
└── requirements.txt # Python dependencies
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the server:
uvicorn app.main:app --reload
Once the server is running, visit:
- OpenAPI documentation: http://localhost:8000/docs
- ReDoc documentation: http://localhost:8000/redoc
All endpoints require an API key header:
X-API-Key: your-secret-key
Process a natural language command.
Request:
{
"command": "Schedule a team meeting"
}
Response:
{
"command_id": "20250401100000",
"status": "completed",
"processed_intent": {
"service": "calendar",
"action": "create_event",
"parameters": {
"title": "Team Meeting",
"date": "2025-04-01",
"time": "10:00 AM"
}
}
}
Get the status of a processed command.
To add a new service adapter:
- Create a new adapter class in
app/adapters/
that inherits fromBaseAdapter
- Implement the required methods:
service_name
propertyexecute()
method
- Register the adapter in
MCPService
initialization
Example:
class EmailAdapter(BaseAdapter):
@property
def service_name(self) -> str:
return "email"
def execute(self, intent: Dict[str, Any]) -> bool:
# Implement email sending logic
return True
pytest