How ishwanku/mcp-agent-demo works
Main Components
• run.py (Entry point / bootstrap)
• Demo Agent (mcp/agents/demo_agent.py)
• Core Server (mcp/core/server.py using FastAPI + Uvicorn)
• Configuration (mcp/core/config.py with Pydantic + .env)
• Tools
– Email File Tool (mcp/tools/email_file_tool.py)
– Email Tool (mcp/tools/email_tool.py)
• External System: Microsoft Outlook via COM Automation
• Client: send_email.py (HTTP client sending sample_email.txt)
Relationships and Data Flows
1. run.py
– Sets up virtual environment & dependencies (pyproject.toml, setup.py)
– Launches demo_agent.py
2. demo_agent.py
– Initializes Config (reads .env via config.py)
– Creates FastAPI app and Uvicorn server (via server.py)
– Registers Email File Tool and Email Tool as API endpoints (plugin pattern)
3. send_email.py (Client)
– Reads sample_email.txt
– Sends HTTP POST → FastAPI endpoint (/tools/send_email_from_file)
4. server.py (FastAPI + Uvicorn)
– Authenticates API key
– Routes request to Email File Tool handler
5. email_file_tool.py
– Parses the email file (recipients, subject, body, attachments)
– Validates data
– Calls email_tool.send_email(...)
6. email_tool.py
– Checks/starts Outlook via COM automation
– Composes email (TO/CC/BCC, attachments)
– Sends via Outlook
– Returns status/log
Architectural Patterns & Design Principles
• Plugin / Component registration: demo_agent dynamically registers tools as API endpoints
• Separation of concerns:
– Configuration (config.py)
– Server layer (server.py)
– Business logic: parsing vs. email composition
• Use of FastAPI for HTTP microservice interface
• Pydantic for strongly-typed configuration settings
• External integration abstracted behind tool interface
Relevant Technologies, Frameworks & Libraries
• Python 3.9+
• FastAPI + Uvicorn
• Pydantic (configuration management)
• python-dotenv (.env support)
• pywin32 or comtypes (Outlook COM automation)
• Standard library for file I/O and logging
Additional Details to Capture
• .env/config loading before server startup
• Health-check endpoint on FastAPI (e.g., GET /health)
• Logging flow: which component logs which events
• Python package installation step (pip install -e .) as part of bootstrapping (optional)