Skip to main content
Glama

MCP Agent - AI Expense Tracker

by dev-muhammad
start.py•5.53 kB
#!/usr/bin/env python3 """ Startup script for the Telegram Bot Handles environment setup and provides helpful information """ import os import sys import subprocess import argparse def check_dependencies(): """Check if required dependencies are installed""" try: import telegram import requests return True except ImportError as e: print(f"āŒ Missing dependency: {e}") return False def install_dependencies(): """Install required dependencies""" try: print("šŸ“¦ Installing dependencies...") subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"]) print("āœ… Dependencies installed successfully") return True except subprocess.CalledProcessError as e: print(f"āŒ Failed to install dependencies: {e}") return False def load_env_file(env_file="config.env"): """Load environment variables from file""" if os.path.exists(env_file): print(f"šŸ“„ Loading environment from {env_file}") with open(env_file, 'r') as f: for line in f: line = line.strip() if line and not line.startswith('#') and '=' in line: key, value = line.split('=', 1) os.environ[key.strip()] = value.strip() return True return False def check_configuration(): """Check if required configuration is present""" required_vars = { 'TELEGRAM_BOT_TOKEN': 'Get from @BotFather on Telegram' } optional_vars = { 'AGNO_API_URL': 'http://localhost:7777', 'AGENT_ID': 'expense-tracker-agent', 'DEFAULT_USER_ID': 'MUHAMMAD' } missing_required = [] print("šŸ”§ Configuration Check:") print("=" * 50) # Check required variables for var, description in required_vars.items(): value = os.getenv(var) if value: print(f"āœ… {var}: {'*' * min(len(value), 20)}...") else: print(f"āŒ {var}: Missing - {description}") missing_required.append(var) # Check optional variables for var, default in optional_vars.items(): value = os.getenv(var, default) print(f"ā„¹ļø {var}: {value}") return len(missing_required) == 0, missing_required def show_setup_help(): """Show setup instructions""" print(""" šŸ¤– TELEGRAM BOT SETUP GUIDE =" * 50 1. Create a Telegram Bot: • Message @BotFather on Telegram • Send /newbot and follow instructions • Copy the bot token 2. Configure Environment: • Copy config.env.example to config.env • Set TELEGRAM_BOT_TOKEN=your_token_here • Adjust other settings if needed 3. Start the Bot: • python start.py --run • Or: python bot.py 4. Test the Bot: • Find your bot on Telegram • Send /start to begin • Try: "What's my balance?" šŸ”— Useful Links: • @BotFather: https://t.me/BotFather • Telegram Bot API: https://core.telegram.org/bots/api • Agno Agent Docs: http://localhost:7777/docs """) def main(): """Main entry point""" parser = argparse.ArgumentParser(description="Telegram Bot for Expense Tracker") parser.add_argument("--run", action="store_true", help="Run the bot") parser.add_argument("--install", action="store_true", help="Install dependencies") parser.add_argument("--setup", action="store_true", help="Show setup instructions") parser.add_argument("--check", action="store_true", help="Check configuration") args = parser.parse_args() if args.setup: show_setup_help() return if args.install: if install_dependencies(): print("āœ… Ready to run! Use --run to start the bot") return # Load environment file if it exists load_env_file() if args.check or not args.run: config_ok, missing = check_configuration() if not config_ok: print(f"\nāŒ Missing required configuration: {', '.join(missing)}") print("šŸ’” Use --setup for setup instructions") return else: print("\nāœ… Configuration looks good!") if not args.run: print("šŸ’” Use --run to start the bot") return if args.run: # Check dependencies if not check_dependencies(): print("šŸ’” Use --install to install dependencies") return # Check configuration config_ok, missing = check_configuration() if not config_ok: print(f"\nāŒ Missing required configuration: {', '.join(missing)}") print("šŸ’” Use --setup for setup instructions") return # Start the bot print("\nšŸš€ Starting Telegram Bot...") try: from bot import main as run_bot run_bot() except KeyboardInterrupt: print("\nšŸ›‘ Bot stopped by user") except Exception as e: print(f"\nāŒ Error starting bot: {e}") else: # Default: show help parser.print_help() print("\nšŸ’” Common commands:") print(" python start.py --setup # Show setup guide") print(" python start.py --install # Install dependencies") print(" python start.py --check # Check configuration") print(" python start.py --run # Start the bot") if __name__ == "__main__": main()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dev-muhammad/MCPAgent'

If you have feedback or need assistance with the MCP directory API, please join our Discord server