这是一个模型上下文协议(MCP)服务器,它使LLM客户端能够与GDB进行交互,用于调试和二进制分析。
<p align="center"> <img src="images/gdb-mcp.png" alt="GDB MCP 服务器" width="600"> </p>uv sync
uv venv
uv run server.py
请注意,您可以使用 uv run 来运行 server.py 脚本,或者使用 uv venv 创建一个虚拟环境,然后运行 /home/youruser/dev/personal/GDB-MCP/.venv/bin/python /home/youruser/dev/personal/GDB-MCP/server.py。
在您的 claude_desktop_config.json 中添加:
{
"mcpServers": {
"gdb": {
"command": "uv",
"args": ["run", "/home/youruser/dev/personal/GDB-MCP/server.py"],
"disabled": false
}
}
}
如果您正在使用WSL:
"mcp": {
"servers": {
"my-mcp-server-4dc36648": {
"type": "stdio",
"command": "wsl",
"args": [
"/home/youruser/dev/personal/GDB-MCP/.venv/bin/python",
"/home/youruser/dev/personal/GDB-MCP/server.py"
]
}
}
}
如果您不使用WSL:
"mcp": {
"servers": {
"my-m-服务器-db89eee1": {
"type": "stdio",
"command": "/home/youruser/dev/personal/GDB-MCP/.venv/bin/python",
"args": ["/home/youruser/dev/personal/GDB-MCP/server.py"]
}
}
}
gdb_start(): 启动新的GDB会话gdb_terminate(session_id): 终止会话gdb_list_sessions(): 列出活动会话gdb_load(session_id, program_path): 加载程序gdb_attach(session_id, pid): 附加到进程gdb_load_core(session_id, core_file): 加载核心转储gdb_continue(session_id): 继续执行gdb_step(session_id): 进入函数gdb_next(session_id): 跳过函数gdb_finish(session_id): 完成当前函数gdb_set_breakpoint(session_id, location): 设置断点gdb_backtrace(session_id): 显示调用栈gdb_print(session_id, expression): 打印表达式gdb_examine(session_id, address): 检查内存gdb_info_registers(session_id): 显示寄存器gdb_disassemble_function(session_id, function_name): 反汇编函数gdb_disassemble_around_pc(session_id, count): 反汇编PC周围gdb_get_local_variables(session_id): 获取局部变量g-获取堆栈帧(session_id): 获取堆栈信息gdb_get_register_values(session_id): 获取寄存器值gdb_read_memory_bytes(session_id, address, count): 读取内存gdb_get_thread_info(session_id): 获取线程信息gdb_get_breakpoint_list(session_id): 列出断点gdb_set_watchpoint(session_id, expression): 设置观察点gdb_get_symbol_info(session_id, symbol): 获取符号信息gdb_command(session_id, command): 执行任何GDB命令uv run python run-tests.py --check-deps
uv run python run-tests.py --type all
检查 examples 目录以获取示例提示。
此项目根据GNU版本3.0许可证发布,请参阅LICENSE文件了解详细信息。