Skip to main content
Glama

MCP Server - Modular Architecture

This MCP (Model Context Protocol) server is built with a clean, modular architecture for maintainable, scalable, and robust development.

๐Ÿ“ Project Structure

MCP-test/ โ”œโ”€โ”€ main.py # Main entry point โ”œโ”€โ”€ config.py # Configuration and constants โ”œโ”€โ”€ persistence.py # Data persistence layer โ”œโ”€โ”€ scheduler.py # Job scheduling functionality โ”œโ”€โ”€ tools/ # MCP tools organized by concern โ”‚ โ”œโ”€โ”€ __init__.py # Tools package initialization and registry โ”‚ โ”œโ”€โ”€ basic_tools.py # Basic utility tools โ”‚ โ”œโ”€โ”€ control_tools.py # Server control tools (restart, shutdown, etc) โ”‚ โ”œโ”€โ”€ file_tools.py # File system operations โ”‚ โ”œโ”€โ”€ persistence_tools.py # Persistence management tools โ”‚ โ”œโ”€โ”€ scheduling_tools.py # Scheduling-related tools โ”‚ โ”œโ”€โ”€ system_tools.py # System information and commands โ”‚ โ”œโ”€โ”€ telegram_tools.py # Telegram integration โ”‚ โ””โ”€โ”€ youtube_tools.py # YouTube-related tools โ”œโ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ .env # Environment variables (create this) โ””โ”€โ”€ README.md # This file

๐Ÿš€ Quick Start

  1. Install dependencies:

    pip install -r requirements.txt
  2. Create environment file:

    # Create .env file with your configuration TG_TOKEN=your_telegram_bot_token ADMIN_ID=your_telegram_chat_id
  3. Run the server:

    python main.py

๐Ÿ“‹ Available Tools

Basic Tools

  • echo โ€” Echo back input text

File Tools

  • read_file โ€” Read the contents of a file

  • write_file โ€” Write content to a file

  • create_file โ€” Create a new empty file

  • create_folder โ€” Create a new directory

  • list_files โ€” List files and folders in a directory

  • delete_file โ€” Delete a file

  • rename_file โ€” Rename or move a file

  • move_folder โ€” Move a folder (directory) to a new location

System Tools

  • system_info โ€” Get basic system information (platform, memory, CPU, etc.)

  • list_processes โ€” List running processes (PID, name, user)

  • run_python_code โ€” Execute a Python code snippet and return the output

  • install_python_library โ€” Install a Python library (via pip) and update requirements.txt

Telegram Integration

  • send_telegram_message โ€” Send Telegram messages, audio, video, or documents (with optional metadata)

  • receive_telegram_updates โ€” Receive and download incoming Telegram messages and files

Scheduling & Job Tools (still in testing)

  • schedule_telegram_message โ€” Schedule a Telegram message to be sent at a specific time (supports ISO datetime or relative times like "in 10 minutes")

  • schedule_function_call โ€” Schedule any registered function to run once at a specified time

  • schedule_recurring_job โ€” Schedule recurring jobs using cron expressions or intervals (e.g., "every 5 minutes", "0 9 ** 1-5")

  • list_scheduled_jobs โ€” List all currently scheduled jobs with details

  • cancel_scheduled_job โ€” Cancel a scheduled job by its ID

  • get_available_functions โ€” List all functions available for scheduling

  • get_job_execution_log โ€” View the execution history and results of scheduled jobs

Persistence Tools

  • update_persistent_info โ€” Add or update a key-value pair in persistent storage

  • get_persistent_info โ€” Retrieve all persistent data, or a specific key's value

  • delete_persistent_info_key โ€” Delete a key from persistent storage

Control Tools

  • type_text โ€” Simulate typing text using the keyboard

  • press_hotkey โ€” Press a combination of keys as a hotkey (e.g., Ctrl+Tab)

  • switch_to_window โ€” Switch focus to a window with a specified title

  • list_open_windows โ€” List the titles of all currently open windows

  • move_mouse_to โ€” Move the mouse cursor to specified screen coordinates

  • click_mouse โ€” Click the mouse at specified coordinates or at the current position

YouTube Tools

  • youtube_download_video โ€” Download a YouTube video as MP4

  • youtube_download_audio โ€” Download YouTube audio as MP3

  • youtube_video_info โ€” Get detailed YouTube video information

๐Ÿ”ง Architecture Benefits

Separation of Concerns

  • config.py: Centralized configuration

  • persistence.py: Data storage abstraction

  • scheduler.py: Scheduling logic isolated

  • tools/: Tools organized by functionality

Maintainability

  • Add new tools by creating new modules

  • Clear dependencies between components

  • Consistent error handling and logging

Scalability

  • Modular design for easy extension

  • Shared MCP instance prevents conflicts

  • Function registry enables dynamic scheduling

๐Ÿ“Š Data Persistence

The server automatically persists:

  • Scheduled Jobs: Survives server restarts

  • Execution Logs: Detailed job run history

  • Persistent Info: Custom key-value storage

Files created:

  • scheduled_jobs.json โ€” Job definitions

  • job_execution_log.json โ€” Execution history

  • persistent_info.json โ€” Custom data

  • main.log โ€” Application logs

  • error.log โ€” Error logs

๐Ÿ› ๏ธ Development

Adding New Tools

  1. Create a new module in tools/

  2. Import the shared MCP instance: from . import mcp

  3. Define your tool function with @mcp.tool() decorator

  4. Register the function in tools/__init__.py if needed

Adding New Persistence Functions

  1. Add functions to persistence.py

  2. Import and use them in your tools

  3. Follow the existing pattern for error handling

๐Ÿ” Troubleshooting

  • Check logs in main.log and error.log

  • Verify environment variables in .env

  • Ensure all dependencies are installed

  • Check file permissions for persistence

-
security - not tested
F
license - not found
-
quality - not tested

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/karar-hayder/Simple-MCP'

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