# FastMCP Feedback Demo Server **File:** `demo_server.py` **Purpose:** Comprehensive demonstration of all FastMCP Feedback features **Lines:** 396 lines of production-ready code **Test Coverage:** Validated through 396+ comprehensive tests ## ๐ŸŽฏ Overview The demo server is a complete, production-ready FastMCP server that showcases every feature of the FastMCP Feedback system. It's designed to demonstrate real-world usage patterns and serve as a reference implementation for developers. ## โœจ Features Demonstrated ### Core Feedback System - **Complete CRUD Operations** - Submit, retrieve, update, delete feedback - **Type Support** - Bug reports, feature requests, improvements, questions - **Status Management** - Open โ†’ In Progress โ†’ Resolved โ†’ Closed workflow - **Rich Metadata** - Timestamps, submitter info, contact details ### Advanced Capabilities - **Privacy-Compliant Analytics** - GDPR-ready insights collection - **Multi-Database Support** - SQLite for development, PostgreSQL for production - **Thread-Safe Operations** - Concurrent request handling - **Performance Monitoring** - Health checks and dependency validation - **Server Composition** - Multiple specialized server types ### Data Integrity - **Input Validation** - Pydantic models with comprehensive validation - **Unicode Support** - Emojis, special characters, international text - **Timezone Handling** - UTC-aware timestamp management - **Whitespace Normalization** - Consistent data cleaning ## ๐Ÿ› ๏ธ Available Tools (7 Total) | Tool | Description | Use Case | |------|-------------|----------| | `submit_feedback` | Submit new feedback items | Users reporting bugs/requesting features | | `list_feedback` | Query and filter feedback | Viewing feedback with pagination/filtering | | `get_feedback_statistics` | Analytics and metrics | Dashboard data and reporting | | `update_feedback_status` | Change feedback status | Admin workflow management | | `delete_feedback` | Remove feedback items | Content moderation | | `get_system_info` | Version/dependency info | System diagnostics | | `setup_sample_data` | Populate demo data | Testing and demonstration | ## ๐Ÿ“Š Sample Data The demo server includes realistic sample data: ```python sample_feedback = [ { "type": "bug", "title": "Memory leak in analytics processing", "description": "Analytics worker consumes increasing memory over time...", "submitter": "alice@example.com", "contact_info": "alice@engineering.example.com" }, { "type": "feature", "title": "Add export functionality for feedback data", "description": "Users need ability to export feedback data as CSV or JSON...", "submitter": "product_manager", "contact_info": "pm@example.com" } # ... 3 more realistic examples ] ``` ## ๐Ÿš€ Usage ### Direct Execution ```bash # Run with Python python examples/demo_server.py # Run with uv (recommended) uv run examples/demo_server.py ``` ### Claude Desktop Integration ```json { "mcpServers": { "fastmcp-feedback-demo": { "command": "uv", "args": ["run", "examples/demo_server.py"], "env": { "DATABASE_URL": "sqlite:///feedback_demo.db", "LOG_LEVEL": "INFO" } } } } ``` ### Docker Deployment ```dockerfile FROM python:3.11-slim COPY . /app WORKDIR /app RUN pip install uv && uv sync CMD ["uv", "run", "examples/demo_server.py"] ``` ## ๐Ÿ”ง Configuration Options ### Environment Variables - `DATABASE_URL` - Database connection string (default: temporary SQLite) - `LOG_LEVEL` - Logging verbosity (DEBUG, INFO, WARNING, ERROR) - `INSIGHTS_ENABLED` - Enable/disable analytics collection - `RETENTION_DAYS` - Analytics data retention period ### Database Support - **SQLite** - `sqlite:///path/to/database.db` (development) - **PostgreSQL** - `postgresql://user:pass@host:port/db` (production) - **In-Memory** - `sqlite:///:memory:` (testing) ## ๐Ÿ“ˆ Performance Characteristics ### Throughput - **Concurrent Requests** - Handles 100+ concurrent submissions - **Database Performance** - Optimized queries with indexing - **Memory Usage** - Efficient async/await patterns ### Scalability - **Horizontal Scaling** - Stateless design supports load balancing - **Database Scaling** - Connection pooling and query optimization - **Analytics Scaling** - Configurable retention and aggregation ## ๐Ÿงช Testing Integration The demo server is thoroughly tested through: ### Unit Tests - Tool registration and configuration - Sample data generation - Error handling scenarios ### Integration Tests - End-to-end workflow validation - Database operations - Server composition patterns ### Performance Tests - High-volume operations - Concurrent request handling - Memory usage monitoring ## ๐ŸŽ“ Learning Examples ### Basic Feedback Submission ```python # Submit a bug report result = await submit_feedback({ "type": "bug", "title": "Application crashes on startup", "description": "Detailed error description...", "submitter": "developer@company.com" }) ``` ### Advanced Filtering ```python # Get all open bug reports from last week feedback = await list_feedback({ "type_filter": "bug", "status_filter": "open", "limit": 50 }) ``` ### Analytics Query ```python # Get comprehensive statistics stats = await get_feedback_statistics() # Returns: total_count, by_type, by_status, recent_count ``` ## ๐Ÿ” Architecture Insights ### Server Composition Pattern ```python # The demo server demonstrates server composition: main_server = FastMCP("Demo Server") feedback_server = create_feedback_server("Feedback Service") main_server.import_server(feedback_server, prefix="feedback_") ``` ### Database Abstraction ```python # Flexible database backend: database = FeedbackDatabase(database_url) await database.initialize() # Auto-creates tables ``` ### Analytics Integration ```python # Privacy-compliant analytics: insights = FeedbackInsights(enabled=True, retention_days=90) insights.record_metric("feedback_submitted", metadata) ``` ## ๐Ÿ“š Related Documentation - **[Simple Integration](simple_integration.md)** - Minimal 3-line integration - **[Production Server](mcp_server.md)** - Environment-configured deployment - **[Testing Guide](../tests/README.md)** - Comprehensive test documentation - **[Architecture Overview](../docs/architecture.md)** - System design details ## ๐Ÿค Contributing When modifying the demo server: 1. **Maintain Compatibility** - Ensure all existing tools continue working 2. **Update Documentation** - Keep this file synchronized with code changes 3. **Add Tests** - Include test coverage for new features 4. **Version Compatibility** - Support multiple FastMCP versions where possible ## ๐Ÿ› Troubleshooting ### Common Issues **Database Errors** ```bash # Check database permissions ls -la feedback_demo.db # Reset database rm feedback_demo.db && python examples/demo_server.py ``` **Import Errors** ```bash # Ensure development installation uv sync # Check Python path python -c "import fastmcp_feedback; print('OK')" ``` **Performance Issues** ```bash # Enable debug logging LOG_LEVEL=DEBUG python examples/demo_server.py # Monitor memory usage ps aux | grep demo_server ``` This demo server represents the gold standard for FastMCP Feedback integration, demonstrating every feature with production-ready code patterns and comprehensive error handling.