Skip to main content
Glama

check_ip_in_waf

Verify if an IP address is included in AWS WAF IP Sets for blocklists or allowlists to manage access control and security policies.

Instructions

Checks if an IP address exists in any WAF IP Set (Blocklists/Allowlists).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ip_addressYesThe IP address to check (e.g., 192.168.1.1).

Implementation Reference

  • The handler function for the 'check_ip_in_waf' tool. It checks if the provided IP address exists in any WAF IP Sets across REGIONAL and CLOUDFRONT scopes by listing IP sets, retrieving their addresses, and using the 'checkIp' utility to verify membership.
    if (name === "check_ip_in_waf") {
        const ip = (args as any)?.ip_address;
        const scopes: ("REGIONAL" | "CLOUDFRONT")[] = ["REGIONAL", "CLOUDFRONT"];
        const foundIn: any[] = [];
    
        for (const scope of scopes) {
            try {
                const listCmd = new ListIPSetsCommand({ Scope: scope, Limit: 100 });
                const listResp = await wafv2Client.send(listCmd);
    
                const ipSets = listResp.IPSets || [];
    
                for (const setSummary of ipSets) {
                    if (!setSummary.Name || !setSummary.Id) continue;
    
                    const getCmd = new GetIPSetCommand({
                        Name: setSummary.Name,
                        Id: setSummary.Id,
                        Scope: scope
                    });
                    const getResp = await wafv2Client.send(getCmd);
                    const addresses = getResp.IPSet?.Addresses || [];
    
                    if (checkIp(ip, addresses)) {
                        foundIn.push({
                            IPSetName: setSummary.Name,
                            IPSetId: setSummary.Id,
                            IPSetARN: setSummary.ARN,
                            Scope: scope,
                            Description: getResp.IPSet?.Description
                        });
                    }
                }
            } catch (err) {
                console.error(`Error checking WAF scope ${scope}:`, err);
            }
        }
    
        if (foundIn.length === 0) {
            return { content: [{ type: "text", text: `IP ${ip} not found in any WAF IP Sets.` }] };
        }
    
        return { content: [{ type: "text", text: JSON.stringify(foundIn, null, 2) }] };
    }
  • src/index.ts:648-660 (registration)
    The tool registration entry in the ListTools response, defining the name, description, and input schema (ip_address as required string).
        name: "check_ip_in_waf",
        description: "Checks if an IP address exists in any WAF IP Set (Blocklists/Allowlists).",
        inputSchema: {
            type: "object",
            properties: {
                ip_address: {
                    type: "string",
                    description: "The IP address to check (e.g., 192.168.1.1)."
                }
            },
            required: ["ip_address"]
        }
    },
  • Import of the 'ip-range-check' library used in the handler to check if an IP belongs to any address range in a WAF IP Set.
    import checkIp from "ip-range-check";
  • Initialization of the WAFv2 AWS client used by the handler to query IP sets.
    const wafv2Client = new WAFV2Client({});
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool checks for IP existence in WAF IP Sets, implying a read-only operation, but does not disclose behavioral traits like authentication requirements, rate limits, error handling, or the format of results (e.g., boolean, detailed match info). This leaves significant gaps for an agent to understand how to invoke it effectively.

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 directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence earns its place by conveying 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?

Given the complexity of a security-related tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects (e.g., what the output looks like, error conditions) and usage context. For a tool that checks IPs in WAF sets, more information on permissions, scope, and result interpretation would be needed for an agent to use it effectively.

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 parameter 'ip_address' fully documented in the schema. The description mentions 'IP address' but adds no additional meaning beyond what the schema provides (e.g., format examples like IPv4/IPv6, validation rules). With high schema coverage, the baseline score of 3 is appropriate as the description does not compensate with extra insights.

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 tool's purpose: 'Checks if an IP address exists in any WAF IP Set (Blocklists/Allowlists).' It specifies the verb ('checks'), resource ('IP address'), and scope ('any WAF IP Set'), but does not explicitly differentiate from sibling tools, which are mostly AWS resource listing tools with no direct overlap in functionality.

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 does not mention prerequisites, context, or exclusions, such as whether it applies to specific AWS regions or WAF configurations. The sibling tools are unrelated (e.g., list-based operations), so no explicit comparison is made.

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/bhaveshopss/MCP-server'

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