Files
fastmcp-feedback/examples
rsp2k ddf23d10e4
Tests / test (==2.12.2) (push) Canceled after 0s
Tests / test (==2.14.3) (push) Canceled after 0s
Tests / test (>=4,<5) (push) Canceled after 0s
Tests / canary (push) Canceled after 0s
Support FastMCP 4 and fix silent composition failure
compose_feedback_services() called import_server() without awaiting it.
That method became async in FastMCP 2.14, so on the version this package
was built against it composed nothing while logging success. FastMCP 4
removed it outright. Use mount(), which is sync on 2.12 through 4.x.

The test suite could not start (pytest-html hook, plugin not installed),
so nothing caught this. Add pytest-html, bring examples/ over from the docs
repo since the integration tests import them, and fix the tests that had
drifted from the code. 407 tests pass on FastMCP 2.12.2, 2.14.3 and 4.0.10.

- Declare fastmcp>=2.12.2,<5; CI matrix covers each family plus a
  non-blocking canary on the newest FastMCP
- Add a composition test with real servers; the mocked ones could not
  see a missing await
- Rewrite the README against the actual API and execute its examples
- Ignore ruff UP042: StrEnum would change stored enum formatting
- Version 2026.09.27
2026-09-27 06:09:30 -06:00
..

FastMCP Feedback Examples

This directory contains comprehensive examples demonstrating all features of the FastMCP Feedback system.

🚀 Demo Server

demo_server.py

Complete demonstration server showcasing all features

Features Demonstrated:

  • ✅ Complete feedback collection workflow
  • ✅ Privacy-compliant analytics (GDPR-ready)
  • ✅ Multi-database support (SQLite, PostgreSQL, MySQL)
  • ✅ Thread-safe operations with 97% test coverage
  • ✅ Server composition patterns
  • ✅ Performance monitoring and health checks
  • ✅ Sample data for testing

Available Tools:

  • submit_feedback - Submit bug reports, feature requests, improvements, questions
  • list_feedback - Query and filter feedback with pagination
  • get_feedback_statistics - Analytics and aggregate metrics
  • update_feedback_status - Change status (open → in_progress → resolved)
  • delete_feedback - Remove feedback items
  • get_system_info - Version and dependency information
  • setup_sample_data - Populate with realistic demo data

Usage:

# Run the demo server
python examples/demo_server.py

# Or with uv
uv run examples/demo_server.py

Claude Desktop MCP Configuration:

{
  "mcpServers": {
    "fastmcp-feedback-demo": {
      "command": "uv",
      "args": ["run", "examples/demo_server.py"],
      "env": {
        "LOG_LEVEL": "INFO"
      }
    }
  }
}

🏗️ Architecture Examples

simple_integration.py

Minimal integration example - 3 lines of code

from fastmcp import FastMCP
from fastmcp_feedback import add_feedback_tools

app = FastMCP("My App")
add_feedback_tools(app, database_url="sqlite:///feedback.db")

advanced_configuration.py

Production-ready configuration with all features

from fastmcp_feedback import (
    add_feedback_tools,
    FeedbackInsights,
    FeedbackDatabase
)

# Configure privacy-compliant analytics
insights = FeedbackInsights(
    enabled=True,
    retention_days=90,
    privacy_compliant=True
)

# Setup database with connection pooling
database = FeedbackDatabase(
    "postgresql://user:pass@localhost/feedback",
    pool_size=20,
    max_overflow=10
)

# Add tools with custom prefix
add_feedback_tools(
    app,
    database=database,
    insights=insights,
    prefix="support_"
)

server_composition.py

Multi-server composition patterns

from fastmcp_feedback.feedback import (
    create_submission_server,
    create_management_server,
    create_analytics_server
)

# Create specialized servers
public_server = create_submission_server("Public Portal")
admin_server = create_management_server("Admin Panel") 
analytics = create_analytics_server("Dashboard")

# Compose into main application
main_app = FastMCP("Main Application")
await main_app.import_server(public_server, prefix="public")
await main_app.import_server(admin_server, prefix="admin")
await main_app.import_server(analytics, prefix="stats")

🎯 Usage Patterns

Basic Feedback Workflow

  1. Submit Feedback:

    # Submit a bug report
    result = await submit_feedback({
        "request": {
            "type": "bug",
            "title": "Login page not responsive on mobile",
            "description": "The login form overflows on screens < 768px width",
            "submitter": "user_123",
            "contact_info": "user@example.com"
        }
    })
    
  2. List and Filter:

    # Get all open bug reports
    bugs = await list_feedback({
        "type_filter": "bug",
        "status_filter": "open", 
        "limit": 20
    })
    
  3. Update Status:

    # Mark as in progress
    await update_feedback_status({
        "feedback_id": "123",
        "new_status": "in_progress",
        "note": "Engineering team investigating"
    })
    
  4. Get Analytics:

    # View statistics
    stats = await get_feedback_statistics()
    # Returns: {"total_count": 45, "by_type": {"BUG": 12, "FEATURE": 20}, ...}
    

🔒 Privacy & Security Examples

Privacy-Compliant Configuration

insights = FeedbackInsights(
    enabled=True,                    # Enable analytics
    retention_days=90,               # Auto-cleanup after 90 days
    privacy_compliant=True,          # Enforce GDPR compliance
    anonymize_identifiers=True,      # Hash user identifiers
    exclude_contact_info=True        # Don't store in metrics
)

Security Features

# Input validation with Pydantic
from fastmcp_feedback.models import SubmitFeedbackRequest

# SQL injection prevention via SQLAlchemy ORM
# Rate limiting support (extend mixins)
# Authentication ready (add middleware)

📊 Performance Examples

Connection Pooling

database = FeedbackDatabase(
    "postgresql://localhost/feedback",
    pool_size=20,           # Base connections
    max_overflow=10,        # Burst capacity
    pool_timeout=30,        # Connection timeout
    pool_recycle=3600       # Refresh every hour
)

Bulk Operations

# Bulk status updates
result = await bulk_update_status(
    feedback_ids=["1", "2", "3", "4", "5"],
    new_status="resolved"
)

Performance Monitoring

# Built-in health checks
health = await database.health_check()
if not health:
    # Trigger alerts
    pass

# Performance metrics
stats = await get_database_stats()
# Returns connection pool status, query times, etc.

🧪 Testing Examples

Unit Testing with FastMCP Feedback

import pytest
from fastmcp_feedback import FeedbackDatabase

@pytest.mark.asyncio
async def test_feedback_submission():
    # Use in-memory database for testing
    db = FeedbackDatabase("sqlite:///:memory:")
    await db.initialize()
    
    # Test feedback submission
    # ... test code here
    
    await db.close()

Integration Testing

# Test complete workflows
async def test_complete_feedback_lifecycle():
    # Submit → List → Update → Verify → Analytics
    pass

🚀 Production Deployment Examples

Docker Configuration

FROM python:3.11-slim

WORKDIR /app
COPY pyproject.toml .
RUN pip install -e .

COPY src/ src/
COPY examples/ examples/

# Health check
HEALTHCHECK --interval=30s --timeout=10s \
  CMD python -c "import asyncio; from examples.health_check import check; asyncio.run(check())"

CMD ["python", "examples/demo_server.py"]

Environment Configuration

# Database
DATABASE_URL=postgresql://user:pass@db:5432/feedback

# Analytics
INSIGHTS_ENABLED=true
INSIGHTS_RETENTION_DAYS=90

# Performance
CONNECTION_POOL_SIZE=20
MAX_OVERFLOW=10

# Security
RATE_LIMIT_REQUESTS=100
RATE_LIMIT_WINDOW=3600

📚 Documentation

Each example includes:

  • Comprehensive comments explaining every feature
  • Error handling patterns
  • Performance considerations
  • Security best practices
  • Testing approaches
  • Production deployment guidance

🎯 Getting Started

  1. Start with the demo server - python examples/demo_server.py
  2. Connect to Claude Desktop using the MCP configuration above
  3. Try the tools - submit feedback, query results, update status
  4. Explore the code - see how each feature is implemented
  5. Customize for your needs - adapt patterns to your use case

🤝 Contributing Examples

We welcome additional examples! Please:

  • Include comprehensive comments
  • Add error handling
  • Provide usage instructions
  • Update this README
  • Add tests if applicable

These examples demonstrate production-ready FastMCP Feedback integration with 97% test coverage and enterprise-grade reliability.