openmcpgdb
openmcpgdb is an asynchronous Rust MCP server for debugging native programs through GDB.
It is implemented with the rmcp crate and exposes a full openmcpgdb_* tool API for MCP clients (Codex, Claude Code, opencode-compatible clients).
Features
- MCP server built with
rmcp(tools/list,tools/callsupport). - One dedicated worker thread per MCP client session.
- GDB process isolation per client.
- Configurable display windows for source, backtrace, and watched variables.
- Transport modes:
https://...andhttp://...streamable HTTP mode (default)stdio://...for stdio MCP wiring when needed
- Interactive MCP test client binary included.
- Rust tests include:
- in-process MCP server/client connectivity
- tool-call coverage
- integration test against
examples/mazerobot/maze_robot
Requirements
- Rust toolchain (stable)
- GDB at an absolute path (default
/usr/bin/gdb) - Linux/macOS environment for the provided examples
Project Layout
src/main.rs: server entrypointsrc/runtime.rs: transport/runtime bootstrappingsrc/server.rs: MCP tool routing and handlerssrc/session.rs: per-client worker thread and operation executionsrc/gdb.rs: real and mock GDB backendssrc/bin/interactive_client.rs: interactive MCP clienttests/mazerobot_mcp_client.rs: integration MCP client test against mazerobotconfig.json: default config template
Configuration
The server loads JSON config from the first CLI argument, defaulting to config.json in project root.
All filesystem paths must be absolute.
Example:
display_join_current_code controls how current_code is returned:
false: object map keyed by line numbertrue: single joined string in the formatline | sourcewith newline separators
mcp_server_url
- Default:
https://localhost:9443 http://host:port/pathorhttps://host:port/path: run streamable HTTP on that bind address/path.stdio://...: run MCP over stdio.
Note: https:// is parsed and accepted, but this project currently binds plain TCP HTTP directly. For real TLS, run behind a TLS-terminating reverse proxy.
Build
Run the MCP Server
1. Default HTTPS URL mode
Use default config:
2. HTTP/HTTPS custom URL mode
Set config URL, for example:
"mcp_server_url": "https://localhost:9443"
Run:
3. Optional stdio mode
Set:
"mcp_server_url": "stdio://local"
Run:
Interactive MCP Client
An interactive MCP client is included for manual testing against HTTP server mode.
Run:
Input format:
<tool_name> <json-args>
Examples of Debugging on local GDB:
openmcpgdb_execute {"executable_path":"/home/brosnan/openmcpgdb/openmcpgdb/examples/mazerobot/maze_robot"}
openmcpgdb_debugger_state {}
openmcpgdb_add_variable_list {"var":"robot_state"}
openmcpgdb_add_breakpoint {"filename":"/home/brosnan/openmcpgdb/openmcpgdb/examples/mazerobot/src/main.c","linenumber":20}
openmcpgdb_run {}
openmcpgdb_next {}
openmcpgdb_step {}
openmcpgdb_print {"var":"counter"}
openmcpgdb_full_backtrace {}
openmcpgdb_continue {}
openmcpgdb_quit {}
Type quit to exit the interactive client.
Use With MCP Clients
This server is compatible with MCP clients that support either:
- command-based stdio servers
- streamable HTTP servers
opencode (stdio recommended)
Use MCP server command settings pointing to:
And set in config:
"mcp_server_url": "stdio://local"
OpenAI Codex clients
You can use either mode:
stdiomode:
- server command:
- config URL:
"mcp_server_url": "stdio://local"
- HTTP mode:
- run server with:
"mcp_server_url": "https://localhost:9443"
- connect client MCP endpoint to:
http://localhost:9443
Claude Code clients
For local development, prefer stdio:
with:
"mcp_server_url": "stdio://local"
If you use HTTP transport, point the client to:
http://localhost:9443
Important transport note
https://localhost:9443 is accepted in this project config as a default URL shape, but the current server bind is plain HTTP.
For true TLS HTTPS, run behind a TLS reverse proxy and expose an HTTPS endpoint there.
Tool API
All tool responses include debugger_state and optional fields like variable_list, backtrace, current_code*, and error.
debugger_state values
not attachedfailed to attachattachedstopped at breakpointrunningsigsegvsigabrtsigbussigfpesigillsigtrapsigtermsigkillexitederror
Execution/session
openmcpgdb_execute(executable_path)openmcpgdb_run()openmcpgdb_target_remote(ip, port)openmcpgdb_set_thread(id)openmcpgdb_set_frame(id)
Breakpoints
openmcpgdb_add_breakpoint(filename, linenumber)openmcpgdb_clear_breakpoint(filename, linenumber)openmcpgdb_enable_breakpoint(filename, linenumber)openmcpgdb_disable_breakpoint(filename, linenumber)openmcpgdb_list_breakpoint()
Stepping
openmcpgdb_next()openmcpgdb_step()openmcpgdb_continue()
Variable watch list
openmcpgdb_add_variable_list(var)openmcpgdb_del_variable_list(var)openmcpgdb_variable_list()
Inspection
openmcpgdb_debugger_state()openmcpgdb_current_code()openmcpgdb_full_backtrace()openmcpgdb_info_threads()openmcpgdb_info_regs()openmcpgdb_print(var)openmcpgdb_set_var(var, value)
Control/config/custom
openmcpgdb_quit()openmcpgdb_kill()openmcpgdb_display_lines_before_current(size)openmcpgdb_display_lines_after_current(size)openmcpgdb_display_backtrace(size)openmcpgdb_display_variable_list(size)openmcpgdb_custom(cmd)
Testing
Run all tests:
Included test coverage:
- MCP server starts and MCP client connects.
- Unit-style all-tool-call response checks.
- Integration test starting MCP server with:
- codebase:
/home/brosnan/openmcpgdb/openmcpgdb/examples/mazerobot/ - binary:
/home/brosnan/openmcpgdb/openmcpgdb/examples/mazerobot/maze_robot - MCP client in
tests/mazerobot_mcp_client.rs
- codebase:
Quick Start (Mazerobot)
- Ensure binary exists:
- Set
config.jsonfor mazerobot absolute paths. - Start server:
- In another terminal (HTTP mode), run interactive client and call tools.