A FastAPI-based MCP (Model Context Protocol) server for collecting and managing user demographics.
- Collect user demographics (name, gender, age range, region, ethnicity, language, preferred channel)
- Store data in SQLite database
- Send demographics via email
- MCP protocol support for tool integration
- Health check endpoint
- CORS enabled
- Production-ready with Docker
- Clone the repository
- Create virtual environment:
python -m venv venv - Activate:
venv\Scripts\activate(Windows) - Install dependencies:
pip install -r requirements.txt - Copy
.env.exampleto.envand configure environment variables - Run:
python demographic_server.py
- Push code to GitHub
- Connect Railway to your GitHub repo
- Deploy (Railway auto-detects Python app)
- Set environment variables in Railway dashboard:
SMTP_HOSTSMTP_PORTSMTP_USERSMTP_PASSWORDEMAIL_TOPORT(auto-set by Railway)
Note: SQLite database is file-based; data persists during runtime but resets on redeploy. For persistent data, consider upgrading to a managed database.
- Build and run with Docker Compose:
docker-compose up --build
- Set environment variables
- Run with uvicorn:
uvicorn demographic_server:app --host 0.0.0.0 --port 8000 --workers 4
GET /- Service infoGET /health- Health checkPOST /mcp- MCP protocol handler
save_demographics_mail- Save demographics and emailget_demographics_mail- Retrieve demographicscheck_demographics_complete_mail- Check completion statussend_complete_session_mail- Send full session via email
SMTP_HOST- SMTP server hostSMTP_PORT- SMTP server portSMTP_USER- SMTP usernameSMTP_PASSWORD- SMTP passwordEMAIL_TO- Recipient email addressPORT- Server port (default: 8000)