PCILech的MCP服务器
英语
一种模型上下文协议(MCP)服务器,为基于DMA的内存操作提供到PCILech的标准化接口。这使得MCP客户端(例如Claude Code)能够通过工具调用执行内存/调试工作流。
作者: 埃文&莫尔\ 技术支持: 加入我们的Discord
特性
- 19个MCP工具 按能力分组:
- 核心内存: memory_read, memory_write, memory_format - 系统: system_info, memory_probe, memory_dump, memory_search, memory_patch, process_list - 地址转换: translate_phys2virt, translate_virt2phys, process_virt2phys - 内核模块(KMD): kmd_load, kmd_exit, kmd_execute, kmd_list_scripts - 高级/FPGA: benchmark, tlp_send, fpga_config
- 虚拟地址模式: 内存工具支持
pid或process_name(相互排斥) - 非阻塞服务器: PCILech调用通过以下方式执行
asyncio.to_thread - 输出助手: 用于分析的hexdump+ASCII+字节/DWORD视图
先决条件
- Windows 10/11 (x64)
- Python 3.10+
- PCILech硬件 配置正确且工作正常
- PCILech二进制文件 (捆绑在下面
pcileech/)
快速开始
1.克隆
git clone https://github.com/Evan7198/mcp_server_pcileech
cd mcp_server_pcileech
// download release in https://github.com/ufrisk/pcileech for using the latest pcileech2.安装依赖项
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt如果遇到MCP导入/版本问题,请从安装 pyproject.toml 相反:
pip install -e .3.验证PCILech
cd pcileech
pcileech.exe probe4.配置克劳德代码(MCP)
添加服务器条目(调整路径):
"mcpServers": {
"pcileech": {
"command": "C:\\path\\to\\mcp_server_pcileech\\.venv\\Scripts\\python.exe",
"args": [
"C:\\path\\to\\mcp_server_pcileech\\main.py"
],
"cwd": "C:\\path\\to\\mcp_server_pcileech",
"env": {}
}
}编辑MCP配置后重新启动Claude Code。
配置
config.json 控制PCILech可执行文件路径和超时:
{
"pcileech": {
"executable_path": "pcileech\\pcileech.exe",
"timeout_seconds": 30
},
"server": {
"name": "mcp-server-pcileech",
"version": "1.0.0"
}
}使用示例
配置后,您可以用自然语言请求操作;客户端将把它们转换为工具调用:
Read 256 bytes from address 0x1000Write the hex data 48656c6c6f to address 0x2000Show me a formatted view of 64 bytes at address 0x1000MCP工具(概述)
笔记:
- 虚拟内存模式: 对于记忆工具,请使用
pid*或*process_name(不是两者)。 - 仅FPGA: 一些操作需要FPGA支持的设备(例如。,
memory_probe,tlp_send).
磁心存储器
memory_read(address, length, pid?, process_name?)→ 十六进制数据+元数据memory_write(address, data, pid?, process_name?)→ 成功/确认memory_format(address, length, formats?, pid?, process_name?)→ hexdump/ASCII/数组/raw
系统
system_info(verbose?)→ 目标系统+设备信息memory_probe(min_address?, max_address?)→ 可读区域(仅FPGA)memory_dump(min_address, max_address, output_file?, force?)→ 转储文件路径/结果memory_search(pattern? | signature?, min_address?, max_address?, find_all?)→ 火柴memory_patch(signature, min_address?, max_address?, patch_all?)→ 补丁结果process_list()→ PID/PPID/名称列表
地址转换
translate_phys2virt(physical_address, cr3)→ 翻译详细信息translate_virt2phys(virtual_address, cr3)→ 翻译详细信息process_virt2phys(pid, virtual_address)→ 翻译详细信息
内核模块(KMD)
kmd_load(kmd_type, use_pt?, cr3?)→ 加载结果(+缓存KMD地址)kmd_exit(kmd_address?)→ 卸载结果(如果省略,则使用缓存地址)kmd_execute(script_name, kmd_address?, input_file?, output_file?, parameter_string?, parameter_int0?, parameter_int1?)kmd_list_scripts(platform?)→ 可用的.ksh按平台分组的脚本
高级/FPGA
benchmark(test_type?, address?)→ MB/s结果(取决于硬件)tlp_send(tlp_data?, wait_seconds?, verbose?)→ 发送/接收TLP(仅FPGA)fpga_config(action?, address?, data?, output_file?)→ 配置读/写(仅FPGA)
建筑
双层设计
- MCP服务器层 (
main.py)
- 标准传输、工具模式、验证、格式化 - 用途 asyncio.to_thread() 避免阻塞事件循环
- PCILech包装器 (
pcileech_wrapper.py)
- 子流程调用 pcileech.exe - 地址对齐+256字节分块(PCILech display 行为) - 输出解析、超时和错误映射
故障排除
未找到PCILech
错误: PCILeech executable not found\ 修复: 验证 config.json → pcileech.executable_path
硬件未连接
警告: PCILeech connection verification failed\ 修复: 跑 pcileech\\pcileech.exe probe 并验证驱动器/布线
内存访问失败
错误: Memory read/write failed\ 修复: 首先在CLI上验证地址/范围,然后通过MCP重试
超时
错误: PCILeech command timed out\ 修复: 增加 pcileech.timeout_seconds 在 config.json
项目结构
mcp_server_pcileech/
├── main.py
├── pcileech_wrapper.py
├── config.json
├── pyproject.toml
├── requirements.txt
├── README.md
├── README_CN.md
└── pcileech/
├── pcileech.exe
└── LICENSE.txt局限性
- 仅限Windows(PCILech是此仓库中以Windows为中心的)
- 实际内存操作需要兼容的PCILech硬件
- 读取大小限制:
- memory_read:高达1MB - memory_format:高达4KB(可读输出)
- 一些工具是 仅FPGA (探头/TLP/config)
- PCILech命令按顺序运行(每个子进程调用)
安全与法律
此工具用于授权调试/安全研究/教育。请勿将其用于未经授权的访问或恶意活动。您有责任遵守适用的法律法规。
许可证
这个项目封装了PCILech,它有自己的许可证。看 pcileech/LICENSE.txt.
学分
版本
此存储库中的工具集目前包括19个工具扩展集。有关包/config版本,请参阅:
pyproject.toml([project].version)config.json(server.version)
支持
- 不一致: 加入我们的Discord
- 问题:在此存储库中打开问题
- PCILech文件:
- MCP文件: MCP文件
更新日志
v1.0.0(2025-12-16)
- 扩展到19个MCP工具,涵盖完整的PCILech功能
- 添加了虚拟地址模式(
pid/process_name)到记忆工具 - 添加了地址转换、KMD和FPGA/高级工具
- 增加了更广泛的验证和错误处理;非阻塞服务器执行
v0.1.0(2025-12-10)
- 初始版本
- 三种MCP工具:
memory_read,memory_write,memory_format
