Skip to main content
Glama
sbergeron42

gdb-multiarch-mcp

by sbergeron42

gdb_call_function

Execute functions in a debugged Nintendo Switch process to test code behavior or modify runtime state during debugging sessions.

Instructions

Call a function in the target process. WARNING: executes code in the debugged program.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
function_callYesFunction call expression (e.g., 'printf("hello\n")' or 'my_func(arg1, arg2)')

Implementation Reference

  • Implementation of the call_function method which executes the GDB 'call' command via interpreter-exec console.
    def call_function(
        self, function_call: str, timeout_sec: int = DEFAULT_TIMEOUT_SEC
    ) -> dict[str, Any]:
        """
        Call a function in the target process.
    
        This is a privileged operation that executes the GDB 'call' command,
        which invokes a function in the debugged program. This can execute
        arbitrary code in the target process and may have side effects.
    
        WARNING: Use with caution as this can modify program state.
    
        Args:
            function_call: Function call expression (e.g., "printf(\\"hello\\n\\")"
                          or "my_function(arg1, arg2)")
            timeout_sec: Timeout for command execution
    
        Returns:
            Dict with the function's return value or error
        """
        if not self.controller:
            return {"status": "error", "message": "No active GDB session"}
    
        if not self._is_gdb_alive():
            return {
                "status": "error",
                "message": "GDB process has exited - cannot execute call",
            }
    
        # Build the call command
        command = f"call {function_call}"
    
        # Escape for MI command
        escaped_command = command.replace("\\", "\\\\").replace('"', '\\"')
        mi_command = f'-interpreter-exec console "{escaped_command}"'
    
        result = self._send_command_and_wait_for_prompt(mi_command, timeout_sec)
    
        if "error" in result:
            return {
                "status": "error",
                "message": result["error"],
                "function_call": function_call,
            }
    
        if result.get("timed_out"):
            return {
                "status": "error",
                "message": f"Timeout waiting for call to complete after {timeout_sec}s",
                "function_call": function_call,
            }
    
        parsed = self._parse_responses(result.get("command_responses", []))
        console_output = "".join(parsed.get("console", []))
    
        return {
            "status": "success",
            "function_call": function_call,
            "result": console_output.strip() if console_output else "(no return value)",
        }
  • MCP tool handler entry point for gdb_call_function, which dispatches to GDBSession.call_function.
    elif name == "gdb_call_function":
        a = CallFunctionArgs(**arguments)
        result = session.call_function(function_call=a.function_call)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of disclosing side effects. The WARNING explicitly states this executes code in the debugged program, which is critical behavioral information. It could further clarify return value handling or thread context, but covers the essential safety concern.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences: one stating purpose, one providing a critical safety warning. Zero redundancy, front-loaded with the verb, and every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the high schema coverage and lack of output schema, the description is adequate. However, for a tool performing arbitrary code execution, it could mention prerequisites (process must be stopped) or return value behavior without violating conciseness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with clear examples ('printf("hello\n")'), so the structured schema fully documents the parameter. The description does not add semantic information beyond what the schema provides, which is appropriate given the high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Call a function') and the target ('in the target process'), distinguishing it from siblings like gdb_evaluate_expression (inspection) and gdb_execute_command (GDB CLI commands).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The WARNING about executing code provides strong implicit guidance about when to use this (intentional execution) versus inspection alternatives. However, it does not explicitly name gdb_evaluate_expression as the non-executing alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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