get_method_callees
Identify methods called by a specified method in code. The tool analyzes the full name of the source method and returns details of its callees, aiding in code review and security analysis.
Instructions
Retrieves a list of methods info that are called by the specified method
@param method_full_name: The fully qualified name of the source method(e.g., com.android.nfc.NfcService$6.onReceive:void(android.content.Context,android.content.Intent)) @return: List of full name, name, signature and id of methods which call the source method
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method_full_name | Yes |
Implementation Reference
- server_tools.py:36-45 (handler)The handler function implementing the logic for the get_method_callees tool. It queries the Joern server for callees of the given method and extracts the list.@joern_mcp.tool() def get_method_callees(method_full_name: str) -> list[str]: """Retrieves a list of methods info that are called by the specified method @param method_full_name: The fully qualified name of the source method(e.g., com.android.nfc.NfcService$6.onReceive:void(android.content.Context,android.content.Intent)) @return: List of full name, name, signature and id of methods which call the source method """ # responses = joern_remote(f'cpg.method.fullNameExact("{method_full_name}").head.callee.distinct.map(m => (s"methodFullName=$' + '{m.fullName} methodId=${m.id}L")).l') responses = joern_remote(f'get_method_callees("{method_full_name}")') return extract_list(responses)
- server.py:96-105 (registration)Registers the get_method_callees tool (and others) by dynamically executing the server_tools.py module in the current namespace, allowing the @joern_mcp.tool() decorators to register the functions.def generate(): """Generate and execute additional server tools from server_tools.py file. This function reads the content of server_tools.py and executes it to add more functionality to the server. """ with open(GENERATED_PY, "r") as f: code = f.read() exec(compile(code, GENERATED_PY, "exec"))
- server.py:38-70 (helper)Core helper function used by get_method_callees to send the Joern query to the server and retrieve the raw response.def joern_remote(query): """ Execute remote query and return results Parameters: query -- The query string to execute Returns: Returns the server response stdout content on success Returns None on failure, error message will be output to stderr """ data = {"query": query} headers = {'Content-Type': 'application/json'} try: response = requests.post( f'http://{server_endpoint}/query-sync', data=json.dumps(data), headers=headers, auth=basic_auth, timeout=timeout ) response.raise_for_status() result = response.json() return remove_ansi_escape_sequences(result.get('stdout', '')) except requests.exceptions.RequestException as e: sys.stderr.write(f"Request Error: {str(e)}\n") except json.JSONDecodeError: sys.stderr.write("Error: Invalid JSON response\n") return None