This PR revamps the Mudrex API Intelligent Assistant into a production-ready, group-only Telegram bot with MCP integration, latest Gemini SDK, and comprehensive RAG-powered documentation support.
- ✅ Migrated to latest
google-genaiSDK (replaces deprecatedgoogle-generativeai) - ✅ Upgraded to
gemini-3-flash-previewmodel - ✅ Implemented service account model for MCP integration
- ✅ File-based vector store using Gemini embeddings
- ✅ Group-only bot (rejects DMs, responds when mentioned or API-related)
- ✅ Python wrapper for Mudrex MCP server (
https://mudrex.com/mcp) - ✅ Supports 2 public data tools:
list_futures,get_future - ✅ Blocks 18 personal account/trading tools for security
- ✅ Service account authentication support
- ✅ Comprehensive error handling and fallback modes
- ✅ 10 comprehensive documentation files covering entire Mudrex API
- ✅ 29 document chunks with semantic search
- ✅ Gemini
gemini-embedding-001for embeddings (fallback if deprecated model configured) - ✅ Persistent vector store (
./data/chroma/vectors.pkl) - ✅ Automatic document ingestion pipeline
- ✅ Junior Dev + Community Admin persona
- ✅ Smart query detection (responds to API questions automatically)
- ✅ Group-only mode with DM rejection
- ✅ Rate limiting (per-group)
- ✅ Context-aware responses with chat history
- ✅
.gitignoreprotects API keys and secrets - ✅ Code-level blocking of personal account queries
- ✅ Trading actions blocked (read-only operations)
- ✅ Clear user messaging about data access limitations
- ✅
railway.jsonconfiguration - ✅
Procfilefor process management - ✅
nixpacks.tomlfor build configuration - ✅
runtime.txtfor Python version - ✅ Environment variable documentation
├── main.py # Entry point with async support
├── src/
│ ├── bot/
│ │ └── telegram_bot.py # Group-only bot handlers
│ ├── rag/
│ │ ├── pipeline.py # RAG orchestration
│ │ ├── vector_store.py # File-based vector storage
│ │ ├── gemini_client.py # Latest Gemini SDK integration
│ │ └── document_loader.py # Document processing
│ ├── mcp/
│ │ ├── client.py # MCP server wrapper
│ │ └── tools.py # MCP tool definitions
│ └── config/
│ └── settings.py # Configuration management
├── scripts/
│ ├── ingest_docs.py # Document ingestion
│ └── scrape_docs.py # Documentation scraper
├── docs/ # API documentation (10 files)
├── data/chroma/ # Vector store (auto-created)
├── requirements.txt # Updated dependencies
├── .env.example # Environment template
├── .gitignore # Protects secrets
└── railway.json # Railway deployment config
google-genai>=1.0.0(new SDK)python-telegram-bot==21.0aiohttp>=3.9.0(for MCP async calls)scikit-learn>=1.3.0(for vector similarity)beautifulsoup4>=4.12.0(for doc scraping)
- Model:
gemini-3-flash-preview - Embeddings:
models/gemini-embedding-001 - Vector Store: File-based pickle format
- Storage:
./data/chroma/vectors.pkl
- ✅
list_futures- Public contract listings - ✅
get_future- Public contract details - ❌ All personal account tools (blocked)
- ❌ All trading tools (blocked)
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
GEMINI_API_KEY=your_gemini_api_key
MUDREX_API_SECRET=your_api_secret # Optional, for MCP public datapip install -r requirements.txtpython3 scripts/ingest_docs.pypython3 main.py/help- Show help/tools- List available API tools/mcp- MCP setup guide/futures- List futures contracts (requires MCP)/stats- Bot statistics
- ✅ Responds when @mentioned (always)
- ✅ Responds to API-related questions (auto-detection)
- ❌ Ignores off-topic messages when not mentioned
- ❌ Rejects DMs with helpful message
- RAG: 29 document chunks covering entire Mudrex API
- MCP: Live public data (contract listings)
- Gemini: AI reasoning and code generation
- ✅
.gitignoreexcludes.env,*.pkl,data/ - ✅ No API keys in code
- ✅ Personal account queries blocked in code
- ✅ Trading actions blocked
- ✅ Service account model (uses bot owner's key for public data only)
- ✅ Comprehensive README.md
- ✅ Setup guides (QUICK_SETUP_GUIDE.md, ACTUAL_SETUP.md)
- ✅ MCP integration guide (SERVICE_ACCOUNT_SETUP.md)
- ✅ RAG knowledge explanation (RAG_KNOWLEDGE_EXPLAINED.md)
- ✅ What bot can fetch (WHAT_BOT_CAN_FETCH.md)
Run test suite:
python3 test_bot.pyTests cover:
- ✅ Configuration validation
- ✅ MCP tools definition
- ✅ Document loading
- ✅ Gemini client initialization
- ✅ MCP client connection
- Connect GitHub repository
- Set environment variables in Railway dashboard
- Deploy (auto-detects
railway.json)
- Set environment variables
- Run
python3 scripts/ingest_docs.py - Run
python3 main.py
| Aspect | Before | After |
|---|---|---|
| SDK | Deprecated google-generativeai |
Latest google-genai |
| Model | gemini-2.5-flash |
gemini-3-flash-preview |
| MCP | Not integrated | Full MCP wrapper with 2 public tools |
| Storage | ChromaDB (complex) | File-based (simple, portable) |
| Bot Mode | DMs + Groups | Group-only (community focused) |
| Docs | 4 basic files | 10 comprehensive files (29 chunks) |
| Security | Basic | .gitignore, code-level blocking |
| Deployment | Manual | Railway-ready |
⚠️ Bot no longer responds to DMs (group-only)⚠️ Requires re-ingestion of documents (new vector store format)⚠️ Environment variable names unchanged but usage clarified
- Updated to latest Gemini SDK
- MCP integration implemented
- RAG knowledge base created
- Group-only mode configured
- Security measures in place
- Railway deployment ready
- Documentation complete
- Test suite passing
-
.gitignoreconfigured - Code-level personal data blocking
DecentralizedJM
MIT License - See LICENSE file
Ready for Review & Merge ✅