Skip to main content
Glama
amittell

firewalla-mcp-server

get_network_rules

Retrieve firewall rules and conditions to monitor network security, analyze traffic patterns, and manage access policies with filtering options.

Instructions

Retrieve firewall rules and conditions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitYesMaximum number of rules to return (required)
queryNoSearch conditions for filtering rules

Implementation Reference

  • Core handler implementation: validates parameters (limit, query), calls Firewalla API getNetworkRules, applies optimization if summary_only, formats unified response with timestamps and safe access.
    export class GetNetworkRulesHandler extends BaseToolHandler {
      name = 'get_network_rules';
      description =
        'Retrieve firewall rules and conditions including target domains, actions, and status. Requires limit parameter. Data is cached for 10 minutes for performance.';
      category = 'rule' as const;
    
      constructor() {
        super({
          enableGeoEnrichment: false, // No IP fields in network rules
          enableFieldNormalization: true,
          additionalMeta: {
            data_source: 'network_rules',
            entity_type: 'firewall_rules',
            supports_geographic_enrichment: false,
            supports_field_normalization: true,
            supports_pagination: true,
            supports_filtering: true,
            standardization_version: '2.0.0',
          },
        });
      }
    
      async execute(
        args: ToolArgs,
        firewalla: FirewallaClient
      ): Promise<ToolResponse> {
        try {
          // Parameter validation with standardized limits
          const limitValidation = ParameterValidator.validateNumber(
            args?.limit,
            'limit',
            {
              required: false,
              defaultValue: 200,
              ...getLimitValidationConfig(this.name),
            }
          );
    
          if (!limitValidation.isValid) {
            return createErrorResponse(
              this.name,
              'Parameter validation failed',
              ErrorType.VALIDATION_ERROR,
              undefined,
              limitValidation.errors
            );
          }
    
          const query = args?.query;
          const summaryOnly = (args?.summary_only as boolean) ?? false;
          const limit = limitValidation.sanitizedValue! as number;
    
          const response = await withToolTimeout(
            async () => firewalla.getNetworkRules(query, limit),
            this.name
          );
    
          // Apply additional optimization if summary mode requested
          let optimizedResponse: any = response;
          if (summaryOnly) {
            optimizedResponse = optimizeRuleResponse(response as any, {
              ...DEFAULT_OPTIMIZATION_CONFIG,
              summaryMode: {
                maxItems: limit,
                includeFields: [
                  'id',
                  'action',
                  'target',
                  'direction',
                  'status',
                  'hit',
                ],
                excludeFields: ['notes', 'schedule', 'timeUsage', 'scope'],
              },
            });
          }
    
          const startTime = Date.now();
    
          const unifiedResponseData = {
            count: SafeAccess.getNestedValue(optimizedResponse, 'count', 0),
            summary_mode: summaryOnly,
            limit_applied: summaryOnly ? limit : undefined,
            rules: summaryOnly
              ? optimizedResponse.results
              : SafeAccess.safeArrayMap(
                  (response.results as any[]).slice(0, limit),
                  (rule: any) => ({
                    id: SafeAccess.getNestedValue(rule, 'id', 'unknown'),
                    action: SafeAccess.getNestedValue(rule, 'action', 'unknown'),
                    target: rule.target
                      ? {
                          type: SafeAccess.getNestedValue(
                            rule.target,
                            'type',
                            'unknown'
                          ),
                          value: SafeAccess.getNestedValue(
                            rule.target,
                            'value',
                            'unknown'
                          ),
                          ...(rule.target?.dnsOnly && {
                            dnsOnly: rule.target.dnsOnly,
                          }),
                          ...(rule.target?.port && { port: rule.target.port }),
                        }
                      : { type: 'unknown', value: 'unknown' },
                    direction: SafeAccess.getNestedValue(
                      rule,
                      'direction',
                      'unknown'
                    ),
                    gid: SafeAccess.getNestedValue(rule, 'gid', 'unknown'),
                    group: SafeAccess.getNestedValue(rule, 'group', undefined),
                    scope: SafeAccess.getNestedValue(rule, 'scope', undefined),
                    notes: SafeAccess.getNestedValue(rule, 'notes', ''),
                    status: SafeAccess.getNestedValue(rule, 'status', 'unknown'),
                    hit: SafeAccess.getNestedValue(rule, 'hit', undefined),
                    schedule: SafeAccess.getNestedValue(
                      rule,
                      'schedule',
                      undefined
                    ),
                    timeUsage: SafeAccess.getNestedValue(
                      rule,
                      'timeUsage',
                      undefined
                    ),
                    protocol: SafeAccess.getNestedValue(
                      rule,
                      'protocol',
                      undefined
                    ),
                    created_at: safeUnixToISOString(
                      SafeAccess.getNestedValue(rule, 'ts', undefined) as
                        | number
                        | undefined,
                      undefined
                    ),
                    updated_at: safeUnixToISOString(
                      SafeAccess.getNestedValue(rule, 'updateTs', undefined) as
                        | number
                        | undefined,
                      undefined
                    ),
                    resume_at: safeUnixToISOString(
                      SafeAccess.getNestedValue(rule, 'resumeTs', undefined) as
                        | number
                        | undefined,
                      undefined
                    ),
                  })
                ),
            next_cursor: SafeAccess.getNestedValue(
              summaryOnly ? optimizedResponse : response,
              'next_cursor',
              undefined
            ),
            ...(summaryOnly &&
              optimizedResponse.pagination_note && {
                pagination_note: optimizedResponse.pagination_note,
              }),
          };
    
          const executionTime = Date.now() - startTime;
          return this.createUnifiedResponse(unifiedResponseData, {
            executionTimeMs: executionTime,
          });
        } catch (error: unknown) {
          if (error instanceof TimeoutError) {
            return createTimeoutErrorResponse(
              this.name,
              error.duration,
              10000 // Default timeout
            );
          }
    
          const errorMessage =
            error instanceof Error ? error.message : 'Unknown error occurred';
          return this.createErrorResponse(
            `Failed to get network rules: ${errorMessage}`
          );
        }
      }
    }
  • MCP protocol input schema definition for get_network_rules tool, specifying required 'limit' (1-1000) and optional 'query' parameters.
    name: 'get_network_rules',
    description: 'Retrieve firewall rules and conditions',
    inputSchema: {
      type: 'object',
      properties: {
        limit: {
          type: 'number',
          description: 'Maximum number of rules to return (required)',
          minimum: 1,
          maximum: 1000,
        },
        query: {
          type: 'string',
          description: 'Search conditions for filtering rules',
        },
      },
      required: ['limit'],
    },
  • Registers the GetNetworkRulesHandler instance in the central ToolRegistry during automatic handler registration.
    this.register(new GetNetworkRulesHandler());
  • src/server.ts:833-833 (registration)
    Calls setupTools which uses the ToolRegistry to register all tool handlers (including get_network_rules) with the MCP Server.
    setupTools(this.server, this.firewalla);
  • Defines validation limits configuration for get_network_rules tool using STANDARD_LIMITS.BASIC_QUERY.
    get_network_rules: STANDARD_LIMITS.BASIC_QUERY,
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states this is a retrieval operation, implying read-only behavior, but doesn't mention any constraints like rate limits, authentication requirements, or what 'conditions' entail. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 with zero waste. It's front-loaded with the core purpose and appropriately sized for a simple retrieval tool, making it easy for an agent to parse quickly.

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

Completeness3/5

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

Given the tool's complexity appears low (simple retrieval with 2 parameters) and no output schema, the description is minimally adequate but incomplete. It doesn't explain what 'conditions' means in the return data or differentiate from siblings, which could confuse an agent. With no annotations, it should provide more behavioral context to be fully helpful.

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 clear documentation for both parameters (limit and query). The description adds no additional parameter semantics beyond what's in the schema, so it meets the baseline score of 3 where the schema does the heavy lifting without compensation needed.

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 'Retrieve firewall rules and conditions' clearly states the verb (retrieve) and resource (firewall rules and conditions), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_network_rules_summary' or 'search_rules', which appear to offer similar functionality, so it doesn't reach the highest score.

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. With siblings like 'get_network_rules_summary' and 'search_rules' that likely retrieve similar data, there's no indication of differences in scope, filtering capabilities, or output format, leaving the agent without context for tool selection.

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/amittell/firewalla-mcp-server'

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