get_global_helper
Retrieve comprehensive details of a global helper by its ID, including Python code and usage information. Requires 'View Rules' permissions for access.
Instructions
Get detailed information about a Panther global helper by ID
Returns complete global helper information including Python body code and usage details.
Permissions:{'all_of': ['View Rules']}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| helper_id | Yes | The ID of the global helper to fetch |
Implementation Reference
- Full implementation of the 'get_global_helper' MCP tool handler, including decorator for registration, input schema via Annotated/Field, and core logic to fetch global helper details from Panther API by ID.@mcp_tool( annotations={ "permissions": all_perms(Permission.RULE_READ), "readOnlyHint": True, } ) async def get_global_helper( helper_id: Annotated[ str, Field( description="The ID of the global helper to fetch", examples=["MyGlobalHelper", "AWSUtilities", "CrowdStrikeHelpers"], ), ], ) -> dict[str, Any]: """Get detailed information about a Panther global helper by ID Returns complete global helper information including Python body code and usage details. """ logger.info(f"Fetching global helper details for helper ID: {helper_id}") try: async with get_rest_client() as client: # Allow 404 as a valid response to handle not found case result, status = await client.get( f"/globals/{helper_id}", expected_codes=[200, 404] ) if status == 404: logger.warning(f"No global helper found with ID: {helper_id}") return { "success": False, "message": f"No global helper found with ID: {helper_id}", } logger.info( f"Successfully retrieved global helper details for helper ID: {helper_id}" ) return {"success": True, "global_helper": result} except Exception as e: logger.error(f"Failed to get global helper details: {str(e)}") return { "success": False, "message": f"Failed to get global helper details: {str(e)}", }
- src/mcp_panther/panther_mcp_core/tools/__init__.py:24-38 (registration)Import of 'global_helpers' module in tools/__init__.py triggers execution of @mcp_tool decorator, adding get_global_helper to the internal tool registry.# Import all tool modules to ensure decorators are processed from . import ( alerts, data_lake, data_models, detections, global_helpers, metrics, permissions, roles, scheduled_queries, schemas, sources, users, )
- src/mcp_panther/server.py:75-75 (registration)Invocation of register_all_tools(mcp) in the main server.py, which registers all tools from the registry (including get_global_helper) with the FastMCP server instance.register_all_tools(mcp)
- The @mcp_tool decorator definition that handles tool registration by adding functions to _tool_registry and storing metadata used during final MCP registration.def mcp_tool( func: Optional[Callable] = None, *, name: Optional[str] = None, description: Optional[str] = None, annotations: Optional[Dict[str, Any]] = None, ) -> Callable: """ Decorator to mark a function as an MCP tool. Functions decorated with this will be automatically registered when register_all_tools() is called. Can be used in two ways: 1. Direct decoration: @mcp_tool def my_tool(): ... 2. With parameters: @mcp_tool( name="custom_name", description="Custom description", annotations={"category": "data_analysis"} ) def my_tool(): ... Args: func: The function to decorate name: Optional custom name for the tool. If not provided, uses the function name. description: Optional description of what the tool does. If not provided, uses the function's docstring. annotations: Optional dictionary of additional annotations for the tool. """ def decorator(func: Callable) -> Callable: # Store metadata on the function func._mcp_tool_metadata = { "name": name, "description": description, "annotations": annotations, } _tool_registry.add(func) @wraps(func) def wrapper(*args, **kwargs): return func(*args, **kwargs) return wrapper # Handle both @mcp_tool and @mcp_tool(...) cases if func is None: return decorator return decorator(func)