XD

xhd2015/dlv-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

21 stars 5 forks 质量 47 趋势 10MIT

MCP 服务器,展示 Golang 的 Delve 调试器,使 AI 能够自我调试

概览

一个MCP服务器,允许LLM与Delve Go调试器交互。 该项目实现了一个模型上下文协议(MCP)服务器,与 Delve Go 调试器集成,使 AI 助手能够调试 Go 应用。该服务器展示了一套工具,允许大型语言模型启动、控制和交互调试会话。 你可以在 EXAMPLE.md 找到一个工作示例。 - 为 Go 程序启动调试会话 - 在代码中设置断点 - 逐步执行代码(下一步、步入、退出) - 在调试会话上下文中评估表达式 - 检查变量和栈跟踪 - 管理多个调试会话 - Go 1.21 或更高版本 - 已安装 Delve 调试器(go install github.com/go-delve/delve/cmd/dlv@latest) 然后在光标或任意MCP客户端的http://localhost:9097/sse,配置MCP服务器。

概述(AI 翻译)

一个MCP服务器,允许LLM与Delve Go调试器交互。

描述

该项目实现了一个模型上下文协议(MCP)服务器,与 Delve Go 调试器集成,使 AI 助手能够调试 Go 应用。该服务器展示了一套工具,允许大型语言模型启动、控制和交互调试会话。

你可以在 EXAMPLE.md 找到一个工作示例。

特色

  • 为 Go 程序启动调试会话
  • 在代码中设置断点
  • 逐步通过代码(下一步,步入,步出)
  • 在调试会话的上下文中评估表达式
  • 检查变量和栈迹
  • 管理多个调试会话

安装

先决条件

  • 达到1.21或更高
  • 已安装Delve调试器(go install github.com/go-delve/delve/cmd/dlv@latest)

安装

用途

启动MCP服务器:

然后在 http://localhost:9097/sse、光标或任意 MCP 客户端配置 MCP 服务器。

检查MCP服务器

可用工具

调试会话管理

  • start_debug:启动新的调试会话
  • program:调试路径到去程序
  • args:程序的命令行参数(可选)

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Go Delve Debugger MCP Server

An MCP server that allows LLMs to interact with the Delve Go debugger.

Description

This project implements a Model Context Protocol (MCP) server that integrates with the Delve Go debugger to enable AI assistants to debug Go applications. The server exposes a set of tools that allow LLMs to start, control, and interact with debug sessions.

You can find a working example at EXAMPLE.md.

Features

  • Start debug sessions for Go programs
  • Set breakpoints in code
  • Step through code (next, step in, step out)
  • Evaluate expressions in the context of a debug session
  • Inspect variables and stack traces
  • Manage multiple debug sessions

Installation

Prerequisites

  • Go 1.21 or higher
  • Delve debugger installed (go install github.com/go-delve/delve/cmd/dlv@latest)

Install

go install github.com/xhd2015/dlv-mcp/cmd/dlv-mcp@latest

Usage

Start the MCP server:

dlv-mcp --listen :9097

Then configure MCP Server at http://localhost:9097/sse, in Cursor or any MCP client.

Inspect the MCP Server

bunx @modelcontextprotocol/inspector dlv-mcp

Available Tools

Debug Session Management

  • start_debug: Start a new debug session

    • program: Path to Go program to debug
    • args: Command line arguments for the program (optional)
    • mode: Debug mode (debug, test, or exec, default: debug)
  • terminate_debug: Terminate a debug session

    • session_id: ID of the debug session to terminate
  • list_debug_sessions: List active debug sessions

Breakpoint Management

  • set_breakpoint: Set a breakpoint in a debug session
    • session_id: ID of the debug session
    • file: Source file to set breakpoint in (absolute path)
    • line: Line number to set breakpoint at

Execution Control

  • continue: Continue execution in a debug session

    • session_id: ID of the debug session
  • next: Step over current line in a debug session

    • session_id: ID of the debug session
  • step_in: Step into function in a debug session

    • session_id: ID of the debug session
  • step_out: Step out of function in a debug session

    • session_id: ID of the debug session

Inspection

  • evaluate: Evaluate an expression in a debug session
    • session_id: ID of the debug session
    • expression: Expression to evaluate
    • frame_id: Stack frame ID (optional, default: 0)

Example Workflow

  1. Start a debug session:

    start_debug program=/path/to/program.go
    
  2. Set a breakpoint:

    set_breakpoint session_id=session-123456 file=/path/to/program.go line=15
    
  3. Continue to breakpoint:

    continue session_id=session-123456
    
  4. Evaluate an expression:

    evaluate session_id=session-123456 expression="myVariable"
    
  5. Step over a line:

    next session_id=session-123456
    
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →