Skip to content

ksawaray/systemd-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Server Manager

Overview

MCP Server Manager is a daemon tool for managing multiple server processes (startup, shutdown, monitoring, and automatic restart) based on the configuration file mcp_server.conf.

Each server process is automatically assigned a unique ID based on its startup command. Using the mcpctl command-line tool, you can operate individual servers by specifying their IDs.

It operates as a systemd service and enhances service availability by automatically restarting processes that terminate unexpectedly.

Key Features

  • Simple Configuration File: Simply describe the commands of servers you want to manage in mcp_server.conf.
  • Automatic ID Generation: Each server command is automatically assigned a unique ID (hash) based on its content.
  • Command-line Operations: Use mcpctl to check IDs with status and operate individual servers with start, stop, and restart.
  • Automatic Process Restart: When a process terminates for reasons other than mcpctl stop, the daemon automatically restarts it.
  • systemd Integration: Easy service registration using mcp-manager.service.

Workflow

  1. Configuration: Edit /etc/mcp/mcp_server.conf to describe the startup commands of servers you want to manage, one per line.
  2. Reload: Execute sudo systemctl restart mcp-manager.service to reflect configuration changes to the daemon.
  3. Check: Run mcpctl status to check the status and automatically generated IDs of each server.
  4. Operations: Use the confirmed IDs with commands like mcpctl start <ID> or mcpctl stop <ID> to manage individual servers.

Setup and Installation

Automatic Installation (Recommended)

  1. Run the Installation Script

    sudo ./install.sh

    This script automatically performs the following tasks:

    • Creates necessary directories (/usr/local/lib/mcp-manager/, /etc/mcp/)
    • Copies mcp_manager.py to /usr/local/lib/mcp-manager/
    • Copies mcpctl to /usr/local/bin/ (adds to PATH)
    • Copies configuration file mcp_server.conf to /etc/mcp/
    • Installs and registers systemd service file
    • Starts the service and enables automatic startup
  2. Verify Installation

    mcpctl status

Manual Installation

For manual installation, follow these steps:

  1. Grant Execute Permissions Grant execute permissions to scripts in the project.

    chmod +x mcp_manager.py mcpctl mcp_server.sh install.sh uninstall.sh
  2. Create Directories

    sudo mkdir -p /usr/local/lib/mcp-manager
    sudo mkdir -p /etc/mcp
  3. Deploy Files

    sudo cp mcp_manager.py /usr/local/lib/mcp-manager/
    sudo cp mcpctl /usr/local/bin/
    sudo cp mcp_server.conf /etc/mcp/mcp_server.conf
  4. Edit Configuration File Edit the configuration file as needed.

    sudo vi /etc/mcp/mcp_server.conf
  5. Verify and Start systemd Service File Open mcp-manager.service and verify the paths are correct. Then start the service as follows:

    sudo cp mcp-manager.service /etc/systemd/system/
    sudo systemctl daemon-reload
    sudo systemctl start mcp-manager.service
    sudo systemctl enable mcp-manager.service

Uninstallation

To completely remove MCP Server Manager from the system:

sudo ./uninstall.sh

This script performs the following tasks:

  • Stops and disables the systemd service
  • Removes service files
  • Removes installed files
  • Removes configuration files (with confirmation)

Using mcpctl

  • Check Status: Displays the status and IDs of all servers described in mcp_server.conf.

    mcpctl status

    Example Output:

    ID       STATUS    PID          UPTIME COMMAND
    -------- --------- ------- --------------- --------------------------------
    a1b2c3d  Running   12345 0 days, 0:10:30 /data/systemd-mcp/mcp_server.sh
    e4f5g6h  Stopped     N/A             N/A /usr/bin/python3 /path/to/another/server
    
  • Start Server: Use ID to start a stopped (Stopped) or idle (Idle) server.

    mcpctl start e4f5g6h
  • Start All Servers from Configuration File: Reload the configuration file and start all servers.

    mcpctl apply
  • Stop Server: Use ID to stop a running (Running) server. Servers stopped this way are excluded from automatic restart.

    mcpctl stop a1b2c3d
  • Restart Server: Use ID to restart a running server.

    mcpctl restart a1b2c3d

About

A systemd-based daemon for managing multiple MCP (Model Context Protocol) servers with automatic restart, process monitoring, and CLI control via mcpctl.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors