Skip to main content
Glama

vps_initialize

Set up a fresh VPS with basic configuration and optional services like Node.js, Nginx, Redis, and PM2 for automated server management.

Instructions

Initialize a fresh VPS with basic setup and optional services

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
servicesNo

Implementation Reference

  • Registration of the 'vps_initialize' tool in the listTools handler, including name, description, and input schema definition.
    {
      name: 'vps_initialize',
      description: 'Initialize a fresh VPS with basic setup and optional services',
      inputSchema: {
        type: 'object',
        properties: {
          services: {
            type: 'object',
            properties: {
              nodejs: { type: 'boolean', description: 'Install Node.js' },
              pm2: { type: 'boolean', description: 'Install PM2' },
              rust: { type: 'boolean', description: 'Install Rust' },
              nginx: { type: 'boolean', description: 'Install Nginx' },
              redis: { type: 'boolean', description: 'Install Redis' },
            },
          },
        },
        required: [],
      },
  • Zod schema (VPSServicesSchema) for validating input parameters to the vps_initialize tool.
    const VPSServicesSchema = z.object({
      nodejs: z.boolean().optional().default(false).describe('Install Node.js'),
      pm2: z.boolean().optional().default(false).describe('Install PM2'),
      rust: z.boolean().optional().default(false).describe('Install Rust'),
      nginx: z.boolean().optional().default(false).describe('Install Nginx'),
      redis: z.boolean().optional().default(false).describe('Install Redis'),
    });
  • MCP tool handler for 'vps_initialize' that validates input, calls VPSInitializer.initializeVPS, and formats results.
    private async handleVPSInitialize(
      args: unknown
    ): Promise<{ content: Array<{ type: 'text'; text: string }> }> {
      if (!this.vpsInitializer) {
        throw new Error('SSH connection not established. Please connect first.');
      }
    
      const services = VPSServicesSchema.parse(args);
      const results = await this.vpsInitializer.initializeVPS(services);
    
      const output = results
        .map(
          result => `${result.service}: ${result.success ? 'Success' : 'Failed'} - ${result.message}`
        )
        .join('\n');
    
      return {
        content: [
          {
            type: 'text',
            text: `VPS Initialization Results:\n${output}`,
          },
        ],
      };
    }
  • Main helper method in VPSInitializer class that coordinates the installation of selected services on the VPS.
    async initializeVPS(services: VPSServices): Promise<VPSInitResult[]> {
      const results: VPSInitResult[] = [];
    
      // Always start with system updates
      results.push(await this.updateSystem());
    
      // Install requested services
      if (services.nodejs) {
        results.push(await this.installNodeJS());
      }
    
      if (services.pm2) {
        results.push(await this.installPM2());
      }
    
      if (services.rust) {
        results.push(await this.installRust());
      }
    
      if (services.nginx) {
        results.push(await this.installNginx());
      }
    
      if (services.redis) {
        results.push(await this.installRedis());
      }
    
      return results;
    }
  • VPSInitializer class containing the core logic for VPS initialization, including all private install methods.
    export class VPSInitializer {
      constructor(private sshService: SSHService) {}
    
      async initializeVPS(services: VPSServices): Promise<VPSInitResult[]> {
        const results: VPSInitResult[] = [];
    
        // Always start with system updates
        results.push(await this.updateSystem());
    
        // Install requested services
        if (services.nodejs) {
          results.push(await this.installNodeJS());
        }
    
        if (services.pm2) {
          results.push(await this.installPM2());
        }
    
        if (services.rust) {
          results.push(await this.installRust());
        }
    
        if (services.nginx) {
          results.push(await this.installNginx());
        }
    
        if (services.redis) {
          results.push(await this.installRedis());
        }
    
        return results;
      }
    
      private async updateSystem(): Promise<VPSInitResult> {
        logger.info('Starting system update');
    
        try {
          // Update package lists
          const updateResult = await this.sshService.executeCommand('apt update');
          if (!updateResult.success) {
            return {
              service: 'system-update',
              success: false,
              message: `Failed to update package lists: ${updateResult.stderr}`,
            };
          }
    
          // Upgrade packages
          const upgradeResult = await this.sshService.executeCommand(
            'DEBIAN_FRONTEND=noninteractive apt upgrade -y'
          );
          if (!upgradeResult.success) {
            return {
              service: 'system-update',
              success: false,
              message: `Failed to upgrade packages: ${upgradeResult.stderr}`,
            };
          }
    
          // Install essential packages
          const essentialPackages = [
            'curl',
            'wget',
            'git',
            'unzip',
            'software-properties-common',
            'apt-transport-https',
            'ca-certificates',
            'gnupg',
            'lsb-release',
            'ufw',
          ];
    
          const installResult = await this.sshService.executeCommand(
            `DEBIAN_FRONTEND=noninteractive apt install -y ${essentialPackages.join(' ')}`
          );
    
          if (!installResult.success) {
            return {
              service: 'system-update',
              success: false,
              message: `Failed to install essential packages: ${installResult.stderr}`,
            };
          }
    
          return {
            service: 'system-update',
            success: true,
            message: 'System updated and essential packages installed',
          };
        } catch (error) {
          logger.error('System update failed', { error });
          return {
            service: 'system-update',
            success: false,
            message: `System update failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
          };
        }
      }
    
      private async installNodeJS(): Promise<VPSInitResult> {
        logger.info('Installing Node.js');
    
        try {
          // Install Node.js via NodeSource repository
          const commands = [
            'curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -',
            'DEBIAN_FRONTEND=noninteractive apt install -y nodejs',
            'npm install -g npm@latest',
          ];
    
          for (const command of commands) {
            const result = await this.sshService.executeCommand(command);
            if (!result.success) {
              return {
                service: 'nodejs',
                success: false,
                message: `Failed to install Node.js: ${result.stderr}`,
              };
            }
          }
    
          // Verify installation
          const versionResult = await this.sshService.executeCommand('node --version && npm --version');
          if (!versionResult.success) {
            return {
              service: 'nodejs',
              success: false,
              message: 'Node.js installation failed verification',
            };
          }
    
          return {
            service: 'nodejs',
            success: true,
            message: `Node.js installed successfully: ${versionResult.stdout.trim()}`,
          };
        } catch (error) {
          logger.error('Node.js installation failed', { error });
          return {
            service: 'nodejs',
            success: false,
            message: `Node.js installation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
          };
        }
      }
    
      private async installPM2(): Promise<VPSInitResult> {
        logger.info('Installing PM2');
    
        try {
          const installResult = await this.sshService.executeCommand('npm install -g pm2');
          if (!installResult.success) {
            return {
              service: 'pm2',
              success: false,
              message: `Failed to install PM2: ${installResult.stderr}`,
            };
          }
    
          // Setup PM2 startup script
          await this.sshService.executeCommand('pm2 startup');
          // Note: startup command may require manual execution, but we log it
    
          return {
            service: 'pm2',
            success: true,
            message: 'PM2 installed successfully. Run the startup command if needed.',
          };
        } catch (error) {
          logger.error('PM2 installation failed', { error });
          return {
            service: 'pm2',
            success: false,
            message: `PM2 installation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
          };
        }
      }
    
      private async installRust(): Promise<VPSInitResult> {
        logger.info('Installing Rust');
    
        try {
          const installResult = await this.sshService.executeCommand(
            'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y'
          );
          if (!installResult.success) {
            return {
              service: 'rust',
              success: false,
              message: `Failed to install Rust: ${installResult.stderr}`,
            };
          }
    
          // Source the cargo environment
          await this.sshService.executeCommand('source ~/.cargo/env');
    
          // Verify installation
          const versionResult = await this.sshService.executeCommand('~/.cargo/bin/rustc --version');
          if (!versionResult.success) {
            return {
              service: 'rust',
              success: false,
              message: 'Rust installation failed verification',
            };
          }
    
          return {
            service: 'rust',
            success: true,
            message: `Rust installed successfully: ${versionResult.stdout.trim()}`,
          };
        } catch (error) {
          logger.error('Rust installation failed', { error });
          return {
            service: 'rust',
            success: false,
            message: `Rust installation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
          };
        }
      }
    
      private async installNginx(): Promise<VPSInitResult> {
        logger.info('Installing Nginx');
    
        try {
          const installResult = await this.sshService.executeCommand(
            'DEBIAN_FRONTEND=noninteractive apt install -y nginx'
          );
          if (!installResult.success) {
            return {
              service: 'nginx',
              success: false,
              message: `Failed to install Nginx: ${installResult.stderr}`,
            };
          }
    
          // Enable and start Nginx
          const enableResult = await this.sshService.executeCommand('systemctl enable nginx');
          const startResult = await this.sshService.executeCommand('systemctl start nginx');
    
          if (!enableResult.success || !startResult.success) {
            return {
              service: 'nginx',
              success: false,
              message: 'Failed to enable or start Nginx service',
            };
          }
    
          // Configure firewall
          await this.sshService.executeCommand('ufw allow "Nginx Full"');
    
          return {
            service: 'nginx',
            success: true,
            message: 'Nginx installed and configured successfully',
          };
        } catch (error) {
          logger.error('Nginx installation failed', { error });
          return {
            service: 'nginx',
            success: false,
            message: `Nginx installation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
          };
        }
      }
    
      private async installRedis(): Promise<VPSInitResult> {
        logger.info('Installing Redis');
    
        try {
          const installResult = await this.sshService.executeCommand(
            'DEBIAN_FRONTEND=noninteractive apt install -y redis-server'
          );
          if (!installResult.success) {
            return {
              service: 'redis',
              success: false,
              message: `Failed to install Redis: ${installResult.stderr}`,
            };
          }
    
          // Configure Redis to start on boot
          const enableResult = await this.sshService.executeCommand('systemctl enable redis-server');
          const startResult = await this.sshService.executeCommand('systemctl start redis-server');
    
          if (!enableResult.success || !startResult.success) {
            return {
              service: 'redis',
              success: false,
              message: 'Failed to enable or start Redis service',
            };
          }
    
          // Test Redis connection
          const testResult = await this.sshService.executeCommand('redis-cli ping');
          if (!testResult.success || !testResult.stdout.includes('PONG')) {
            return {
              service: 'redis',
              success: false,
              message: 'Redis installation failed verification',
            };
          }
    
          return {
            service: 'redis',
            success: true,
            message: 'Redis installed and configured successfully',
          };
        } catch (error) {
          logger.error('Redis installation failed', { error });
          return {
            service: 'redis',
            success: false,
            message: `Redis installation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
          };
        }
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies a creation/write operation ('initialize') but doesn't disclose critical traits like whether this is destructive to existing VPS configurations, authentication requirements, execution time, error handling, or rate limits. The phrase 'basic setup' is vague without elaboration.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. Every word earns its place: 'initialize' (action), 'fresh VPS' (resource), 'basic setup' (scope), and 'optional services' (parameter hint). There's no redundancy or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of initializing a VPS with multiple service options, no annotations, no output schema, and low schema coverage, the description is inadequate. It lacks details on what 'basic setup' entails, expected outcomes, error conditions, or how the tool interacts with siblings, making it incomplete for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, but the description adds some context by mentioning 'optional services', which aligns with the 'services' parameter in the schema. However, it doesn't explain the structure of the services object or provide examples, leaving significant gaps in understanding how to use the parameters effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('initialize') and resource ('fresh VPS'), specifying 'with basic setup and optional services'. It distinguishes from siblings like 'execute_command' or 'nginx_setup' by focusing on comprehensive VPS initialization rather than specific tasks. However, it doesn't explicitly differentiate from 'github_cicd_setup' which might also involve setup activities.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'nginx_setup' for just Nginx installation or 'github_cicd_setup' for CI/CD setup. It mentions 'optional services' but doesn't specify prerequisites, timing, or exclusions, leaving the agent to guess based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/oxy-Op/DevPilot'

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