一个用于全面威胁建模并支持引导式代码验证的模型上下文协议(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 Server,将确保客户端(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"
在安装 Threat Modeling MCP Server 之前,请确保满足以下要求:
uvx
uvx --version在安装并验证 uvx 可正常工作后,将以下配置添加到你的 mcp.json 配置文件中。根据你使用的客户端类型(kiro/cline/amazon-q),此 mcp.json 的位置会有所不同。添加配置并重启 IDE 后,Threat Modeling MCP Server 将使用 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
该 agent 包含的内容:
.kiro/prompts/threat-modeler.md):分阶段 STRIDE 方法的详细说明.kiro/skills/):各阶段的参考材料,包括可选的 Phase 7.5在导出之前,使用
manage_workflow(action="set_project", directory=...) 选择要进行威胁建模的目录。导出工具始终
创建 <selected-project>/.threatmodel/ 并将这些产物写入其中:
<base>.tc.json:严格的 AWS Threat Composer JSON。这是唯一需要
导入 Threat Composer 的文件。它仅包含标准 schema 键,使用
确定性 UUID id,并应用 Threat Composer 的字段长度限制。<base>.md:包含完整文本的人类可读 Markdown 报告。<base>.extended.json:单独的服务器状态快照(架构、
分类法配置、残余风险、阶段进度),包含内部 id 和完整
文本。它无法导入 Threat Composer。传入
include_extended_data=False 可跳过它。存储的模型保留完整文本。当某个字段超出 Threat Composer 限制时,
只有 .tc.json 副本会被缩短,工具响应会在 "Export Warnings" 下
列出每个被缩短的字段(按实体、字段和长度)。
省略 output_path 会使用带时间戳的基础文件名。提供
output_path 仅选择基础文件名;绝对路径、父级
遍历和其他目录组件无法将任何产物重定向到
所选项目的 .threatmodel 目录之外。
验证和分析工具通常通过 MCP 返回文本,而不是 写入报告文件。导出的文件是快照;服务器在新进程启动时 不会自动重新加载它们。