Hospital WAF MCP

Hospital WAF MCP

A Model Context Protocol server that exposes a hospital-oriented web application firewall engine for AI assistants. It enables request inspection against curated security rules and provides tools for rule management and security testing.

Category
Visit Server

README

Hospital WAF Management System MCP Server

Python License MCP

English | 中文

医院 Web 应用防火墙 MCP 服务器,为 AI 助手提供 WAF 规则检测能力。支持 SQL 注入、XSS、命令注入、路径遍历检测,内置医院场景专项规则。

✨ 功能特性

  • 🔒 SQL 注入检测 — 识别常见 SQLi 攻击模式(UNION注入、布尔盲注、时间盲注、报错注入)
  • 🎯 XSS 跨站脚本检测 — 检测反射型/存储型 XSS(script标签、事件处理器、JS URI)
  • 命令注入检测 — 识别 Unix/Windows 系统命令执行攻击
  • 📁 路径遍历检测 — 检测目录穿越攻击及编码绕过
  • 🏥 医院专项规则 — 覆盖 HIS/PACS/LIS/RIS 常见漏洞模式
  • 🔄 热重载规则 — 修改规则后无需重启服务
  • 🧪 自检测试 — 内置攻击样例验证引擎能力
  • 轻量运行 — 纯 Python 正则引擎,无外部依赖

🚀 快速开始

1. 安装

# 克隆仓库
git clone https://github.com/12211725-star/hospital-waf-mcp.git
cd hospital-waf-mcp

# 安装依赖
pip install -r requirements-mcp.txt

2. 集成到 MCP 客户端

在 MCP 客户端配置文件中添加:

{
  "mcpServers": {
    "hospital-waf-mcp": {
      "command": "python",
      "args": ["-m", "waf_mcp"],
      "env": {
        "WAF_MCP_LOG_LEVEL": "INFO"
      }
    }
  }
}

Docker 方式

{
  "mcpServers": {
    "hospital-waf-mcp": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "hospital-waf-mcp"],
      "env": {
        "WAF_MCP_LOG_LEVEL": "INFO"
      }
    }
  }
}

Streamable HTTP 远程部署

export WAF_MCP_TRANSPORT=http
export WAF_MCP_HOST=0.0.0.0
export WAF_MCP_PORT=8000
python -m waf_mcp

MCP 端点:http://<host>:8000/mcp 健康检查:GET /health

📖 使用方法

检测 SQL 注入

在 Claude / Cursor / 其他 MCP 客户端中:

请帮我检测这个请求是否有安全问题:
URL: https://example.com/search?q=1' OR '1'='1

AI 会调用 waf_check_request 工具,返回:

[
  {
    "rule_id": "sqli-001",
    "category": "SQL Injection",
    "severity": "high",
    "matched": "1' OR '1'='1",
    "description": "检测到 SQL 注入特征"
  }
]

检测 XSS 攻击

检测这个 POST 请求的 body:
<script>alert('xss')</script>

查看规则统计

当前 WAF 引擎加载了多少规则?

🎯 提示词指南

安全评估场景

我需要对一个请求进行安全检测,
URL 是 https://hospital.example.com/api/patient?id=1 UNION SELECT,
请帮我分析是否存在攻击特征。

规则运维场景

我刚刚更新了 WAF 规则文件,
请帮我重新加载规则并确认加载成功。

引擎验证场景

请运行 WAF 引擎自检测试,
确认 SQL 注入和 XSS 检测功能正常。

日志分析场景

帮我检测这个可疑请求的完整参数:
URL: https://api.hospital.com/query
Method: POST
Body: {"filter": "'; DROP TABLE users; --"}
Headers: {"Content-Type": "application/json"}

🛠️ 工具列表

工具 描述 参数
waf_check_request WAF 请求检测 url: 请求URL, method: HTTP方法, headers: 请求头, body: 请求体, cookies: Cookie
waf_rule_stats 规则统计 无参数
waf_reload_rules 热重载规则 无参数
waf_run_self_tests 自检测试 无参数

📖 环境变量

变量 说明 默认值
WAF_MCP_TRANSPORT 传输协议 (stdio/http/sse) stdio
WAF_MCP_HOST HTTP 监听地址 127.0.0.1
WAF_MCP_PORT HTTP 监听端口 8000
WAF_MCP_LOG_LEVEL 日志级别 INFO
WAF_RULES_FILE 规则文件路径 waf_mcp/rules/waf_rules.mcp.json

📋 检测能力

SQL 注入检测

风险类型 严重程度 检测条件
UNION 注入 High UNION SELECT 等
布尔盲注 High AND/OR 布尔表达式
时间盲注 High SLEEP/BENCHMARK 等
报错注入 High EXTRACTVALUE/UPDATEXML 等
堆叠查询 High 分号分隔多条 SQL

XSS 检测

风险类型 严重程度 检测条件
script 标签 High <script> 标签注入
事件处理器 High onclick/onerror 等
JavaScript URI Medium javascript: 协议
SVG 注入 Medium <svg onload>

命令注入检测

风险类型 严重程度 检测条件
Unix 命令注入 Critical ; | & $ ` 管道连接
Windows 命令注入 Critical & | ^ 命令连接
危险命令 Critical cat/ls/wget/curl 等

路径遍历检测

风险类型 严重程度 检测条件
目录穿越 High ../ 路径穿越
URL 编码绕过 High %2e%2e/ 等编码
双重编码绕过 High %252e%252e/

医院场景专项

系统类型 关键词
HIS 医院信息系统、门诊、住院、挂号
PACS 影像、DICOM、放射
LIS 检验、实验室、生化
RIS 放射信息系统、影像诊断
EMR 电子病历、病程记录

🔧 开发

git clone https://github.com/12211725-star/hospital-waf-mcp.git
cd hospital-waf-mcp
pip install -e .

# 运行测试
python scripts/run_functional_tests.py

# 本地运行
python -m waf_mcp

📁 项目结构

hospital-waf-mcp/
├── waf_mcp/                  # MCP 服务包
│   ├── __init__.py
│   ├── __main__.py
│   ├── config.py
│   ├── server.py
│   ├── version.py
│   ├── waf_engine.py
│   └── rules/
│       └── waf_rules.mcp.json
├── scripts/                  # 脚本工具
├── modelscope.yaml           # 魔搭配置
├── mcp.json                  # MCP 元数据
├── mcp_config.json           # MCP 客户端配置
├── pyproject.toml            # Python 项目配置
└── README.md

📄 许可证

MIT License

🔗 链接

  • GitHub: https://github.com/12211725-star/hospital-waf-mcp
  • Issues: https://github.com/12211725-star/hospital-waf-mcp/issues
  • 魔搭 MCP 广场: https://modelscope.cn/mcp/servers

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured