LISA MCP服务器

将任何兼容MCP的AI(如GitHub Copilot、VS Code)直接连接到Microsoft LISA Linux测试框架,通过自然语言选择测试用例、生成测试代码、构建运行手册配置、运行测试并分析失败。

  • by kkkashan
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 kkkashan/LISA_MCP_Server

使用说明

LISA MCP服务器

Microsoft LISA的模型上下文协议服务器——Linux集成服务自动化

将任何兼容MCP的AI(GitHub Copilot、VS Code或任何MCP客户端)直接连接到 微软LISA Linux测试框架。通过自然语言选择测试用例、生成测试代码、构建runbook配置、运行测试以及使用AI分析故障。


什么是LISA?

LISA(Linux集成服务自动化)是微软针对Azure、HyperV和裸机上的Linux的质量验证系统。它提供:

  • A. 声明性测试框架 内置Python
  • 数百 内置测试套件 涵盖网络、存储、CPU、内存、内核、管理程序集成等
  • 多平台支持:Azure、HyperV、QEMU、裸机
  • Runbook驱动的执行 通过YAML配置文件
  • 基于层次的测试选择 (T0–T4)用于不同的CI/CD阶段

此MCP服务器添加了什么

无MCP 带LISA MCP服务器
手动grep Python文件作为测试名称 “显示优先级为0的所有存储测试”
从头开始手写runbook YAML “为RHEL 9构建T2 Azure runbook”
复制粘贴测试套件样板 “生成NVMe磁盘吞吐量测试套件”
手动解析JUnitXML以查找故障 “我上次跑步失败了什么,为什么?”
记住CLI标志和变量语法 由AI自动处理

LLM故障分析——多提供商AI支持

该服务器与任何兼容OpenAI的LLM集成,以提供AI驱动的故障分析:

  • 根本原因分类 --对故障进行分类(磁盘I/O、网络超时、内核死机等)
  • 可操作的修复建议 --要调查的特定命令、文件路径、设置
  • 严重性评分 --关键/高/中/低优先级
  • 运行级别执行摘要 --利益相关者准备的健康报告
  • HTML+Markdown报告 --可共享分析工件

支持的提供商 --通过任何 endpoint 到分析工具:

提供者 示例端点
Azure OpenAI响应API (默认) https://<resource>.openai.azure.com/openai/responses?api-version=2025-04-01-preview
OpenAI https://api.openai.com/v1/chat/completions
Azure OpenAI聊天完成 https://<resource>.openai.azure.com/openai/deployments/<model>/chat/completions?api-version=2024-02-01
Ollama(当地) http://localhost:11434/v1/chat/completions
LM工作室(本地) http://localhost:1234/v1/chat/completions
Azure AI Foundry https://models.inference.ai.azure.com/chat/completions

使用 list_llm_providers 该工具可随时查看所有选项及其配置。

聊天中的示例用法:

Analyze the failures in ~/lisa/lisa_results.xml
API key: <your-key>
Endpoint: https://api.openai.com/v1/chat/completions
Model: gpt-4o
Save the report to ~/reports/

如果没有提供端点,服务器将使用预配置的Azure OpenAI默认值。


快速示例

You: "Scan my LISA repo and show me all network tests at tier T1,
      then build a runbook for Azure that runs them on Ubuntu 22.04"

The AI invokes:
  1. discover_test_cases(lisa_path="~/lisa", area="network", tier="T1")
  2. build_runbook(name="Network T1", platform_type="azure",
                   tier="T1", image="ubuntu jammy 22.04-lts latest")

Result: a filtered list of tests + a ready-to-use runbook.yml

入门指南

1--安装

git clone https://github.com/kkkashan/LISA_MCP_Server.git ~/lisa-mcp-server
cd ~/lisa-mcp-server
pip install -e .

2--使用VS代码注册

存储库附带了 .vscode/mcp.json 它在VS Code中自动注册服务器。打开工作区——VS Code将检测到它并主动启动服务器。

或者,手动将其添加到 .vscode/mcp.json:

{
  "servers": {
    "lisa": {
      "command": "python3",
      "args": ["-m", "lisa_mcp.server"],
      "cwd": "/absolute/path/to/lisa-mcp-server"
    }
  }
}

3--开始提问

打开GitHub Copilot Chat(或任何MCP客户端),从以下内容开始:

Check the LISA environment and show me the available test tiers

文档

文档 描述
QUICKSTART.md 10分钟后开始跑步
安装.md 所有平台的完整安装指南
用法.md 详细使用示例
docs/running-lisa.md 运行LISA测试的分步指南
docs/tools-reference.md 所有17个MCP工具的完整参考
docs/测试发现.md 测试扫描和过滤的工作原理
文档/写作测试.md 编写新LISA测试的分步指南
docs/runbook-guide.md 完整的runbook编写指南
docs/llm-analysis.md 人工智能驱动的故障分析管道
docs/automation-guide.md CI/CD管道集成
docs/故障排除.md 常见问题及解决方法
更改日志.md 版本历史和发行说明
贡献.md 如何为这个项目做出贡献

18个MCP工具

类别 工具 它的作用
发现 discover_test_cases 扫描LISA仓库,按区域/级别/优先级/平台过滤
list_test_areas 列出所有功能区域(网络、存储、CPU……)
get_test_case_details 一个测试的完整元数据
search_tests 跨名称和描述的自由文本搜索
生成 generate_test_suite_code 为新的测试套件生成Python源代码
build_runbook 使用测试条件生成YAML runbook
build_tier_runbook_file 基于层的快速runbook生成器
验证 validate_runbook_file 检查YAML语法和架构
add_test_to_existing_runbook 向现有runbook添加包含/排除条件
check_lisa_environment 验证是否安装了LISA CLI
get_tier_info T0–T4层定义和优先级范围
执行 run_lisa_tests 通过以下方式执行测试 lisa CLI子流程
parse_test_results 解析JUnitXML或控制台输出
AI分析 analyze_test_run_with_llm 使用Azure OpenAI分析所有故障
analyze_failure_root_cause 针对一次故障的深入AI分析
generate_analysis_report 完整管道→ HTML+Markdown报告
run_and_analyze 端到端:运行测试→ 分析→ 报告
list_llm_providers 列出所有支持的LLM提供程序和端点配置

项目结构

lisa-mcp-server/
├── README.md                         ← You are here
├── QUICKSTART.md                     ← Start here
├── INSTALL.md                        ← Installation guide
├── USAGE.md                          ← Usage guide
├── pyproject.toml                    ← Python package metadata
├── mcp_config.json                   ← MCP client config snippet
├── .vscode/
│   └── mcp.json                      ← VS Code MCP server registration
│
├── lisa_mcp/                         ← Python package
│   ├── server.py                     ← FastMCP server (18 tools, 3 resources, 3 prompts)
│   ├── models.py                     ← Pydantic data models
│   └── tools/
│       ├── test_discovery.py         ← AST-based test scanner
│       ├── test_generator.py         ← Code + YAML generation
│       ├── runbook_builder.py        ← Runbook build/validate/update
│       ├── test_runner.py            ← lisa CLI subprocess wrapper
│       ├── result_parser.py          ← JUnit XML + console output parser
│       ├── log_collector.py          ← Memory-safe log extraction
│       ├── llm_analyzer.py           ← Azure OpenAI failure analysis
│       └── report_generator.py       ← HTML + Markdown report generation
│
├── docs/
│   ├── running-lisa.md               ← Step-by-step run guide
│   ├── tools-reference.md            ← All 18 tools documented
│   ├── test-discovery.md             ← Discovery internals
│   ├── writing-tests.md              ← Test authoring guide
│   ├── runbook-guide.md              ← Runbook authoring guide
│   ├── llm-analysis.md               ← AI analysis pipeline
│   ├── automation-guide.md           ← CI/CD integration
│   └── troubleshooting.md            ← Problem solving
│
└── examples/
    ├── azure_t1_runbook.yml          ← Ready-to-use T1 runbook
    ├── custom_selection_runbook.yml  ← Custom test selection
    ├── new_test_suite_example.py     ← Example test suite
    └── network_connectivity_test.py  ← Generated network test suite

许可证

麻省理工学院——见 许可证.

专为 微软LISA |技术支持: 模型上下文协议 |AI分析通过 Azure OpenAI