Skip to main content
Glama

waf_reload_rules

Reload and compile WAF rules from disk to apply rule changes without restarting the MCP server.

Instructions

重新从磁盘加载 WAF_RULES_FILE(或默认 rules/waf_rules.mcp.json)并编译。用于修改规则文件后无需重启 MCP。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'waf_reload_rules' tool. It calls _reload_engine() to reload rules from disk and returns a success response with stats.
    @mcp.tool
    def waf_reload_rules() -> Dict[str, Any]:
        """重新从磁盘加载 WAF_RULES_FILE(或默认 rules/waf_rules.mcp.json)并编译。用于修改规则文件后无需重启 MCP。"""
        eng = _reload_engine()
        stats = eng.get_stats()
        return {"success": True, "message": "规则已重新加载", "stats": stats}
  • The helper function _reload_engine() that creates a new WAFEngine instance (loading rules from disk) and replaces the global engine.
    def _reload_engine() -> WAFEngine:
        global _engine
        _engine = WAFEngine(str(_rules_path()))
        return _engine
  • The @mcp.tool decorator that registers 'waf_reload_rules' as an MCP tool on the FastMCP instance.
    @mcp.tool
  • The return type Dict[str, Any] defines the schema: it returns a dict with 'success' (bool), 'message' (str), and 'stats' (dict from get_stats). No input parameters needed.
    def waf_reload_rules() -> Dict[str, Any]:
        """重新从磁盘加载 WAF_RULES_FILE(或默认 rules/waf_rules.mcp.json)并编译。用于修改规则文件后无需重启 MCP。"""
        eng = _reload_engine()
        stats = eng.get_stats()
        return {"success": True, "message": "规则已重新加载", "stats": stats}
  • The WAFEngine.get_stats() method that provides the stats dict returned by the tool (includes rules_file, total_rules, compiled_rules, 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,
        }
Behavior3/5

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

No annotations are provided, so the description carries full burden. It discloses the reload and compile actions but lacks detail on potential side effects (e.g., whether it is safe to call mid-operation, impacts on in-flight requests). The presence of an output schema suggests return values are documented elsewhere.

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 two sentences in Chinese, efficiently stating the action and purpose with no superfluous words. It is front-loaded and to the point.

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

Completeness5/5

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

Given the simplicity of the tool (no parameters, output schema exists), the description covers what it does, the file involved, and the reason to use it. It is sufficiently complete for an agent to select and invoke correctly.

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?

The tool has zero parameters, so schema coverage is 100%. The description adds no parameter information, but the baseline for no parameters is 4. No additional semantics needed.

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 the tool's action: reload the WAF rules file from disk and compile, with the specific purpose of avoiding MCP restart after rule modifications. It distinguishes itself from sibling tools (check, stats, self-tests) by focusing on reloading.

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 explicitly indicates when to use: after modifying rule files. However, it does not provide exclusions or mention alternatives, but the context is clear given sibling tool purposes.

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