A FastAPI application that integrates with Telegram using webhooks and OpenAI Agents SDK for AI-powered stock trading assistance, utilizing MCPHub for multiple MCP server management.
- Telegram bot integration with webhook support
- AI-powered stock analysis using OpenAI Agents SDK
- Multiple MCP server integration via MCPHub:
- Stock news analysis
- Volume wall detection
- Real-time stock data analysis
- Market news integration
- Conversation history tracking
- Trading context management
- MongoDB integration for data persistence
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI app with MCPHub initialization
│ ├── api/
│ │ ├── __init__.py
│ │ └── telegram_webhook.py # Telegram webhook endpoint
│ ├── bot/
│ │ ├── __init__.py
│ │ ├── bot.py # Bot instance and context management
│ │ ├── agent.py # AI agent implementation with MCP servers
│ │ ├── context.py # Conversation context and history
│ │ └── telegram_handler.py # Process incoming messages
│ ├── core/
│ │ ├── __init__.py
│ │ └── settings.py # Application settings
│ ├── models/
│ │ ├── __init__.py
│ │ └── news.py # News data models
│ ├── services/
│ │ ├── __init__.py
│ │ └── mongodb_service.py # MongoDB operations
│ └── startup.py # Startup events
-
Clone the repository
-
Install dependencies:
poetry install
-
Copy
.env.exampleto.envand fill in the required values:cp .env.example .env
-
Edit
.envwith your actual values:TELEGRAM_BOT_TOKEN: Your Telegram bot token from @BotFatherTELEGRAM_WEBHOOK_URL: The public URL where your bot will receive updatesHOSTandPORT: Server configurationAZURE_OPENAI_API_KEY: Your Azure OpenAI API keyAZURE_OPENAI_ENDPOINT: Your Azure OpenAI endpointAZURE_OPENAI_DEPLOYMENT: Your Azure OpenAI deployment nameAZURE_OPENAI_API_VERSION: Azure OpenAI API versionMONGO_URI: MongoDB connection stringMONGO_DB: MongoDB database name