Skip to main content
Glama
0xhackerfren

Frida Game Hacking MCP

by 0xhackerfren

scan_next

Refine memory scan results by searching for a specific value to narrow down addresses in game hacking and reverse engineering processes.

Instructions

Narrow scan results with new value.

Args:
    value: New value to search for

Returns:
    Number of remaining addresses.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The scan_next tool handler: narrows previous scan results by batch-reading memory from candidate addresses via Frida scripts and filtering those whose current value bytes match the packed new value.
    @mcp.tool()
    def scan_next(value: Union[int, float, str]) -> Dict[str, Any]:
        """
        Narrow scan results with new value.
        
        Args:
            value: New value to search for
        
        Returns:
            Number of remaining addresses.
        """
        global _session
        
        if not _session.is_attached():
            return {"error": "Not attached. Use attach() first."}
        
        if not _session.scan_state.scan_active:
            return {"error": "No active scan. Use scan_value() first."}
        
        try:
            value_type = _session.scan_state.value_type
            value_size = _get_value_size(value_type)
            
            if value_type == "string":
                expected_hex = value.encode('utf-8').hex()
            else:
                expected_hex = _pack_value(value, value_type).hex()
            
            addresses = _session.scan_state.results
            if not addresses:
                return {"success": True, "value": value, "remaining": 0}
            
            batch_size = 1000
            new_results = []
            
            for batch_start in range(0, len(addresses), batch_size):
                batch = addresses[batch_start:batch_start + batch_size]
                addr_list = ", ".join(f'"{hex(a)}"' for a in batch)
                
                script_code = f"""
                var addresses = [{addr_list}];
                var size = {value_size};
                var expected = "{expected_hex}";
                var matches = [];
                
                for (var i = 0; i < addresses.length; i++) {{
                    try {{
                        var data = Memory.readByteArray(ptr(addresses[i]), size);
                        var hex = '';
                        var bytes = new Uint8Array(data);
                        for (var j = 0; j < bytes.length; j++) {{
                            hex += ('0' + bytes[j].toString(16)).slice(-2);
                        }}
                        if (hex === expected) matches.push(addresses[i]);
                    }} catch (e) {{ }}
                }}
                send(JSON.stringify(matches));
                """
                
                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 result_data:
                    import json
                    matches = json.loads(result_data[0])
                    new_results.extend([int(a, 16) for a in matches])
            
            _session.scan_state.results = new_results
            _session.scan_state.last_values = {addr: value for addr in new_results}
            
            return {
                "success": True,
                "value": value,
                "remaining": len(new_results),
                "message": f"Narrowed to {len(new_results)} addresses."
            }
        
        except Exception as e:
            return {"error": f"Scan next failed: {str(e)}"}
  • Dataclass used by scan_next to maintain scan results list, last known values per address, value type, and active state.
    class ScanState:
        """Tracks memory scan state for Cheat Engine-style scanning."""
        value_type: str = ""
        results: List[int] = field(default_factory=list)
        last_values: Dict[int, Any] = field(default_factory=dict)
        scan_active: bool = False
  • Helper function used by scan_next to determine byte size of value_type for memory reads.
    def _get_value_size(value_type: str) -> int:
        """Get byte size for value type."""
        sizes = {
            "int8": 1, "uint8": 1,
            "int16": 2, "uint16": 2,
            "int32": 4, "uint32": 4,
            "int64": 8, "uint64": 8,
            "float": 4, "double": 8
        }
        return sizes.get(value_type, 4)
  • Helper function used by scan_next to pack the new value into bytes/hex for comparison in Frida script.
    def _pack_value(value: Any, value_type: str) -> bytes:
        """Pack value to bytes based on type."""
        formats = {
            "int8": "<b", "uint8": "<B",
            "int16": "<h", "uint16": "<H",
            "int32": "<i", "uint32": "<I",
            "int64": "<q", "uint64": "<Q",
            "float": "<f", "double": "<d"
        }
        fmt = formats.get(value_type)
        if fmt:
            return struct.pack(fmt, value)
        elif value_type == "string":
            return value.encode('utf-8') + b'\x00'
        return struct.pack("<i", int(value))
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'narrow scan results' but doesn't disclose critical behavioral traits: what type of scan it operates on (memory, process, etc.), whether it modifies existing data or creates new results, error conditions, or performance characteristics. The return value description is minimal but doesn't explain what 'remaining addresses' means contextually.

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

Conciseness4/5

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

The description is appropriately concise with three sentences: purpose, parameter explanation, and return value. Each sentence adds value, and it's front-loaded with the core functionality. No wasted words, though it could be slightly more structured (e.g., bullet points).

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 1 parameter, no annotations, and an output schema (implied by 'Returns'), the description is minimally adequate. It covers the parameter's role and return type, but lacks context about scan types, prerequisites, and error handling. For a tool in a debugging/memory scanning context with many siblings, more operational details would help.

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?

With 1 parameter and 0% schema description coverage, the description adds essential meaning: it explains that 'value' is a 'new value to search for'. This clarifies the parameter's purpose beyond the schema's generic title 'Value'. However, it doesn't specify format constraints or examples (e.g., numeric vs. string values), leaving some ambiguity.

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

Purpose3/5

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

The description states the tool 'narrow scan results with new value', which provides a vague purpose (verb+resource). It doesn't specify what type of scan (memory? process? module?) or what 'narrow' means operationally. Compared to siblings like 'scan_value', 'scan_pattern', 'scan_changed', and 'scan_unchanged', it lacks clear differentiation beyond implying it's a follow-up operation.

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 explicit guidance on when to use this tool versus alternatives. The description implies it's for narrowing existing scan results, but doesn't specify prerequisites (e.g., must have an active scan from another tool) or when to choose it over similar tools like 'scan_value' or 'get_scan_results'. The agent must infer usage from context alone.

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