load_cpg
Loads a Code Property Graph (CPG) from a specified file path for security analysis and code review in the Joern MCP Server.
Instructions
Loads a CPG from a file if the cpg is not loaded or the cpg is not the same as the filepath.
Args:
cpg_filepath (str): The path to the CPG file, the filepath is absolute path.
Returns:
str: True if the CPG is loaded successfully, False otherwise.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cpg_filepath | Yes |
Implementation Reference
- server_tools.py:21-35 (handler)The load_cpg tool handler function, decorated with @joern_mcp.tool() for registration. It executes joern_remote to load the CPG file and extracts the value.@joern_mcp.tool() def load_cpg(cpg_filepath: str) -> str: """ Loads a CPG from a file if the cpg is not loaded or the cpg is not the same as the filepath. Args: cpg_filepath (str): The path to the CPG file, the filepath is absolute path. Returns: str: True if the CPG is loaded successfully, False otherwise. """ # return extract_value(joern_remote(f'val cpg = CpgLoader.load("{cpg_filepath}")')) return extract_value(joern_remote(f'load_cpg("{cpg_filepath}")'))