Skip to main content
Glama

server_guard

Idempotent

Monitor server security by installing automated checks for disk, RAM, CPU, and audit logs via scheduled cron jobs. Use SSH access to start, stop, or view monitoring status and threshold breaches.

Instructions

Manage autonomous security monitoring daemon on a server. Actions: 'start' installs guard as remote cron (checks disk/RAM/CPU/audit every 5 min), 'stop' removes guard cron entry, 'status' shows whether guard is active with last check time and any threshold breaches. Requires SSH access to target server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverNoServer name or IP. Auto-selected if only one server exists.
actionYesGuard action: 'start' installs guard cron, 'stop' removes it, 'status' shows current state and recent breaches.

Implementation Reference

  • Main handler function for the 'server_guard' tool, executing actions 'start', 'stop', and 'status'.
    export async function handleServerGuard(params: {
      server?: string;
      action: "start" | "stop" | "status";
    }): Promise<McpResponse> {
      try {
        const servers = getServers();
        if (servers.length === 0) {
          return mcpError("No servers found", undefined, [
            { command: "kastell add", reason: "Add a server first" },
          ]);
        }
    
        const server = resolveServerForMcp(params, servers);
        if (!server) {
          if (params.server) {
            return mcpError(
              `Server not found: ${params.server}`,
              `Available servers: ${servers.map((s) => s.name).join(", ")}`,
            );
          }
          return mcpError(
            "Multiple servers found. Specify which server to use.",
            `Available: ${servers.map((s) => s.name).join(", ")}`,
          );
        }
    
        switch (params.action) {
          case "start": {
            const result = await startGuard(server.ip, server.name);
            if (!result.success) {
              return mcpError(result.error ?? "Failed to start guard", result.hint);
            }
            return mcpSuccess({
              success: true,
              message: `Guard installed on ${server.name}. Runs every 5 minutes via cron.`,
            });
          }
    
          case "stop": {
            const result = await stopGuard(server.ip, server.name);
            if (!result.success) {
              return mcpError(result.error ?? "Failed to stop guard", result.hint);
            }
            return mcpSuccess({
              success: true,
              message: `Guard removed from ${server.name}.`,
            });
          }
    
          case "status": {
            const result = await guardStatus(server.ip, server.name);
            if (!result.success) {
              return mcpError(result.error ?? "Failed to check guard status");
            }
            return mcpSuccess({
              isActive: result.isActive,
              lastRunAt: result.lastRunAt,
              breaches: result.breaches,
              logTail: result.logTail,
              installedAt: result.installedAt,
            });
          }
    
          default:
            return mcpError(`Invalid action: ${String(params.action)}`, "Valid actions: start, stop, status");
        }
      } catch (error: unknown) {
        return mcpError(getErrorMessage(error));
      }
    }
  • Input validation schema for the 'server_guard' tool parameters.
    export const serverGuardSchema = {
      server: z.string().optional().describe("Server name or IP. Auto-selected if only one server exists."),
      action: z.enum(["start", "stop", "status"]).describe("Guard action: 'start' installs guard cron, 'stop' removes it, 'status' shows current state and recent breaches."),
    };
  • Tool registration for 'server_guard' in the MCP server setup.
    server.registerTool("server_guard", {
      description:
        "Manage autonomous security monitoring daemon on a server. Actions: 'start' installs guard as remote cron (checks disk/RAM/CPU/audit every 5 min), 'stop' removes guard cron entry, 'status' shows whether guard is active with last check time and any threshold breaches. Requires SSH access to target server.",
      inputSchema: serverGuardSchema,
      annotations: {
        title: "Guard Daemon",
        readOnlyHint: false,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true,
      },
    }, async (params) => {
      return handleServerGuard(params);
    });
Behavior4/5

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

Beyond annotations (readOnlyHint:false, destructiveHint:false), the description adds crucial behavioral context: it specifies the 5-minute check interval, exact metrics monitored (disk/RAM/CPU/audit), cron-based implementation, and authentication requirements (SSH). It does not contradict annotations.

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

Conciseness4/5

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

The description is front-loaded with purpose ('Manage autonomous security monitoring daemon'), followed by specific action breakdowns and prerequisites. Every sentence conveys distinct operational information (cron nature, check interval, metrics, SSH requirement) with minimal redundancy.

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

Completeness4/5

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

Given the rich schema (100% coverage) and good annotations, the description adequately covers the tool's purpose and mechanics. It hints at return values for 'status' (active state, breaches, last check time) though explicit return format documentation would strengthen it further given the lack of output schema.

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

Parameters4/5

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

With 100% schema coverage, the baseline is 3. The description adds value by explaining the operational semantics of each action value in the context of the daemon (e.g., 'start' means installing a remote cron that performs specific checks every 5 minutes), which goes beyond the schema's basic descriptions.

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

Purpose5/5

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

The description clearly states 'Manage autonomous security monitoring daemon on a server' with specific verbs and resources. It distinguishes from siblings (e.g., server_audit, server_backup) by specifying this installs an autonomous cron-based monitoring daemon rather than performing one-time audits or backups.

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

Usage Guidelines4/5

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

The description details prerequisites ('Requires SSH access to target server') and explains what each action does (start/stop/status). However, it lacks explicit guidance on when to choose this over server_audit or other monitoring siblings, though the daemon nature implies continuous monitoring use cases.

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/kastelldev/kastell'

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