行为测试工具

MCP Sentinel是一个用于MCP服务器的行为测试工具,支持模式测试和Docker沙箱监控。

  • by CULPRITCHAOS
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 CULPRITCHAOS/MCP-Sentinel

使用说明

MCP哨兵

MCP(模型上下文协议)服务器的行为测试工具。

一个问题: 这个MCP服务器只做它声称的事情吗?

模式

模式 功能 限制
schema Stdio模糊测试:发现工具,从模式生成测试输入,验证错误处理。没有Docker。 无法检测到副作用。
sandbox Docker+sidecar观察器+exfil接收器。完全行为监视。 无法检测仅在内存中的行为。

快速开始

# Install
pip install -e ".[dev]"

# Schema mode — test a local MCP server
mcp-sentinel test --mode schema --command "python server.py"

# Sandbox mode — test a Docker image
mcp-sentinel test --mode sandbox --image my-mcp-server:latest

# Export telemetry
mcp-sentinel test --mode schema --command "python server.py" --export-telemetry results.jsonl

项目结构

src/mcp_sentinel/
├── __init__.py
├── models.py            # Pydantic data models
├── schema_analyzer.py   # Tool discovery + test case generation
├── cli.py               # Click CLI entry point
├── test_runner.py       # Test execution orchestrator
├── exfil_sink.py        # Exfil sink server + host-side log parser
└── sandbox.py           # Docker sandbox orchestrator

tests/
├── unit/                # Unit tests
├── integration/         # Integration tests (require fixtures/Docker)
└── fixtures/
    ├── good_server/     # Clean, well-behaved MCP server
    └── evil_server/     # Malicious MCP server for testing detection

技术栈

  • Python 3.11+
  • MCP-SDK --工具发现和调用客户端
  • 点击+丰富 --CLI和终端格式化
  • 码头工人 --沙盒行为监控
  • Pydantic v2 --数据模型和验证

发展

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run only unit tests
pytest tests/unit/

# Run integration tests (requires MCP fixtures)
pytest tests/integration/ -m integration

# Lint
ruff check src/ tests/

# Type check
mypy src/

文档