Skip to main content
Glama
sbergeron42

gdb-multiarch-mcp

by sbergeron42

switch_start_session

Initialize debugging for Nintendo Switch executables by connecting to the GDB stub, loading debug commands, and setting up the game's base address automatically.

Instructions

Start gdb-multiarch and connect to the Switch/Yuzu GDB stub. This MUST be called before any other tool. Connects to the IP/port configured via SWITCH_IP and SWITCH_PORT environment variables (defaults: 192.168.1.235:22225). Automatically loads Switch debug commands, attaches to the game, and sets $main to the base address of cross2_Release.nss. Do NOT manually run 'target remote', 'attach', or 'set $main' — this tool handles all of that.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The _start_session function implements the logic to initialize the GDB session, deploy necessary scripts, and connect to the target.
    def _start_session() -> dict:
        """
        Start a gdb-multiarch session and connect to Yuzu.
    
        Uses DEFAULT_SWITCH_IP:DEFAULT_SWITCH_PORT, sources the Switch gdbinit
        commands, runs attach.py to auto-attach and set $main.
        """
        global _session
        with _session_lock:
            if _session is not None and _session.is_running:
                return {"status": "error", "message": "Session already running. Stop it first."}
    
            scripts_dir = _deploy_scripts()
    
            _session = GDBSession()
            init_cmds = [
                f"source {scripts_dir}/gdbinit_switch",
                f"target extended-remote {DEFAULT_SWITCH_IP}:{DEFAULT_SWITCH_PORT}",
                f"source {scripts_dir}/attach.py",
            ]
    
            result = _session.start(init_commands=init_cmds)
    
            if result.get("status") == "error":
                logger.error(f"Start failed: {result.get('message')}")
                _session = None
    
            return result
  • Tool definition and registration for 'switch_start_session' in the list_tools method.
    Tool(
        name="switch_start_session",
        description=(
            "Start gdb-multiarch and connect to the Switch/Yuzu GDB stub. "
            "This MUST be called before any other tool. "
            "Connects to the IP/port configured via SWITCH_IP and SWITCH_PORT "
            "environment variables (defaults: 192.168.1.235:22225). "
            "Automatically loads Switch debug commands, attaches to the game, "
            "and sets $main to the base address of cross2_Release.nss. "
            "Do NOT manually run 'target remote', 'attach', or 'set $main' — "
            "this tool handles all of that."
        ),
        inputSchema=NO_ARGS_SCHEMA,
    ),
  • Dispatch logic in the call_tool function that routes the 'switch_start_session' tool call to the _start_session handler.
    if name == "switch_start_session":
        result = _start_session()

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/sbergeron42/gdb-multiarch-mcp'

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