根因分析工具

一款基于5 Whys方法的模型上下文协议(MCP)服务器,用于系统性的根因分析,帮助开发者和问题解决者通过结构化提问识别问题的根本原因。

  • by schwepps
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 schwepps/5-whys-mcp-server

使用说明

五个为什么MCP服务器

一个模型上下文协议(MCP)服务器,它实现了用于系统根本原因分析的5个为什么方法。该工具通过结构化提问帮助开发人员和问题解决者确定问题的根本原因。

什么是五个为什么的方法论?

5个为什么是一种解决问题的技巧,涉及反复(通常5次)问“为什么”,以深入到问题的根本原因。它对以下情况特别有效:

  • 调试复杂的软件问题
  • 了解系统故障
  • 识别流程瓶颈
  • 分析用户体验问题
  • 调查生产事故

特性

  • 交互分析:逐步指导您完成5个为什么的过程
  • 状态管理:在多个交互中保持分析状态
  • 多种导出格式:将结果导出为Markdown、JSON或纯文本
  • 根本原因识别:完成后自动识别根本原因
  • 重置并重新启动:轻松开始新的分析
  • MCP集成:与Claude和其他MCP兼容工具无缝协作

安装

先决条件

  • Node.js 18或更高版本
  • npm或纱线

安装软件包

npm install five-whys-mcp-server

添加到克劳德代码

选项1:自动安装(推荐)

使用Claude CLI命令自动添加服务器:

claude mcp add five-whys npx five-whys-mcp-server # For local installation
claude mcp add -s user five-whys npx five-whys-mcp-server # user scope

此命令将:

  • 将服务器添加到Claude配置中
  • 无需手动编辑文件
  • 适用于Claude Desktop和Claude Code

选项2:手动安装

  1. 打开您的Claude Desktop配置文件:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • 视窗: %APPDATA%/Claude/claude_desktop_config.json
  2. 添加服务器配置:

{
  "mcpServers": {
    "five-whys": {
      "command": "npx",
      "args": ["five-whys-mcp-server"]
    }
  }
}
  1. 重新启动克劳德桌面

用法

安装和配置后,您可以在Claude Code中使用以下工具:

1.开始新的分析

让克劳德用你的问题陈述开始一个5个为什么的分析:

Claude代码示例:

"Start a 5 whys analysis for: The website is loading slowly for users"

"Help me analyze why our CI/CD pipeline keeps failing"

"I need to do a root cause analysis on this bug: Users can't log in after the latest update"

发生了什么:

  • 克劳德将使用 start_five_whys 工具
  • 你会得到第一个“为什么”的问题来回答
  • 分析会话开始

2.回答为什么问题

在分析过程中,自然地回答克劳德的“为什么”问题:

Claude代码示例:

"The database queries are taking too long"

"Because there are no indexes on the user_activity table"

"The development team didn't know about indexing best practices"

发生了什么:

  • 克劳德使用 answer_why 工具与您的响应
  • 你会自动得到下一个“为什么”的问题
  • 跟踪进度(例如,“问题2/5”)

3.检查当前状态

让克劳德展示你目前的进展:

Claude代码示例:

"Show me the current state of my 5 whys analysis"

"What's my progress on the root cause analysis?"

"Can you display where we are in the analysis?"

发生了什么:

  • 克劳德使用 get_current_state 工具
  • 您看到了到目前为止的所有问题和答案
  • 显示当前进度和下一步

4.导出结果

以不同格式请求您的完整分析:

Claude代码示例:

"Export my 5 whys analysis as markdown"

"Give me the analysis results in JSON format"

"Can you export this as a text summary I can share with my team?"

可用格式:

  • markdown -格式丰富的文档(默认)
  • json -结构化数据格式
  • text -纯文本摘要

发生了什么:

  • 克劳德使用 export_analysis 工具
  • 您将获得一份完整的格式化报告
  • 非常适合记录或共享

5.重置分析

需要时重新开始:

Claude代码示例:

"Reset the current analysis, I want to start over"

"Clear this analysis and let me begin with a new problem"

"Start fresh - I need to analyze a different issue"

发生了什么:

  • 克劳德使用 reset_analysis 工具
  • 清除所有当前进度
  • 您可以立即开始新的分析

完整工作流示例

以下是与Claude Code的典型会话的外观:

你: “开始进行5个为什么的分析:网站对用户的加载速度很慢”

克劳德: ✅ 分析已成功开始。请回答第一个“为什么”的问题。

当前分析:

  • 问题:用户的网站加载速度很慢
  • 状态:进行中
  • 进展:1/5个问题

下一个问题: 为什么会出现这个问题?

你: “数据库查询花费的时间太长”

克劳德: ✅ 记录答案。请回答下一个“为什么”问题(2/5)。

问题和答案:

  1. 为什么会出现这个问题? → 数据库查询耗时太长

下一个问题: 为什么会这样?

你: “经常查询的列上没有索引”

克劳德: ✅ 记录答案。请回答下一个“为什么”问题(3/5)。

[持续到完成]

你: “将此分析导出为降价”

克劳德: [提供完整的格式分析]

示例分析会话

1. Problem: "The website is loading slowly for users"
   
2. Why is the website loading slowly?
   → The database queries are taking too long
   
3. Why are the database queries taking too long?
   → There are no indexes on frequently queried columns
   
4. Why are there no indexes on frequently queried columns?
   → The database was not properly optimized during development
   
5. Why was the database not properly optimized during development?
   → There was no database performance review in the development process
   
6. Why was there no database performance review in the development process?
   → The development team lacks database optimization expertise

Root Cause: The development team lacks database optimization expertise

可用工具

工具 说明 参数
start_five_whys 开始新的分析 problem: string
answer_why 回答当前问题 answer: string
get_current_state 获取分析状态 无
export_analysis 导出结果 format?: 'markdown' | 'json' | 'text'
reset_analysis 重置当前分析 无

发展

地方发展

  1. 克隆存储库
  2. 安装依赖项: npm install
  3. 构建项目: npm run build
  4. 启动开发模式: npm run dev

测试

要在本地测试MCP服务器:

# Start the server
npm start

# In another terminal, test with MCP inspector
npx @modelcontextprotocol/inspector http://localhost:3000

配置

默认情况下,服务器在stdio传输上运行,这适用于MCP集成。不需要额外的配置。

故障排除

常见问题

  1. 服务器未启动:确保已安装Node.js 18+
  2. 工具未出现在Claude中:检查配置文件路径并重新启动Claude
  3. 权限错误:确保包具有执行权限

调试模式

要使用调试输出运行:

DEBUG=* npx five-whys-mcp-server

贡献

  1. 分叉存储库
  2. 创建要素分支
  3. 进行更改
  4. 如果适用,添加测试
  5. 提交拉取请求

许可证

MIT许可证-有关详细信息,请参阅许可证文件

支持

对于问题和疑问:

  • 在GitHub上打开一个问题
  • 检查故障排除部分
  • 查阅MCP文档

采用模型上下文协议(MCP)构建,可与AI助手无缝集成。