|
| 1 | +# Python Todo List App with MCP Integration |
| 2 | + |
| 3 | +A Flask-based todo list application that exposes operations as MCP (Model Context Protocol) tools over HTTP and can be deployed to Azure App Service. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- ✅ **CRUD Operations**: Create, read, update, delete todos |
| 8 | +- 🎯 **Priority Management**: Set priority levels (low, medium, high) |
| 9 | +- ✅ **Mark Complete/Incomplete**: Toggle completion status |
| 10 | +- 🌐 **Web Interface**: Clean, responsive Bootstrap UI |
| 11 | +- 💬 **Chat Interface**: Placeholder for future LLM integration |
| 12 | +- 🔧 **MCP Tools**: HTTP-accessible tools for external integrations |
| 13 | +- ☁️ **Azure Ready**: Optimized for Azure App Service deployment |
| 14 | + |
| 15 | +## MCP Tools Available |
| 16 | + |
| 17 | +The application exposes the following MCP tools over HTTP: |
| 18 | + |
| 19 | +- `create_todo(title, description, priority)` - Create a new todo item |
| 20 | +- `list_todos(filter_completed)` - Get all todos with optional filtering |
| 21 | +- `update_todo(id, title, description, priority, completed)` - Update existing todo |
| 22 | +- `delete_todo(id)` - Delete a todo item |
| 23 | +- `mark_todo_complete(id, completed)` - Mark todo as complete/incomplete |
| 24 | + |
| 25 | +## Local Development |
| 26 | + |
| 27 | +### Prerequisites |
| 28 | + |
| 29 | +- Python 3.12+ |
| 30 | +- Virtual environment (venv) |
| 31 | + |
| 32 | +### Setup |
| 33 | + |
| 34 | +1. **Clone and setup environment**: |
| 35 | + ```bash |
| 36 | + git clone <repository-url> |
| 37 | + cd python-todo-mcp-agent |
| 38 | + python -m venv .venv |
| 39 | + .venv\Scripts\activate # Windows |
| 40 | + # or |
| 41 | + source .venv/bin/activate # Linux/Mac |
| 42 | + ``` |
| 43 | + |
| 44 | +2. **Install dependencies**: |
| 45 | + ```bash |
| 46 | + pip install -r requirements.txt |
| 47 | + ``` |
| 48 | + |
| 49 | +3. **Set environment variables** (optional): |
| 50 | + ```bash |
| 51 | + set SECRET_KEY=your-secret-key-here |
| 52 | + set DATABASE_URL=sqlite:///todos.db |
| 53 | + ``` |
| 54 | + |
| 55 | +4. **Run the application**: |
| 56 | + ```bash |
| 57 | + python main.py |
| 58 | + ``` |
| 59 | + |
| 60 | +5. **Access the application**: |
| 61 | + - Web Interface: http://localhost:8000 |
| 62 | + - Chat Interface: http://localhost:8000/chat |
| 63 | + - Health Check: http://localhost:8000/health |
| 64 | + - MCP Endpoint: http://localhost:8000/mcp |
| 65 | + - MCP Tools: http://localhost:8000/mcp/tools/* |
| 66 | + |
| 67 | +## Azure Deployment |
| 68 | + |
| 69 | +### Prerequisites |
| 70 | + |
| 71 | +- Azure CLI installed and logged in |
| 72 | +- Azure Developer CLI (azd) installed |
| 73 | + |
| 74 | +### Deploy with AZD |
| 75 | + |
| 76 | +1. **Initialize AZD**: |
| 77 | + ```bash |
| 78 | + azd init |
| 79 | + ``` |
| 80 | + |
| 81 | +2. **Set environment variables**: |
| 82 | + ```bash |
| 83 | + azd env set SECRET_KEY "your-production-secret-key" |
| 84 | + azd env set DATABASE_URL "sqlite:///todos.db" |
| 85 | + ``` |
| 86 | + |
| 87 | +3. **Deploy to Azure**: |
| 88 | + ```bash |
| 89 | + azd up |
| 90 | + ``` |
| 91 | + |
| 92 | +### Infrastructure |
| 93 | + |
| 94 | +The deployment creates: |
| 95 | + |
| 96 | +- **App Service Plan**: P0V3 (Premium V3, Linux) |
| 97 | +- **App Service**: Python 3.12 runtime |
| 98 | +- **Managed Identity**: Secure Azure resource access |
| 99 | + |
| 100 | +## Architecture |
| 101 | + |
| 102 | +``` |
| 103 | +┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ |
| 104 | +│ Web Browser │────│ Flask App │────│ SQLite DB │ |
| 105 | +│ (Todo UI) │ │ (CRUD API) │ │ (Data Store) │ |
| 106 | +└─────────────────┘ └──────────────────┘ └─────────────────┘ |
| 107 | + │ |
| 108 | + ┌──────────────────┐ |
| 109 | + │ MCP Server │ |
| 110 | + │ (HTTP Tools) │ |
| 111 | + └──────────────────┘ |
| 112 | + │ |
| 113 | + ┌──────────────────┐ |
| 114 | + │ External Tools │ |
| 115 | + │ & Integrations │ |
| 116 | + └──────────────────┘ |
| 117 | +``` |
| 118 | + |
| 119 | +## API Endpoints |
| 120 | + |
| 121 | +### REST API |
| 122 | +- `GET /api/todos` - List all todos |
| 123 | +- `POST /api/todos` - Create new todo |
| 124 | +- `GET /api/todos/{id}` - Get specific todo |
| 125 | +- `PUT /api/todos/{id}` - Update todo |
| 126 | +- `DELETE /api/todos/{id}` - Delete todo |
| 127 | +- `PATCH /api/todos/{id}/complete` - Toggle completion |
| 128 | + |
| 129 | +### MCP Integration |
| 130 | +- `GET /mcp` - MCP server info and available tools |
| 131 | +- `POST /mcp` - MCP protocol endpoint (JSON-RPC 2.0) |
| 132 | +- `GET/POST /mcp/tools/create_todo` - Direct tool access |
| 133 | +- `GET/POST /mcp/tools/list_todos` - Direct tool access |
| 134 | +- `POST /mcp/tools/update_todo` - Direct tool access |
| 135 | +- `POST /mcp/tools/delete_todo` - Direct tool access |
| 136 | +- `POST /mcp/tools/mark_todo_complete` - Direct tool access |
| 137 | + |
| 138 | +## Environment Variables |
| 139 | + |
| 140 | +| Variable | Description | Default | |
| 141 | +|----------|-------------|---------| |
| 142 | +| `SECRET_KEY` | Flask secret key for sessions | `dev-secret-key` | |
| 143 | +| `DATABASE_URL` | Database connection string | `sqlite:///todos.db` | |
| 144 | + |
| 145 | +## Development Notes |
| 146 | + |
| 147 | +- **Database**: Uses SQLite for simplicity (can be upgraded to Azure SQL) |
| 148 | +- **Styling**: Bootstrap 5 with Font Awesome icons |
| 149 | +- **Frontend**: Vanilla JavaScript with fetch API |
| 150 | +- **Backend**: Flask with SQLAlchemy ORM |
| 151 | +- **MCP**: Native JSON-RPC 2.0 implementation in Flask |
| 152 | +- **Security**: HTTPS only, managed identity, CORS enabled |
| 153 | + |
| 154 | +## Future Enhancements |
| 155 | + |
| 156 | +- 🤖 **LLM Integration**: Connect chat interface to language models |
| 157 | +- 🗄️ **Database Upgrade**: Migrate to Azure SQL Database |
| 158 | +- 🔐 **Authentication**: Add user accounts and auth |
| 159 | +- 📱 **Mobile App**: React Native or Flutter companion |
| 160 | +- 🔍 **Search**: Full-text search capabilities |
| 161 | +- 📊 **Analytics**: Usage metrics and insights |
| 162 | + |
| 163 | +## Contributing |
| 164 | + |
| 165 | +1. Fork the repository |
| 166 | +2. Create a feature branch |
| 167 | +3. Make your changes |
| 168 | +4. Add tests if applicable |
| 169 | +5. Submit a pull request |
| 170 | + |
| 171 | +## License |
| 172 | + |
| 173 | +This project is licensed under the MIT License. |
0 commit comments