Skip to main content
Glama

waf_rule_stats

Retrieve statistics of loaded WAF rules, including compilation status, errors, and category counts.

Instructions

返回当前已加载规则的统计:含 rules_file、compiled_rules、compile_failed、compile_errors(截断)及分类计数。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for 'waf_rule_stats'. Decorated with @mcp.tool, it returns the WAF engine's statistics by calling _get_engine().get_stats().
    @mcp.tool
    def waf_rule_stats() -> Dict[str, Any]:
        """返回当前已加载规则的统计:含 rules_file、compiled_rules、compile_failed、compile_errors(截断)及分类计数。"""
        return _get_engine().get_stats()
  • The get_stats() method on WAFEngine that provides the actual statistics data (total_rules, enabled_rules, compiled_rules, compile_failed, categories, severities, etc.)
    def get_stats(self) -> Dict:
        """获取规则统计"""
        categories = {}
        severities = {}
        
        for rule in self.rules:
            if rule.get("enabled") is False:
                continue
            cat = rule.get("category", "other")
            sev = rule.get("severity", "medium")
    
            categories[cat] = categories.get(cat, 0) + 1
            severities[sev] = severities.get(sev, 0) + 1
        
        enabled_rules = [r for r in self.rules if r.get("enabled") is not False]
        return {
            "rules_file": str(self.rules_file),
            "total_rules": len(self.rules),
            "enabled_rules": len(enabled_rules),
            "compiled_rules": len(self.compiled_rules),
            "compile_failed": len(self.compile_failures),
            "compile_errors": self.compile_failures[:50],
            "categories": categories,
            "severities": severities,
        }
  • The FastMCP instance ('mcp') is created here; the @mcp.tool decorator on waf_rule_stats registers it as a tool.
    mcp = FastMCP(name="hospital-waf")
  • The _get_engine() helper that lazily initializes and returns the WAFEngine singleton used by waf_rule_stats.
    def _get_engine() -> WAFEngine:
        global _engine
        if _engine is None:
            _engine = WAFEngine(str(_rules_path()))
        return _engine
Behavior3/5

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

No annotations provided, but the description mentions that compile_errors are truncated, which is a useful behavioral detail. However, it lacks further info on side effects or prerequisites.

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?

Single sentence is front-loaded with purpose and lists key fields, no wasted words.

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 no parameters and presence of output schema, the description adequately covers the tool's purpose and notes the truncation of compile_errors.

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?

No parameters exist, so schema coverage is 100%. The description does not need to add parameter info; baseline for 0 params is 4.

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 it returns statistics of currently loaded rules and lists specific fields (rules_file, compiled_rules, etc.), distinguishing it from sibling tools like waf_check_request or waf_reload_rules.

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?

No guidance on when to use this tool versus alternatives; it only describes what it does without context for 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/12211725-star/hospital-waf-mcp'

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