Skip to main content
Glama

waf_run_self_tests

Run built-in SQLi, XSS, command injection, and path traversal test cases to verify attack detection by the WAF engine.

Instructions

运行内置 SQLi/XSS/命令注入/路径遍历样例,用于快速验证引擎是否检出攻击。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler registered via @mcp.tool decorator. Calls WAFEngine.test_detection() which runs built-in test cases.
    @mcp.tool
    def waf_run_self_tests() -> List[Dict[str, Any]]:
        """运行内置 SQLi/XSS/命令注入/路径遍历样例,用于快速验证引擎是否检出攻击。"""
        return _get_engine().test_detection()
  • Registration of the tool via the @mcp.tool decorator on FastMCP instance.
    @mcp.tool
    def waf_run_self_tests() -> List[Dict[str, Any]]:
        """运行内置 SQLi/XSS/命令注入/路径遍历样例,用于快速验证引擎是否检出攻击。"""
  • The WAFEngine.test_detection() helper method. Runs 4 built-in test cases (SQLi, XSS, CMDi, LFI) against the engine and returns detection results.
    def test_detection(self) -> List[Dict]:
        """测试WAF引擎检测能力"""
        test_cases = [
            {
                "name": "SQL注入测试",
                "request": {
                    "url": "http://example.com/login?id=1' OR '1'='1",
                    "method": "GET",
                    "headers": {"User-Agent": "Mozilla/5.0"},
                    "body": "",
                    "query_string": "id=1' OR '1'='1"
                },
                "expected": "sqli"
            },
            {
                "name": "XSS攻击测试",
                "request": {
                    "url": "http://example.com/search?q=<script>alert('xss')</script>",
                    "method": "GET",
                    "headers": {},
                    "body": "",
                    "query_string": "q=<script>alert('xss')</script>"
                },
                "expected": "xss"
            },
            {
                "name": "命令注入测试",
                "request": {
                    "url": "http://example.com/ping?host=127.0.0.1;cat /etc/passwd",
                    "method": "GET",
                    "headers": {},
                    "body": "",
                    "query_string": "host=127.0.0.1;cat /etc/passwd"
                },
                "expected": "cmdi"
            },
            {
                "name": "路径遍历测试",
                "request": {
                    "url": "http://example.com/file?path=../../../etc/passwd",
                    "method": "GET",
                    "headers": {},
                    "body": "",
                    "query_string": "path=../../../etc/passwd"
                },
                "expected": "lfi"
            }
        ]
        
        results = []
        for test in test_cases:
            alerts = self.check_request(test["request"])
            detected = len(alerts) > 0
            
            results.append({
                "test_name": test["name"],
                "expected": test["expected"],
                "detected": detected,
                "alert_count": len(alerts),
                "alerts": alerts if detected else []
            })
        
        return results
Behavior3/5

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

With no annotations, the description carries the transparency burden. It states the action and purpose but omits details on return format, side effects (e.g., alerts, logs), or whether it alters state. Neither destructive nor read-only hint provided.

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, efficient, and front-loaded with the verb '运行'. Every word earns its place with no redundancy.

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 zero parameters and an existing output schema, the description covers the core purpose. It could briefly indicate output (e.g., pass/fail), but remains sufficiently complete for a test tool.

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?

Input schema has zero parameters, so there is nothing to explain. Baseline for 0 params is 4 per guidelines.

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 runs built-in attack samples (SQLi, XSS, etc.) to verify engine detection, with a specific verb and resource. It distinguishes from sibling tools like waf_check_request (single request check) and waf_reload_rules (rules reload).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase '快速验证' implies quick testing, but lacks explicit guidance on when to use vs alternatives or any exclusions. No when-not-to-use or prerequisites mentioned.

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