Skip to main content
Glama
vespo92

OPNSense MCP Server

haproxy_backend_health

Monitor and retrieve the health status of a specified backend on OPNSense firewalls using the provided backend name for effective network management.

Instructions

Get health status of a specific backend

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
backendYesBackend name

Implementation Reference

  • The core handler function implementing HAProxy backend health checking. It fetches overall HAProxy stats and extracts the health information for the specified backend name.
    async getBackendHealth(backendName: string): Promise<any> {
      try {
        const stats = await this.getStats();
        return stats.backends[backendName]?.health || {};
      } catch (error) {
        throw new Error(`Failed to get backend health: ${error}`);
      }
    }
  • Helper function that parses the raw HAProxy stats response into structured HAProxyStats format, including backend health details for individual servers.
    private parseStats(data: any): HAProxyStats {
      const stats: HAProxyStats = {
        frontends: {},
        backends: {}
      };
    
      // Parse the stats data from HAProxy
      // This would need to be implemented based on the actual response format
      // For now, returning a basic structure
      if (data.stats) {
        // Parse frontend stats
        if (data.stats.frontends) {
          for (const [name, frontendData] of Object.entries(data.stats.frontends)) {
            stats.frontends[name] = {
              status: (frontendData as any).status || 'unknown',
              sessions: (frontendData as any).scur || 0,
              bytesIn: (frontendData as any).bin || 0,
              bytesOut: (frontendData as any).bout || 0,
              requestRate: (frontendData as any).req_rate || 0,
              errorRate: (frontendData as any).ereq || 0
            };
          }
        }
    
        // Parse backend stats
        if (data.stats.backends) {
          for (const [name, backendData] of Object.entries(data.stats.backends)) {
            const backend = backendData as any;
            stats.backends[name] = {
              status: backend.status || 'unknown',
              activeServers: backend.act || 0,
              backupServers: backend.bck || 0,
              sessions: backend.scur || 0,
              queuedRequests: backend.qcur || 0,
              health: {}
            };
    
            // Parse server health
            if (backend.servers) {
              for (const [serverName, serverData] of Object.entries(backend.servers)) {
                const server = serverData as any;
                stats.backends[name].health[serverName] = {
                  status: server.status === 'UP' ? 'up' : server.status === 'DOWN' ? 'down' : 'maint',
                  lastCheck: server.check_status || '',
                  weight: server.weight || 0,
                  checksPassed: server.chkpass || 0,
                  checksFailed: server.chkfail || 0
                };
              }
            }
          }
        }
      }
    
      return stats;
    }
  • Supporting method that fetches raw HAProxy statistics via API, used by getBackendHealth.
    async getStats(): Promise<HAProxyStats> {
      try {
        const response = await this.client.get('/haproxy/stats/show');
        return this.parseStats(response);
      } catch (error) {
        throw new Error(`Failed to get HAProxy stats: ${error}`);
      }
    }
  • Type definitions for HAProxy statistics, including detailed backend and server health information used by the tool.
    export interface HAProxyStats {
      frontends: {
        [name: string]: {
          status: string;
          sessions: number;
          bytesIn: number;
          bytesOut: number;
          requestRate: number;
          errorRate: number;
        };
      };
      backends: {
        [name: string]: {
          status: string;
          activeServers: number;
          backupServers: number;
          sessions: number;
          queuedRequests: number;
          health: {
            [serverName: string]: {
              status: 'up' | 'down' | 'maint';
              lastCheck: string;
              weight: number;
              checksPassed: number;
              checksFailed: number;
            };
          };
        };
      };
    }
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. It states this is a read operation ('Get'), but doesn't describe what the health status includes, format of return data, error conditions, or any side effects. For a monitoring tool with zero annotation coverage, this leaves significant behavioral gaps.

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 communicates the core purpose without unnecessary words. It's appropriately sized for a simple read operation and front-loads the essential information.

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 monitoring tool with no annotations and no output schema, the description is insufficient. It doesn't explain what health information is returned, format of response data, or how to interpret results. Given the complexity of HAProxy health monitoring and lack of structured output documentation, the description should provide more context about what 'health status' entails.

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?

Schema description coverage is 100% with the single parameter 'backend' documented as 'Backend name'. The description adds no additional parameter context beyond what's in the schema, so it meets the baseline for high schema coverage but doesn't provide extra value like explaining what constitutes a valid backend name or where to find available backends.

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 ('Get health status') and target resource ('of a specific backend'), making the purpose immediately understandable. It doesn't distinguish from siblings like haproxy_backend_list or haproxy_stats, but the verb+resource combination is specific enough for basic understanding.

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 haproxy_backend_list or haproxy_stats. There's no mention of prerequisites, expected context, or comparison with sibling tools that might provide related HAProxy information.

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

Related 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/vespo92/OPNSenseMCP'

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