Skip to main content
Glama

restart_service

Restart services with automated health checks and rollback to maintain reliability during infrastructure updates on Last Rock MCP.

Instructions

Restart a service with pre/post health checks and automatic rollback. DO NOT use ssh_exec('docker restart') - always use this tool instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
service_nameYesService name (e.g., 'garza-home-mcp', 'nginx', 'postgres')
service_typeYesService type (fly_app/docker/systemd)
health_check_urlNoOptional URL to check service health

Implementation Reference

  • Schema definition for the 'restart_service' tool, specifying input parameters: service_name (required), service_type (required), and optional health_check_url.
    {
      name: "restart_service",
      description: "Restart a service with pre/post health checks and automatic rollback. DO NOT use ssh_exec('docker restart') - always use this tool instead.",
      inputSchema: {
        type: "object",
        properties: {
          service_name: {
            type: "string",
            description: "Service name (e.g., 'garza-home-mcp', 'nginx', 'postgres')"
          },
          service_type: {
            type: "string",
            description: "Service type (fly_app/docker/systemd)"
          },
          health_check_url: {
            type: "string",
            description: "Optional URL to check service health"
          }
        },
        required: ["service_name", "service_type"]
      }
    },
  • Handler logic for 'restart_service' tool within the CallToolRequestSchema switch statement. Extracts parameters and calls executeOrchestrator with operation 'maintain/restart-service'.
    case "restart_service": {
      const { service_name, service_type, health_check_url } = args as {
        service_name: string;
        service_type: string;
        health_check_url?: string;
      };
      
      const params: Record<string, string> = {
        service_name,
        service_type
      };
      
      if (health_check_url) {
        params.health_check_url = health_check_url;
      }
      
      result = executeOrchestrator("maintain/restart-service", params);
      break;
    }
  • Helper function executeOrchestrator that runs the orchestrator.py Python script with the given operation and parameters, handling JSON parsing and errors. Used by restart_service handler.
    function executeOrchestrator(operation: string, params: Record<string, string> = {}): any {
      const paramStr = Object.entries(params)
        .map(([key, value]) => `${key}="${value}"`)
        .join(" ");
      
      const cmd = `cd ${ORCHESTRATOR_PATH} && python orchestrator.py ${operation} ${paramStr}`;
      
      try {
        const output = execSync(cmd, {
          encoding: "utf-8",
          maxBuffer: 10 * 1024 * 1024
        });
        
        // Try to parse as JSON, fallback to plain text
        try {
          return JSON.parse(output);
        } catch {
          return { output: output.trim() };
        }
      } catch (error: any) {
        return {
          success: false,
          error: error.message,
          stderr: error.stderr?.toString() || "",
          stdout: error.stdout?.toString() || ""
        };
      }
    }
  • src/index.ts:46-166 (registration)
    The tools array registers the 'restart_service' tool (among others) which is returned by the ListToolsRequestSchema handler.
    const tools: Tool[] = [
      {
        name: "deploy_mcp_server",
        description: "Deploy MCP server to Fly.io with state tracking, locks, and health checks. DO NOT use ssh_exec for deployments - always use this tool instead.",
        inputSchema: {
          type: "object",
          properties: {
            app_name: {
              type: "string",
              description: "Fly.io app name (e.g., 'garza-home-mcp')"
            },
            source_dir: {
              type: "string",
              description: "Source directory containing the MCP server code"
            },
            region: {
              type: "string",
              description: "Fly.io region (default: dfw)"
            }
          },
          required: ["app_name"]
        }
      },
      {
        name: "deploy_cloudflare_worker",
        description: "Deploy Cloudflare Worker with state tracking and health checks. DO NOT use ssh_exec('wrangler deploy') - always use this tool instead.",
        inputSchema: {
          type: "object",
          properties: {
            worker_name: {
              type: "string",
              description: "Worker name (e.g., 'voicenotes-webhook')"
            },
            source_dir: {
              type: "string",
              description: "Source directory containing wrangler.toml"
            },
            env: {
              type: "string",
              description: "Environment (production/staging, default: production)"
            }
          },
          required: ["worker_name"]
        }
      },
      {
        name: "restart_service",
        description: "Restart a service with pre/post health checks and automatic rollback. DO NOT use ssh_exec('docker restart') - always use this tool instead.",
        inputSchema: {
          type: "object",
          properties: {
            service_name: {
              type: "string",
              description: "Service name (e.g., 'garza-home-mcp', 'nginx', 'postgres')"
            },
            service_type: {
              type: "string",
              description: "Service type (fly_app/docker/systemd)"
            },
            health_check_url: {
              type: "string",
              description: "Optional URL to check service health"
            }
          },
          required: ["service_name", "service_type"]
        }
      },
      {
        name: "check_services_health",
        description: "Check health of one or more services. Safe read-only operation.",
        inputSchema: {
          type: "object",
          properties: {
            service_group: {
              type: "string",
              description: "Service group: 'all', 'mcp_servers', 'workers', 'infrastructure'"
            },
            service_names: {
              type: "array",
              items: { type: "string" },
              description: "Optional specific service names to check"
            }
          }
        }
      },
      {
        name: "trigger_auto_recovery",
        description: "Trigger automatic recovery for a failed service using predefined playbooks.",
        inputSchema: {
          type: "object",
          properties: {
            service_name: {
              type: "string",
              description: "Service that failed"
            },
            failure_type: {
              type: "string",
              description: "Type of failure: 'crash', 'health_check_failed', 'deployment_failed'"
            }
          },
          required: ["service_name", "failure_type"]
        }
      },
      {
        name: "get_infrastructure_status",
        description: "Get comprehensive overview of entire infrastructure. Safe read-only operation.",
        inputSchema: {
          type: "object",
          properties: {
            include_history: {
              type: "boolean",
              description: "Include recent operation history (default: true)"
            },
            include_locks: {
              type: "boolean",
              description: "Include active locks (default: true)"
            }
          }
        }
      }
    ];

Latest Blog Posts

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/itsablabla/lastrock-mcp'

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