Skip to main content
Glama

check_connection

Verify the operational status of the Joern MCP plugin to ensure it is actively running and ready for code review and security analysis tasks.

Instructions

Check if the Joern MCP plugin is running

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • server.py:83-93 (handler)
    The main handler function for the 'check_connection' tool. It is registered via the @joern_mcp.tool() decorator. Checks Joern server connection by running a 'version' query, extracting the version with extract_value, and returning a success or failure message.
    @joern_mcp.tool() def check_connection() -> str: """Check if the Joern MCP plugin is running""" try: metadata = extract_value(joern_remote("version")) if not metadata: return f"Failed to connect to Joern MCP! Make sure the Joern MCP server is running." return f"Successfully connected to Joern MCP, joern server version is {metadata}" except Exception as e: return f"Failed to connect to Joern MCP! Make sure the Joern MCP server is running."
  • Helper function used by check_connection to send the 'version' query to the Joern server endpoint via HTTP POST, processes the response, removes ANSI escapes, and returns the cleaned stdout.
    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
  • Helper function imported from common_tools.py, used by check_connection to parse the version string from the Joern server response and extract the actual version value.
    def extract_value(input_str: str) -> str: """Extract value from a string based on its pattern. This function automatically selects the appropriate extraction method based on the input string format: * If contains 'Long =', uses extract_long_value * If contains triple quotes, uses extract_code_between_triple_quotes * If contains single quotes, uses extract_quoted_string Args: input_str (str): Input string containing a value to extract Returns: str: Extracted value based on the detected pattern """ if 'Long =' in input_str: return extract_long_value(input_str) elif 'String = """' in input_str: return extract_code_between_triple_quotes(input_str) elif 'String = "' in input_str: return extract_quoted_string(input_str) else: return input_str

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