Skip to main content
Glama
cbxss
by cbxss

heap_search

Find live Java class instances in the heap of an Android device by specifying the class name and maximum results. Enables runtime inspection of objects for security analysis.

Instructions

Search Java heap for live instances of a class

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
class_nameYesFull Java class name (e.g., 'java.security.Key')
max_resultsNoMax instances to return (default: 10)

Implementation Reference

  • The JavaScript Frida agent implementation that uses Java.choose() to enumerate live Java heap instances of a class, collecting their handle, toString(), and class name up to maxResults.
    heapSearch(className, maxResults) {
        if (!Java.available) {
            throw new Error("Java runtime not available");
        }
        const results = [];
        const limit = maxResults || 10;
        Java.performNow(() => {
            try {
                Java.choose(className, {
                    onMatch(instance) {
                        if (results.length < limit) {
                            const info = { handle: instance.$h || instance.toString() };
                            try {
                                info.toString = instance.toString();
                            } catch (e) {}
                            try {
                                info.class = instance.getClass().getName();
                            } catch (e) {}
                            results.push(info);
                        }
                    },
                    onComplete() {}
                });
            } catch (e) {
                results.push({ error: e.message });
            }
        });
        return { instances: results };
    },
  • Python handler that gets the active Frida RPC API and calls the heap_search RPC method (which maps to the JS agent's heapSearch), with a 10-second timeout.
    def heap_search(class_name: str, max_results: int = 10) -> dict:
        """Search Java heap for instances of a class."""
        api = get_api()
        return with_timeout(lambda: api.heap_search(class_name, max_results), timeout=10)
  • MCP tool schema definition for heap_search, declaring the input schema (class_name required, max_results optional with default 10) and description.
    Tool(
        name="heap_search",
        description="Search Java heap for live instances of a class",
        inputSchema={
            "type": "object",
            "properties": {
                "class_name": {"type": "string", "description": "Full Java class name (e.g., 'java.security.Key')"},
                "max_results": {"type": "integer", "description": "Max instances to return (default: 10)"},
            },
            "required": ["class_name"],
        },
    ),
  • Tool dispatch in the server's call_tool function that routes the 'heap_search' tool name to android.heap_search(), passing class_name from arguments and defaulting max_results to 10.
    elif name == "heap_search":
        return android.heap_search(arguments["class_name"], arguments.get("max_results", 10))
Behavior2/5

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

No annotations are provided, so the description must carry full burden. It only states the basic operation without disclosing behavioral traits like performance impact, error handling, or whether the search is blocking. For a heap search tool, more transparency is needed.

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 a single, concise sentence that directly states the purpose. No wasted words, but could benefit from slight restructuring to include key details without becoming lengthy.

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

Completeness2/5

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

The tool has no output schema, so the description should ideally mention what is returned (e.g., list of instances). It does not, leaving the agent without information about return format. Given low complexity, this gap is significant.

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 descriptions for both parameters. The description adds no additional meaning beyond the schema, so baseline of 3 is appropriate.

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: searching the Java heap for live instances of a class. It uses a specific verb ('Search') and resource ('Java heap'), and the scope is well-defined. Among siblings, it is distinct from generic memory_search or dump_class.

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

Usage Guidelines3/5

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

The description implies when to use the tool (when needing live instances of a class in the heap) but provides no explicit guidance on when not to use it or alternatives. No exclusions or comparisons are given.

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/cbxss/frida-mcp'

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