Skip to main content
Glama

get_method_callees

Identify methods called by a specified method to analyze code dependencies and understand execution flow during code review or 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
NameRequiredDescriptionDefault
method_full_nameYes

Implementation Reference

  • The handler function for the 'get_method_callees' tool. It is decorated with @joern_mcp.tool(), which also serves as the registration mechanism. The function queries the Joern server using joern_remote and processes the response with extract_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:102-104 (registration)
    The exec statement in the generate() function that dynamically loads and executes server_tools.py, thereby registering all tools including 'get_method_callees' via their decorators.
    with open(GENERATED_PY, "r") as f: code = f.read() exec(compile(code, GENERATED_PY, "exec"))
  • The joern_remote helper function used by get_method_callees to send queries to the Joern server.
    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
  • The extract_list helper function used to parse the list response from Joern queries in get_method_callees.
    def extract_list(input_str): """Extract a list of elements from a string representation of a Scala List. Parameters: input_str -- The input string containing a Scala List representation Returns: A Python list containing the extracted elements with cleaned data

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/sfncat/mcp-joern'

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