Skip to main content
Glama
0xhackerfren

Frida Game Hacking MCP

by 0xhackerfren

read_memory

Extract data from game memory addresses to analyze values, strings, or structures for reverse engineering and debugging purposes.

Instructions

Read memory at specified address.

Args:
    address: Memory address (hex string like "0x401234")
    size: Number of bytes to read
    format: Output format ("hex", "bytes", "int32", "float", "string")

Returns:
    Memory contents in requested format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes
sizeNo
formatNohex

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the read_memory tool. It attaches to a Frida session, injects JavaScript to read memory bytes using Memory.readByteArray, formats the output based on the specified format (hex, bytes, int32, float, string), and returns the result.
    @mcp.tool()
    def read_memory(address: str, size: int = 16, format: str = "hex") -> Dict[str, Any]:
        """
        Read memory at specified address.
        
        Args:
            address: Memory address (hex string like "0x401234")
            size: Number of bytes to read
            format: Output format ("hex", "bytes", "int32", "float", "string")
        
        Returns:
            Memory contents in requested format.
        """
        global _session
        
        if not _session.is_attached():
            return {"error": "Not attached. Use attach() first."}
        
        try:
            addr = int(address, 16) if address.startswith("0x") else int(address)
            
            script_code = f"""
            var addr = ptr("{hex(addr)}");
            try {{
                var data = Memory.readByteArray(addr, {size});
                var hex = '';
                var bytes = new Uint8Array(data);
                for (var i = 0; i < bytes.length; i++) {{
                    hex += ('0' + bytes[i].toString(16)).slice(-2);
                }}
                send({{type: 'data', hex: hex}});
            }} catch (e) {{
                send({{type: 'error', msg: e.toString()}});
            }}
            """
            
            result_data = []
            def on_message(message, data):
                if message['type'] == 'send':
                    result_data.append(message['payload'])
            
            script = _session.session.create_script(script_code)
            script.on('message', on_message)
            script.load()
            script.unload()
            
            if not result_data:
                return {"error": "No response from Frida"}
            
            response = result_data[0]
            if response.get('type') == 'error':
                return {"error": f"Memory read failed: {response.get('msg')}"}
            
            raw_bytes = bytes.fromhex(response['hex'])
            output = {"address": hex(addr), "size": size}
            
            if format == "hex":
                output["hex"] = raw_bytes.hex()
                output["hex_spaced"] = " ".join(f"{b:02x}" for b in raw_bytes)
            elif format == "bytes":
                output["bytes"] = list(raw_bytes)
            elif format == "int32" and size >= 4:
                output["value"] = struct.unpack("<i", raw_bytes[:4])[0]
            elif format == "float" and size >= 4:
                output["value"] = struct.unpack("<f", raw_bytes[:4])[0]
            elif format == "string":
                output["string"] = raw_bytes.split(b'\x00')[0].decode('utf-8', errors='replace')
            else:
                output["hex"] = raw_bytes.hex()
                output["hex_spaced"] = " ".join(f"{b:02x}" for b in raw_bytes)
            
            return output
        
        except Exception as e:
            return {"error": f"Failed to read memory: {str(e)}"}
  • The read_memory tool is listed in the capabilities under memory_operations category, advertised by the list_capabilities tool.
                "read_memory", "write_memory", "scan_value", "scan_next",
                "scan_changed", "scan_unchanged", "scan_pattern",
                "get_scan_results", "clear_scan", "list_memory_regions"
            ],
            "module_information": [
                "list_modules", "get_module_info", "get_module_exports",
                "get_module_imports", "resolve_symbol"
            ],
            "function_hooking": [
                "hook_function", "unhook_function", "replace_function",
                "hook_native_function", "list_hooks", "intercept_module_function"
            ],
            "debugging": [
                "set_breakpoint", "remove_breakpoint", "list_breakpoints", "read_registers"
            ],
            "script_management": [
                "load_script", "unload_script", "call_rpc"
            ],
            "window_interaction": [
                "list_windows", "screenshot_window", "screenshot_screen",
                "send_key_to_window", "focus_window"
            ],
            "standard": [
                "list_capabilities", "get_documentation", "check_installation"
            ]
        },
        "total_tools": 42
    }
Behavior2/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 behavioral disclosure. It states the action ('Read memory') and return values, but lacks critical details: it doesn't mention potential errors (e.g., invalid addresses, access violations), safety implications (e.g., whether this is a safe read operation or could crash processes), or dependencies (e.g., requires an attached debug session). This is inadequate for a low-level memory tool.

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?

The description is efficiently structured with a clear purpose statement followed by bullet points for arguments and returns. Every sentence earns its place by providing essential information without redundancy, making it easy to scan and understand quickly.

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 complexity of a memory read operation, no annotations, and an output schema that likely covers return values, the description is partially complete. It explains parameters well but misses behavioral context like error handling or prerequisites. For a tool with potential safety implications, this leaves gaps that could hinder effective use.

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

Parameters4/5

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

The description adds significant value beyond the input schema, which has 0% description coverage. It explains each parameter's purpose: 'address' as a hex string, 'size' as bytes to read, and 'format' as output options with examples. This compensates well for the schema's lack of details, though it could specify default values or constraints more explicitly.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('Read') and resource ('memory at specified address'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_memory_regions' or 'write_memory', which would require mentioning this is for reading raw memory content rather than metadata or writing operations.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention when to choose 'read_memory' over 'list_memory_regions' (for metadata) or 'write_memory' (for modifications), nor does it specify prerequisites like needing an attached process or valid memory access. This leaves the agent without context for tool selection.

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/0xhackerfren/frida-game-hacking-mcp'

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