Skip to main content
Glama
TomMelt

HPC-MCP

by TomMelt

debug_crash

Debug crashing programs by analyzing stack traces to identify root causes of failures in HPC environments.

Instructions

Debug crashing program and return the stack trace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYes
argsYes

Implementation Reference

  • The main handler function for the 'debug_crash' tool. It generates a GDB command, executes it via subprocess, parses the backtrace from the output, and returns it.
    def debug_crash(target: str, args: list[str]) -> str: """Debug crashing program and return the stack trace.""" debug_cmd = generate_debug_cmd(target, args) debug_output = subprocess.run(shlex.split(debug_cmd), capture_output=True) backtrace_text = parse_backtrace(debug_output) return backtrace_text
  • Function signature providing input/output type hints serving as the tool schema: target (str), args (list[str]) -> str.
    def debug_crash(target: str, args: list[str]) -> str:
  • src/debug.py:8-8 (registration)
    Decorator registering the debug_crash function as an MCP tool.
    @mcp.tool
  • Helper function to construct the GDB command for batch mode execution, backtrace, and quit.
    def generate_debug_cmd(target: str, args: list[str]) -> str: """Generate a debug command for the target program with args.""" crash_script = shlex.split("--batch -ex b _exit -ex run -ex bt -ex quit") general_gdb_config = "-q" debug_cmd = shlex.join( ["gdb", general_gdb_config] + crash_script + ["--args", target] + args ) return debug_cmd
  • Helper function to extract backtrace lines (starting with '#') from GDB output.
    def parse_backtrace(debug_output: subprocess.CompletedProcess[bytes]) -> str: """Parse the backtrace from the output of gdb.""" raw_text = debug_output.stdout.decode("utf-8") backtrace = "\n".join( line for line in raw_text.splitlines() if line.startswith("#") ) return backtrace

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TomMelt/hpc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server