🧩 GlassTape策略生成器MCP服务器
  
将自然语言转化为生产就绪的人工智能治理政策。
玻璃胶带 策略生成器 是一个开源 MCP服务器 将自然语言安全要求转换为 Cerbos YAML政策 通过自动化验证、测试和红队。\ 它使安全和工程团队能够整合 AI代理和应用程序 随着 政策即代码 框架——为工具调用拦截、数据访问和模型工作流带来零信任护栏。
🚀 特性
- ⚙️ 自然语言政策 –使用Claude或AWS Q从简单的英语生成Cerbos策略
- 🧠 自动验证 –使用Cerbos CLI(
cerbos compile,cerbos test)用于语法和逻辑检查 - 🧪 红队分析 –6点安全分析,自动提出改进建议
- 🧩 MCP集成 –在IDE中原生工作,如 光标, 泽德,以及 克劳德桌面
- 🔒 气隙操作 –本地优先设计,无外部依赖
- 🏷️ 基于主题的治理 –40多个安全分类的内容主题
- 🧾 合规性模板 –SOX、HIPAA、PCI-DSS和欧盟AI法案的内置模板
🚀 快速开始
1.先决条件
安装Cerbos CLI (政策验证所需):
# macOS
brew install cerbos/tap/cerbos
# Linux
curl -L https://github.com/cerbos/cerbos/releases/latest/download/cerbos_Linux_x86_64 \
-o /usr/local/bin/cerbos && chmod +x /usr/local/bin/cerbos
# Verify installation
cerbos --version2.从源代码安装
# Clone the repository
git clone https://github.com/glasstape/glasstape-policy-builder-mcp.git
cd glasstape-policy-builder-mcp/agent-policy-builder-mcp
# Basic installation
pip install -e .
# With optional LLM support (for server-side natural language parsing)
pip install -e ".[anthropic]" # Anthropic Claude
pip install -e ".[openai]" # OpenAI GPT
pip install -e ".[llm]" # All LLM providers
# Development installation
pip install -e ".[dev]"3.配置您的MCP客户端
克劳德桌面 (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"glasstape-policy-builder": {
"command": "glasstape-policy-builder-mcp"
}
}
}光标/Zed:在IDE的MCP设置中添加类似的配置。
可选:服务器端LLM (用于自然语言处理):
{
"mcpServers": {
"glasstape-policy-builder": {
"command": "glasstape-policy-builder-mcp",
"env": {
"LLM_PROVIDER": "anthropic",
"ANTHROPIC_API_KEY": "sk-ant-your-key"
}
}
}
}4.使用示例
生成策略 (在Claude Desktop或启用MCP的IDE中):
Create a payment policy for AI agents:
- Allow payments up to $50
- Block sanctioned entities
- Limit to 5 transactions per 5 minutes列出可用模板:
list_templates验证策略:
validate_policy with policy_yaml: ""5.故障排除
找不到Cerbos CLI:
- 确保Cerbos CLI已安装并位于您的PATH中
- 跑
cerbos --version验证安装(注意:--version不version)
MCP服务器未连接:
- 检查您的MCP客户端配置
- 配置更改后重新启动IDE
- 验证命令路径是否正确:
which glasstape-policy-builder-mcp
安装失败,显示“无法确定要发送哪些文件”:
- 这是一个已知的舱口构建问题-确保您在正确的目录中
- pyproject.toml应包括
[tool.hatch.build.targets.wheel]配置
MCP导入错误:
- 确保您有正确的MCP导入:
from mcp.server import Server - 尝试重新安装:
pip install -e . --force-reinstall
策略验证失败:
- 检查生成的策略中的YAML语法
- 确保Cerbos CLI正常工作:
cerbos compile --help - 查看特定问题的错误消息
安装后找不到命令:
- 确保你有Python 3.10或更高版本
- 检查pyproject.toml中的入口点是否配置正确
🦭 可用工具
通过MCP连接时,您可以在Claude或IDE中使用这些工具:
| 工具 | 它做什么 |
|---|---|
generate_policy | 转换自然语言→ 使用主题治理验证Cerbos YAML |
validate_policy | 使用检查策略语法 cerbos compile |
test_policy | 根据策略运行测试套件 cerbos compile |
suggest_improvements | 6点安全分析,并自动提出改进建议 |
list_templates | 浏览内置模板(金融、医疗保健、人工智能安全) |
工作流程示例:
1. "Generate a payment policy for AI agents with $50 limit..."
→ Claude calls generate_policy
2. "Show me available financial templates"
→ Claude calls list_templates
3. "Test this policy with the test suite"
→ Claude calls test_policy
4. "Analyze this policy for security issues"
→ Claude calls suggest_improvements
5. "Validate the policy syntax"
→ Claude calls validate_policy🧪 输出示例
输入:
"Allow AI agents to execute payments up to $50. Block sanctioned entities.
Limit cumulative hourly amount to $50. Maximum 5 transactions per 5 minutes."生成带有主题治理的策略:
# policies/payment_policy.yaml
apiVersion: api.cerbos.dev/v1
resourcePolicy:
version: "1.0.0"
resource: "payment"
rules:
- actions: ["execute"]
effect: EFFECT_ALLOW
condition:
match:
expr: >
request.resource.attr.amount > 0 &&
request.resource.attr.amount B["GlassTape MCP Server"]
B --> C["Intermediate Canonical Policy - JSON"]
C --> D["Cerbos YAML policy generation"]
D --> E["Cerbos CLI validation + testing"]
E --> F["Ready-to-deploy policy bundle"]关键创新: ICP(Intermediate Canonical Policy)是一种与语言无关的中间表示,支持确定性生成、策略可移植性和形式验证。
🧪 发展
# Clone and setup
git clone https://github.com/glasstape/glasstape-policy-builder-mcp.git
cd glasstape-policy-builder-mcp
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src/ tests/🤝 贡献
我们欢迎捐款!看 贡献.md 作为指导方针。
快速链接:
______________________________________________________________________
💪 许可证
根据 Apache 2.0许可证. ©2025 GlassTape,股份有限公司。
______________________________________________________________________
💡 链接
- 🌐 GlassTape 网站
- 📚 文档
- 🧱 Cerbos文件
- 🧩 模型上下文协议
- 🐛 报告问题
______________________________________________________________________
内置❤️ 通过 玻璃胶带 — *默认情况下使AI代理安全。*
