get_data_model
Retrieve comprehensive details of a Panther data model, including Python body code and UDM mappings. Requires 'View Rules' permission to access specific data model ID.
Instructions
Get detailed information about a Panther data model, including the mappings and body
Returns complete data model information including Python body code and UDM mappings.
Permissions:{'all_of': ['View Rules']}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data_model_id | Yes | The ID of the data model to fetch |
Implementation Reference
- src/mcp_panther/panther_mcp_core/tools/data_models.py:90-95 (registration)The @mcp_tool decorator that registers the get_data_model function as an MCP tool, specifying required permissions and read-only hint.@mcp_tool( annotations={ "permissions": all_perms(Permission.RULE_READ), "readOnlyHint": True, } )
- Pydantic input schema definition for the data_model_id parameter using Annotated and Field, including description and examples.data_model_id: Annotated[ str, Field( description="The ID of the data model to fetch", examples=["MyDataModel", "AWS_CloudTrail", "StandardUser"], ), ],
- The core handler function that implements the get_data_model tool logic: logs the request, fetches the data model via REST API endpoint `/data-models/{id}`, handles 404 not found, returns structured success/error response.async def get_data_model( data_model_id: Annotated[ str, Field( description="The ID of the data model to fetch", examples=["MyDataModel", "AWS_CloudTrail", "StandardUser"], ), ], ) -> dict[str, Any]: """Get detailed information about a Panther data model, including the mappings and body Returns complete data model information including Python body code and UDM mappings. """ logger.info(f"Fetching data model details for data model ID: {data_model_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"/data-models/{data_model_id}", expected_codes=[200, 404] ) if status == 404: logger.warning(f"No data model found with ID: {data_model_id}") return { "success": False, "message": f"No data model found with ID: {data_model_id}", } logger.info( f"Successfully retrieved data model details for data model ID: {data_model_id}" ) return {"success": True, "data_model": result} except Exception as e: logger.error(f"Failed to get data model details: {str(e)}") return { "success": False, "message": f"Failed to get data model details: {str(e)}", }
- The mcp_tool decorator definition that collects tool functions into a registry for later bulk registration with the MCP server.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)