tracker_settings_app_update
Update tracker settings for a specific app in Piwik PRO Analytics. Modify anonymization levels, session durations, campaign parameters, IP exclusions, and other tracking configurations using JSON attributes.
Instructions
Update tracker settings for a specific app using JSON attributes.
This tool uses a simplified interface with 2 parameters: app_id and attributes.
Use tools_parameters_get("tracker_settings_app_update") to get
the complete JSON schema with all available fields, types, and validation rules.
Args:
app_id: UUID of the app
attributes: Dictionary containing tracker settings attributes to update. All fields
are optional. Supported fields include anonymize_visitor_ip_level,
excluded_ips, session settings, campaign parameters, and more.
Returns:
Dictionary containing update status:
- status: Update status
- message: Descriptive message
- updated_fields: List of fields that were updated
Parameter Discovery:
Use tools_parameters_get("tracker_settings_app_update") to get
the complete JSON schema for all available fields. This returns validation rules,
field types, and examples.
Examples:
# Get available parameters first
schema = tools_parameters_get("tracker_settings_app_update")
# Update basic settings
attributes = {
"anonymize_visitor_ip_level": 2,
"excluded_ips": ["192.168.1.1", "10.0.0.1"]
}
# Update session and campaign settings
attributes = {
"session_max_duration_seconds": 3600,
"campaign_name_params": ["utm_campaign", "campaign"],
"exclude_crawlers": True
}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_id | Yes | ||
| attributes | Yes |
Implementation Reference
- MCP tool handler for tracker_settings_app_update. Decorated with @mcp.tool and implements the tool logic by calling the underlying update function after validation.
@mcp.tool(annotations={"title": "Piwik PRO: Update App Tracker Settings"}) def tracker_settings_app_update(app_id: str, attributes: dict) -> UpdateStatusResponse: """Update tracker settings for a specific app using JSON attributes. This tool uses a simplified interface with 2 parameters: app_id and attributes. Use tools_parameters_get("tracker_settings_app_update") to get the complete JSON schema with all available fields, types, and validation rules. Args: app_id: UUID of the app attributes: Dictionary containing tracker settings attributes to update. All fields are optional. Supported fields include anonymize_visitor_ip_level, excluded_ips, session settings, campaign parameters, and more. Returns: Dictionary containing update status: - status: Update status - message: Descriptive message - updated_fields: List of fields that were updated Parameter Discovery: Use tools_parameters_get("tracker_settings_app_update") to get the complete JSON schema for all available fields. This returns validation rules, field types, and examples. Examples: # Get available parameters first schema = tools_parameters_get("tracker_settings_app_update") # Update basic settings attributes = { "anonymize_visitor_ip_level": 2, "excluded_ips": ["192.168.1.1", "10.0.0.1"] } # Update session and campaign settings attributes = { "session_max_duration_seconds": 3600, "campaign_name_params": ["utm_campaign", "campaign"], "exclude_crawlers": True } """ return update_app_tracker_settings(app_id, attributes) - Core helper function that performs the actual API call to update app tracker settings, including validation against AppTrackerSettings schema.
def update_app_tracker_settings(app_id: str, attributes: dict) -> UpdateStatusResponse: try: client = create_piwik_client() # Validate attributes directly against the model validated_attrs = validate_data_against_model(attributes, AppTrackerSettings) # Convert to dictionary and filter out None values update_kwargs = {k: v for k, v in validated_attrs.model_dump(by_alias=True, exclude_none=True).items()} if not update_kwargs: raise RuntimeError("No update parameters provided") updated_fields = list(update_kwargs.keys()) client.tracker_settings.update_app_settings(app_id, **update_kwargs) return UpdateStatusResponse( status="success", message=f"App {app_id} tracker settings updated successfully", updated_fields=updated_fields, ) except NotFoundError: raise RuntimeError(f"App with ID {app_id} not found") except BadRequestError as e: raise RuntimeError(f"Failed to update app tracker settings: {e.message}") except Exception as e: raise RuntimeError(f"Failed to update app tracker settings: {str(e)}") - TOOL_PARAMETER_MODELS dictionary that maps 'tracker_settings_app_update' to the AppTrackerSettings Pydantic model for input validation and schema generation.
TOOL_PARAMETER_MODELS: Dict[str, Type[BaseModel]] = { "apps_create": NewAppAttributes, "apps_update": AppEditableAttributes, "audiences_create": NewAudienceAttributes, "audiences_update": EditableAudienceAttributes, "tracker_settings_app_update": AppTrackerSettings, "tracker_settings_global_update": GlobalTrackerSettings, "tags_create": TagManagerCreateAttributes, "tags_update": TagManagerUpdateAttributes, "tags_list": TagFilters, "triggers_create": TriggerAttributes, "triggers_list": TriggerFilters, "variables_create": VariableCreateAttributes, "variables_update": VariableUpdateAttributes, "variables_list": VariableFilters, } - src/piwik_pro_mcp/tools/__init__.py:42-42 (registration)Registration call to register_tracker_settings_tools(mcp) in the central tools registration function, which includes the @mcp.tool decorator for this tool.
register_tracker_settings_tools(mcp)