Skip to main content
Glama
sfncat
by sfncat

get_class_methods_by_class_full_name

Retrieve all methods from a class by providing its fully qualified name. Returns method details including full name, signature, and ID for code analysis.

Instructions

Get the methods of a class by its fully qualified name

@param class_full_name: The fully qualified name of the class
@return: List of full name, name, signature and id of methods in the class

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
class_full_nameYes

Implementation Reference

  • The handler function implementing the 'get_class_methods_by_class_full_name' MCP tool. It is registered via the @joern_mcp.tool() decorator. The function sends a parameterized query to the Joern server using the joern_remote helper and parses the response into a list using extract_list.
    @joern_mcp.tool()
    def get_class_methods_by_class_full_name(class_full_name:str) -> list[str]:
        """Get the methods of a class by its fully qualified name
      
        @param class_full_name: The fully qualified name of the class
        @return: List of full name, name, signature and id of methods in the class
        """
        response = joern_remote(f'get_class_methods_by_class_full_name("{class_full_name}")')
        return extract_list(response)
  • server.py:94-106 (registration)
    The generate() function in server.py dynamically executes server_tools.py, which defines and registers the tool via its @joern_mcp.tool() decorator during server startup.
    SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
    GENERATED_PY = os.path.join(SCRIPT_DIR, "server_tools.py")
    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"))
    
    generate()
  • The joern_remote helper function, called by the tool handler to execute the actual Joern query on the remote 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 parses the Joern query response into a structured list of method information (fullName, name, signature, id). Used by the tool handler.
    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