Skip to main content
Glama

ubuntu_nginx_control

Control Nginx web server on Ubuntu systems via SSH connections. Start, stop, restart, check status, reload configurations, or verify configuration files remotely.

Instructions

Control Nginx web server on Ubuntu

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesID of an active SSH connection
actionYesAction to perform (start, stop, restart, status, reload, check-config)
sudoNoWhether to run the command with sudo (default: true)

Implementation Reference

  • Main execution logic for controlling Nginx web server (start, stop, restart, status, reload, check-config) via SSH using systemctl and nginx commands.
    async ubuntu_nginx_control(params) {
      const { connectionId, action, sudo = true } = params;
      
      try {
        const conn = getConnection(connectionMap, connectionId);
        
        // Validate action
        const validActions = ['start', 'stop', 'restart', 'status', 'reload', 'check-config'];
        if (!validActions.includes(action)) {
          throw new Error(`Invalid action: ${action}. Valid actions are: ${validActions.join(', ')}`);
        }
        
        let command = '';
        const sudoPrefix = sudo ? 'sudo ' : '';
        
        switch (action) {
          case 'start':
          case 'stop':
          case 'restart':
          case 'status':
          case 'reload':
            command = `${sudoPrefix}systemctl ${action} nginx`;
            break;
          case 'check-config':
            command = `${sudoPrefix}nginx -t`;
            break;
        }
        
        const result = await executeSSHCommand(conn, command);
        
        let status = result.code === 0 ? 'success' : 'error';
        let message = result.stdout || result.stderr;
        
        if (action === 'status') {
          // Extract status info from systemctl output
          const isActive = message.includes('Active: active');
          status = isActive ? 'active' : 'inactive';
        }
        
        return {
          content: [{
            type: 'text',
            text: `Nginx ${action} result: ${status}\n\n${message}`
          }]
        };
      } catch (error: any) {
        return {
          content: [{ type: 'text', text: `Nginx control error: ${error.message}` }],
          isError: true
        };
      }
    },
  • Input schema defining parameters for the ubuntu_nginx_control tool: connectionId (required), action (required), sudo (optional).
    ubuntu_nginx_control: {
      description: 'Control Nginx web server on Ubuntu',
      inputSchema: {
        type: 'object',
        properties: {
          connectionId: {
            type: 'string',
            description: 'ID of an active SSH connection'
          },
          action: {
            type: 'string',
            description: 'Action to perform (start, stop, restart, status, reload, check-config)'
          },
          sudo: {
            type: 'boolean',
            description: 'Whether to run the command with sudo (default: true)'
          }
        },
        required: ['connectionId', 'action']
      }
    },
  • src/index.ts:294-296 (registration)
    Handler dispatch logic in the main CallToolRequestSchema handler that routes ubuntu_* tool calls to the corresponding function in ubuntuToolHandlers.
    if (toolName.startsWith('ubuntu_') && ubuntuToolHandlers[toolName]) {
      return ubuntuToolHandlers[toolName](request.params.arguments);
    }
  • Creates the list of Ubuntu tools including ubuntu_nginx_control schema for the overridden ListToolsRequestSchema handler.
    // Create array of Ubuntu tools
    const ubuntuTools = Object.entries(ubuntuToolSchemas).map(([name, schema]) => ({
      name,
      description: schema.description,
      inputSchema: schema.inputSchema
    }));
  • Utility function to execute SSH commands with timeout and error handling, used by the tool handler.
    async function executeSSHCommand(conn: Client, command: string, timeout = 60000): Promise<{
      code: number;
      signal: string;
      stdout: string;
      stderr: string;
    }> {
      return new Promise((resolve, reject) => {
        // Set up timeout
        const timeoutId = setTimeout(() => {
          reject(new Error(`Command execution timed out after ${timeout}ms`));
        }, timeout);
        
        conn.exec(command, {}, (err: Error | undefined, stream: any) => {
          if (err) {
            clearTimeout(timeoutId);
            return reject(new Error(`Failed to execute command: ${err.message}`));
          }
          
          let stdout = '';
          let stderr = '';
          
          stream.on('close', (code: number, signal: string) => {
            clearTimeout(timeoutId);
            resolve({
              code,
              signal,
              stdout: stdout.trim(),
              stderr: stderr.trim()
            });
          });
          
          stream.on('data', (data: Buffer) => {
            stdout += data.toString();
          });
          
          stream.stderr.on('data', (data: Buffer) => {
            stderr += data.toString();
          });
        });
      });
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but provides minimal information. It mentions 'Control' which implies system administration actions, but doesn't disclose that this likely requires root/sudo privileges (though the schema hints at this), doesn't mention what happens when actions fail, and provides no information about output format or error conditions.

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 extremely concise at just 5 words, front-loading the essential information with zero wasted words. Every word earns its place by specifying the target (Nginx), platform (Ubuntu), and action type (Control).

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?

For a system administration tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'Control' entails operationally, doesn't mention that this requires an established SSH connection (though the parameter implies it), and provides no information about what the tool returns or how to interpret results.

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?

With 100% schema description coverage, the baseline is 3. The description adds no parameter-specific information beyond what's already documented in the schema. It doesn't explain the relationship between parameters, doesn't provide examples of valid 'action' values (though the schema lists them), and offers no additional context about parameter usage.

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 verb ('Control') and resource ('Nginx web server on Ubuntu'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential alternatives like 'ssh_exec' which could also control Nginx, or explain why this specialized tool exists when general SSH execution is available.

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. It doesn't mention prerequisites (like needing an active SSH connection first), doesn't compare it to the 'ssh_exec' sibling tool, and offers no context about when this specialized Nginx control tool is preferable to general command execution.

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/mixelpixx/SSH-MCP'

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