A comprehensive dashboard application that integrates Microsoft Outlook emails, GitHub repositories, and Microsoft Teams with AI-powered insights and interactive chatbots.
- Read and summarize Outlook emails
- AI-powered email analysis and insights
- Interactive email assistant chatbot
- Unread email tracking and management
- Connect and analyze GitHub repositories
- View commits, issues, and pull requests
- AI-powered GitHub activity summaries
- Interactive GitHub assistant chatbot
- Access Teams channels and messages
- Calendar and meeting management
- AI-powered Teams activity analysis
- Interactive Teams assistant chatbot
- Google Gemini AI integration
- Intelligent data summarization
- Context-aware chatbot responses
- Real-time data analysis
- Python 3.8 or higher
- Microsoft Azure account
- GitHub account
- Google Cloud account (for Gemini AI)
- Modern web browser
git clone https://github.com/Pavantext/_MCP_Agent.git
cd _MCP_Agentpython -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activatepip install -r requirements.txt- Go to Azure Portal
- Navigate to Azure Active Directory > App registrations
- Click New registration
- Fill in details:
- Name: MCP Agent
- Supported account types: Accounts in this organizational directory only (Single tenant)
- Redirect URI: Web -
http://localhost:8000/auth/callback
- Click Register
- In your app registration, go to API permissions
- Click Add a permission
- Select Microsoft Graph
- Choose Delegated permissions
- Add these permissions:
Mail.ReadUser.ReadChat.ReadChat.ReadWriteChannel.ReadBasic.AllTeam.ReadBasic.AllCalendars.ReadOnlineMeetings.Read
- Click Grant admin consent
- Go to Overview and copy:
- Application (client) ID
- Directory (tenant) ID
- Go to Certificates & secrets
- Click New client secret
- Copy the Value (client secret)
- Go to GitHub Settings
- Click New OAuth App
- Fill in details:
- Application name: MCP Agent
- Homepage URL:
http://localhost:8000 - Authorization callback URL:
http://localhost:8000/auth/github/callback
- Click Register application
- Copy the Client ID
- Click Generate a new client secret
- Copy the Client Secret
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the Generative AI API
- Go to APIs & Services > Credentials
- Click Create Credentials > API Key
- Copy the API key
Create a .env file in the project root:
# Microsoft Azure Configuration (Email & Teams)
CLIENT_ID=your_azure_client_id_here
CLIENT_SECRET=your_azure_client_secret_here
TENANT_ID=your_azure_tenant_id_here
REDIRECT_URI=http://localhost:8000/auth/callback
SCOPES=Mail.Read User.Read
# Teams Configuration
TEAMS_CLIENT_ID=your_azure_client_id_here
TEAMS_CLIENT_SECRET=your_azure_client_secret_here
TEAMS_TENANT_ID=your_azure_tenant_id_here
TEAMS_REDIRECT_URI=http://localhost:8000/auth/teams/callback
TEAMS_SCOPES=Chat.Read Chat.ReadWrite Channel.ReadBasic.All Team.ReadBasic.All User.Read Calendars.Read OnlineMeetings.Read
# GitHub Configuration
GITHUB_CLIENT_ID=your_github_client_id_here
GITHUB_CLIENT_SECRET=your_github_client_secret_here
GITHUB_REDIRECT_URI=http://localhost:8000/auth/github/callback
GITHUB_SCOPES=repo user
# AI Configuration
GEMINI_API_KEY=your_gemini_api_key_herepython app.pyThe application will be available at: http://localhost:8000
- Open
http://localhost:8000in your browser - Click Login with Microsoft to authenticate
- Grant permissions when prompted
- You'll be redirected to the dashboard
- AI Email Summary: Intelligent analysis of your emails
- Email Assistant: Chat with AI about your emails
- Email Statistics: Total and unread email counts
- Quick Actions: View all emails or unread only
- AI GitHub Summary: Analysis of your repositories and activity
- GitHub Assistant: Chat with AI about your GitHub data
- Repository Stats: Total repositories and recent activity
- Connect Button: Authenticate with GitHub
- AI Teams Summary: Analysis of your Teams activity
- Teams Assistant: Chat with AI about your Teams data
- Teams Stats: Total teams, channels, and meetings
- Connect Button: Authenticate with Microsoft Teams
GET /auth/login # Microsoft OAuth login
GET /auth/callback # OAuth callback handler
GET /auth/status # Check authentication status
POST /auth/logout # Logout userGET /emails/summary # Get email summary
GET /emails/all # Get all emails
GET /emails/unread # Get unread emails
GET /emails/ai-summary # Get AI-powered summary
PATCH /emails/{email_id}/read # Mark email as readGET /github/login # GitHub OAuth login
GET /github/callback # GitHub OAuth callback
GET /github/status # Check GitHub auth status
GET /github/summary # Get GitHub summary
GET /github/repositories # Get user repositories
GET /github/commits # Get recent commits
GET /github/issues # Get user issues
GET /github/pull-requests # Get pull requests
GET /github/ai-summary # Get AI-powered GitHub summaryGET /teams/login # Teams OAuth login
GET /teams/callback # Teams OAuth callback
GET /teams/status # Check Teams auth status
GET /teams/summary # Get Teams summary
GET /teams/teams # Get user's teams
GET /teams/channels # Get all channels
GET /teams/messages # Get recent messages
GET /teams/meetings # Get user's meetings
GET /teams/ai-summary # Get AI-powered Teams summaryPOST /chatbot/chat # Chat with email assistant
GET /chatbot/suggestions # Get email chat suggestions
POST /github-chatbot/chat # Chat with GitHub assistant
GET /github-chatbot/suggestions # Get GitHub chat suggestions
POST /teams-chatbot/chat # Chat with Teams assistant
GET /teams-chatbot/suggestions # Get Teams chat suggestionsUser: "How many unread emails do I have?"
Assistant: "You currently have 15 unread emails. The most recent ones are from..."
User: "Show me emails from john@example.com"
Assistant: "I found 3 emails from john@example.com. The most recent one is..."
User: "What are my most important emails?"
Assistant: "Based on your email patterns, here are the most important emails..."
User: "How many repositories do I have?"
Assistant: "You have 12 repositories. The most active ones are..."
User: "What are my recent commits?"
Assistant: "Your most recent commits include..."
User: "Show me my open issues"
Assistant: "You have 5 open issues across your repositories..."
User: "How many teams do I have?"
Assistant: "You are a member of 8 teams. The most active ones are..."
User: "What meetings do I have today?"
Assistant: "You have 3 meetings scheduled for today..."
User: "Show me recent messages from my teams"
Assistant: "Recent activity in your teams includes..."
_MCP_Agent/
βββ api/
β βββ main.py # FastAPI application entry point
β βββ models/ # Pydantic data models
β β βββ auth.py # Authentication models
β β βββ chatbot.py # Chatbot models
β β βββ github.py # GitHub models
β β βββ teams.py # Teams models
β βββ routers/ # API route handlers
β β βββ auth.py # Authentication routes
β β βββ emails.py # Email management routes
β β βββ chatbot.py # Email chatbot routes
β β βββ github.py # GitHub routes
β β βββ github_chatbot.py # GitHub chatbot routes
β β βββ teams.py # Teams routes
β β βββ teams_chatbot.py # Teams chatbot routes
β βββ services/ # Business logic services
β βββ auth_service.py # Microsoft authentication
β βββ email_service.py # Email operations
β βββ ai_service.py # AI summarization
β βββ github_auth_service.py # GitHub authentication
β βββ github_service.py # GitHub operations
β βββ github_chatbot_service.py # GitHub chatbot
β βββ teams_auth_service.py # Teams authentication
β βββ teams_service.py # Teams operations
β βββ teams_chatbot_service.py # Teams chatbot
β βββ chatbot_service.py # Email chatbot
βββ frontend/
β βββ templates/
β βββ dashboard.html # Main dashboard template
βββ app.py # Application launcher
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ GITHUB_SETUP.md # GitHub setup guide
βββ TEAMS_SETUP.md # Teams setup guide
| Variable | Description | Required | Default |
|---|---|---|---|
CLIENT_ID |
Microsoft Azure client ID | Yes | - |
CLIENT_SECRET |
Microsoft Azure client secret | Yes | - |
TENANT_ID |
Microsoft Azure tenant ID | Yes | - |
REDIRECT_URI |
OAuth redirect URI | No | http://localhost:8000/auth/callback |
SCOPES |
Microsoft Graph scopes | No | Mail.Read User.Read |
TEAMS_CLIENT_ID |
Teams client ID (same as CLIENT_ID) | Yes | - |
TEAMS_CLIENT_SECRET |
Teams client secret (same as CLIENT_SECRET) | Yes | - |
TEAMS_TENANT_ID |
Teams tenant ID (same as TENANT_ID) | Yes | - |
TEAMS_REDIRECT_URI |
Teams OAuth redirect URI | No | http://localhost:8000/auth/teams/callback |
TEAMS_SCOPES |
Teams scopes | No | Chat.Read Chat.ReadWrite Channel.ReadBasic.All Team.ReadBasic.All User.Read Calendars.Read OnlineMeetings.Read |
GITHUB_CLIENT_ID |
GitHub OAuth client ID | Yes | - |
GITHUB_CLIENT_SECRET |
GitHub OAuth client secret | Yes | - |
GITHUB_REDIRECT_URI |
GitHub OAuth redirect URI | No | http://localhost:8000/auth/github/callback |
GITHUB_SCOPES |
GitHub scopes | No | repo user |
GEMINI_API_KEY |
Google Gemini AI API key | Yes | - |
- Verify your Azure app registration is correct
- Check that CLIENT_ID and CLIENT_SECRET match your Azure app
- Ensure the app is registered as a web application
- Check that all required permissions are granted in Azure AD
- Verify admin consent is granted for all permissions
- Ensure the user has access to the requested resources
- Make sure you're using a single-tenant app registration
- Verify TENANT_ID is set to your specific tenant ID
- Don't use "common" as the tenant ID
- Check that redirect URIs match exactly
- Verify the OAuth flow is completing properly
- Ensure the app registration settings are correct
- Verify GEMINI_API_KEY is set correctly
- Check that the Google Cloud project has Generative AI API enabled
- Ensure the API key has proper permissions
Add to your .env file for detailed logging:
DEBUG=true- Use HTTPS: Always use HTTPS in production
- Database Storage: Replace in-memory token storage with a proper database
- Environment Variables: Store sensitive data in environment variables
- Rate Limiting: Implement rate limiting for API endpoints
- Token Refresh: Implement automatic token refresh logic
- Monitoring: Add proper logging and monitoring
- Tokens are currently stored in memory (for development)
- Implement secure token storage for production
- Add token refresh logic for long-running sessions
- Implement proper token validation
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Add tests if applicable
- Commit your changes:
git commit -m 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter issues:
- Check the browser console for JavaScript errors
- Review the application logs for Python errors
- Verify all environment variables are set correctly
- Test with a different account if authentication issues persist
- Check network connectivity to external APIs
Stay updated with the latest features and fixes:
git pull origin main
pip install -r requirements.txtNote: This application is designed for development and testing purposes. For production use, implement proper security measures, database storage, and monitoring.