MCP微服务调试器
实时Kubernetes日志分析与GitHub Copilot Claude Sonnet 4 Agent集成。
🚀 快速开始
选项1:手动设置
python startup_script.py出现提示时输入VM详细信息。
选项2:直接克劳德集成
在GitHub Copilot中使用此提示开始调试 无需手动运行任何脚本:
# 🚨 MCP Microservice Debug Setup
I need you to set up and run a microservice debugging system with these specs:
**System Requirements:**
- Monitor Kubernetes pod logs in real-time
- Detect: Java exceptions, OutOfMemory, SIGKILL, SIGTERM, database/kafka errors
- Parse JSON logs and group by thread ID for context analysis
- Generate debugging contexts automatically
**Connection Details:**
- VM IP: [YOUR_VM_IP]
- Username: [YOUR_USERNAME]
- PEM Key: ./NxF-2.pem
- Pod: onc-[SERVICE_NAME]-service-0
- Namespace: onc
- Command: `kubectl logs -f onc-[SERVICE_NAME]-service-0 -n onc`
**Expected Log Format:**{ "timestamp":"2025-09-08T11:14:10.544Z", "service":"inventory", "level":"error", "message":"Error message here", "thread":"devicenotifications_updates_5_1417" }
**安装说明:**
1. 安装所需的软件包: `mcp`, `paramiko`
1. 为GitHub Copilot创建MCP服务器配置
1. 使用PEM密钥启动安全SSH连接(无密码存储)
1. 开始实时日志监控
1. 解析JSON日志并提取线程上下文
1. 检测错误模式和组相关日志
1. 通过根本原因分析生成副驾驶上下文
1. 提供具体的修复建议
**当检测到错误时:**
- 将来自同一线程的最后5个日志分组以获取上下文
- 分析级联故障
- 使用置信度得分生成根本原因分析
- 创建可操作的修复建议
- 保存上下文文件: `copilot_context_*.json` 和 `copilot_prompt_*.md`
**请立即启动调试系统,开始监控我的微服务。**
用实际值替换\[YOUR_VM_IP\]、\[YOUR_USERNAME\]和\[SERVICE_NAME\]。
🎯 What It Does
- Connects securely via SSH with your PEM key
- Monitors logs for errors and exceptions
- Groups related logs by thread ID for better context
- Generates analysis with root causes and fix suggestions
- Creates Copilot contexts automatically for debugging assistance
📁 Files Needed
你的项目/
├── NxF-2.pem#您的pem密钥文件
├── startup_script.py#主启动器
├── mcp_debug_server.py#mcp服务器代码
└── simple_debug_client.py#轻量级选项
🔧 Error Detection
Automatically detects:
- Java exceptions and stack traces
- OutOfMemoryError conditions
- SIGKILL/SIGTERM signals
- Database connection issues
- Kafka messaging problems
- Network connectivity errors
🤖 GitHub Copilot Commands
Once running, use these commands:
@微服务调试器start_debug_session,vm_ip=“192.168.1.100”用户名=“admin”pem_file_path=“./NxF-2.pem”pod_name=“onc-inventory-service-0”命名空间=“onc”
@计数为3的微服务调试器get_latest_errors
@微服务调试器stop_debug_session
🚨 Quick Start Prompts
Interactive Setup (Claude asks for details):
@microservice-debugger I need microservice debugging setup. Please ask me for my VM IP, username, and service name, then automatically start the monitoring system.直接设置(立即提供详细信息):
@microservice-debugger Setup debugging: VM=192.168.1.100, user=admin, service=onc-inventory-service-0, namespace=onc, key=./NxF-2.pem. Start monitoring now.______________________________________________________________________
就是这样! 该系统处理安全性,通过PEM密钥连接,智能分析日志,并自动为GitHub Copilot提供调试上下文。
