一个用于全面威胁建模并带有引导式代码验证的模型上下文协议(MCP)服务器。
此服务器提供用于威胁建模的工具,包括业务上下文分析、架构分析、威胁行为者分析、信任边界分析、资产流分析、代码安全验证以及综合报告生成。
此 MCP 服务器调用现有代理的 LLM,而不是向其他服务发起外部 API 或网络调用。它依赖现有客户端的 LLM,例如 Amazon-Q、Kiro 或 Cline。
此威胁建模 MCP 服务器有三个主要功能:
它还具有以 Markdown 和 JSON 可导出格式生成最终报告的工具。
.threatmodel 目录,但这些快照不会在后续会话中自动加载。注意: 在使用这些提示词之前,您必须先完成安装过程以设置 MCP 服务器。
"Threat model this project using the threat modeling MCP Server"
在提示词中明确指定使用威胁建模 MCP 服务器,将确保客户端(Cline/Kiro 等)遵循确切的阶段和方法论,而不是走捷径并在结果中引入幻觉。
"Threat model this subfolder using the threat modeling MCP Server"
对子文件夹运行会限制预期的分析范围。要将导出保存到那里,请请求该子文件夹内的输出路径;导出位置不会从分析范围自动推断。
"Save the threat model report"
"Please complete all the phases in the threat model plan and then generate the final report."
"Threat model this project using the threat model MCP server and consider this architecture_image.png attached for this review"
"Can you see if you can implement mitigation controls in the code based on the threats reported in the threat model"
"Can you updated the threat model based on the code fixes which mitigated the reported threats"
# Set up context
"Set business context for an e-commerce payment system"
# Add architecture
"Add a web server component using AWS EC2"
"Add a database component using AWS RDS"
# Identify threats
"Add a threat where an attacker with network access performs SQL injection"
# Add mitigations
"Add a mitigation for input validation"
# Export results
"Export the threat model to my_model.tc.json"
在安装威胁建模 MCP 服务器之前,请确保您满足以下要求:
uvx
uvx --version一旦您安装并验证 uvx 可正常工作,请将以下配置添加到您的 mcp.json 配置文件中。根据您使用的客户端类型(kiro/cline/amazon-q),此 mcp.json 的位置会有所不同。添加配置并重启 IDE 后,威胁建模 MCP 服务器将使用 uvx 直接从该 GitHub 仓库自动安装。
注意: 此 mcp 服务器用于威胁建模的工具已添加到
autoApprove中,以提升用户体验,从而实现无缝操作,无需为每次工具调用手动批准提示。所有工具都是服务器内部的,不会进行外部 API 调用。如果您想审查每个工具并按每次调用进行批准,则需要将 autoApprove 数组替换为:"autoApprove": []
将以下内容添加到您的 MCP 客户端配置中:
对于 Amazon Q(~/.aws/amazonq/mcp.json):
{
"mcpServers": {
"threat-modeling-mcp-server": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/awslabs/threat-modeling-mcp-server.git",
"threat-modeling-mcp-server"
],
"env": {
"FASTMCP_LOG_LEVEL": "ERROR"
},
"disabled": false,
"autoApprove": ["manage_workflow","export_threat_model","manage_system_context","manage_assumptions","manage_architecture","manage_threat_actors","manage_trust_boundaries","manage_asset_flows","manage_threats","inspect_data_models","manage_code_validation"]
}
}
}
对于 VSCode Cline:
{
"mcpServers": {
"threat-modeling-mcp-server": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/awslabs/threat-modeling-mcp-server.git",
"threat-modeling-mcp-server"
],
"env": {
"FASTMCP_LOG_LEVEL": "ERROR"
},
"disabled": false,
"autoApprove": ["manage_workflow","export_threat_model","manage_system_context","manage_assumptions","manage_architecture","manage_threat_actors","manage_trust_boundaries","manage_asset_flows","manage_threats","inspect_data_models","manage_code_validation"],
"timeout": 60,
"type": "stdio"
}
}
}
对于 Kiro(~/.kiro/settings/mcp.json):
{
"mcpServers": {
"threat-modeling-mcp-server": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/awslabs/threat-modeling-mcp-server.git",
"threat-modeling-mcp-server"
],
"env": {
"FASTMCP_LOG_LEVEL": "ERROR"
},
"disabled": false,
"autoApprove": ["manage_workflow","export_threat_model","manage_system_context","manage_assumptions","manage_architecture","manage_threat_actors","manage_trust_boundaries","manage_asset_flows","manage_threats","inspect_data_models","manage_code_validation"]
}
}
}
要通过 kiro-cli 运行 MCP 服务器并自动批准所有工具:
kiro-cli chat --trust-tools="@threat-modeling-mcp-server/*"
这会信任来自 threat-modeling-mcp-server MCP 服务器的所有工具,因此您不会收到逐个批准每次工具调用的提示。
此仓库包含一个预配置的 Kiro CLI 代理,涵盖九个编号阶段以及可选的 Phase 7.5 代码验证步骤。代理配置位于 .kiro/agents/threat-modeler.json。
全局安装(可从任何目录使用):
./install-kiro-agent.sh
卸载:./install-kiro-agent.sh --remove
本地安装(项目特定):
cp -r /path/to/threat-modeling-mcp-server/.kiro /path/to/your-project/.kiro
用法:
# Non-interactive: run full threat model and exit
kiro-cli chat --agent threat-modeler --no-interactive "Threat model this project"
# Interactive: start a session with the agent
kiro-cli chat --agent threat-modeler
代理包含的内容:
.kiro/prompts/threat-modeler.md):分阶段 STRIDE 方法论的详细说明.kiro/skills/):各阶段的参考材料,包括可选的 Phase 7.5在导出之前,使用
manage_workflow(action="set_project", directory=...) 选择要进行威胁建模的目录。导出工具始终
创建 <selected-project>/.threatmodel/,并在其中写入 Threat Composer
.tc.json 文件和 Markdown 报告。省略 output_path 将使用带时间戳的基础文件名。提供 output_path 仅选择基础
文件名;绝对路径、父目录遍历和其他目录组件
无法将任一产物重定向到所选项目的 .threatmodel
目录之外。
验证和分析工具通常通过 MCP 返回文本,而不是 写入报告文件。导出的文件是快照;服务器在新进程启动时不会 自动重新加载它们。
| 工具 | 用途 | 示例 |
|---|---|---|
manage_workflow(action="plan") | 获取综合计划 | 从这里开始了解概览 |
manage_workflow(action="guidance", phase="1") | 获取聚焦的 Phase 1 指导 | 推荐的起点 |
manage_workflow(action="status") | 检查进度 | 跟踪完成状态 |
manage_system_context(action, section, ...) | 定义业务上下文和分类配置文件 | action="set", section="all" |
manage_assumptions(action, ...) | 记录和维护假设 | 从 action="describe" 开始 |
manage_architecture(action, section, ...) | 管理组件、数据存储节点和连接 | 从 action="describe" 开始 |
manage_threat_actors(action, ...) | 评估和分析威胁行为者 | 使用 action="update" 设置相关性和优先级 |
manage_trust_boundaries(action, section, ...) | 管理区域、跨越点和边界 | 使用 action="detection_plan" 获取指导 |
manage_asset_flows(action, section, ...) | 管理资产和流 | 部分为 assets 和 flows |
manage_threats(action, section, ...) | 管理威胁、缓解措施、链接和残余风险决策 | 在 Phase 8 中使用 action="assess" |
manage_code_validation(action, values) | 记录并报告代码验证证据 | 从 action="describe" 开始 |
export_threat_model() | 执行 Phase 9 导出 | 生成 JSON 和 Markdown 快照 |
推荐方法:一次使用一个阶段的综合指导工具: