Skip to main content
Glama
PiwikPRO

Piwik PRO MCP Server

Official
by PiwikPRO

templates_get_variable

Read-only

Retrieve detailed specifications and field mutability information for Piwik PRO Tag Manager variable templates to properly configure create_variable and update_variable operations.

Instructions

Get detailed information about a specific Piwik PRO Tag Manager variable template.

    This tool provides comprehensive guidance for using variable templates with both create_variable
    and update_variable operations. It includes complete field mutability information to help you
    understand which fields can be modified after creation.

    Args:
        template_name: Name of the variable template to get details for
                      Available templates include: 'data_layer', 'custom_javascript', 'constant'

    Returns:
        Dictionary containing complete variable template information including:
        - template_name and display_name
        - description and ai_usage_guide
        - mcp_usage: Separate guidance for create_variable and update_variable
        - required_attributes, optional_attributes, read_only_attributes
        - field_mutability_guide: Detailed explanation of field editability
        - complete_examples: Working examples for both create and update operations
        - troubleshooting and best practices

    Examples:
        # Get dataLayer variable template info
        template = templates_get_variable(template_name='data_layer')

        # Get custom JavaScript variable template info
        template = templates_get_variable(template_name='custom_javascript')

    Field Mutability Overview:
        ✅ Editable: name, is_active, template-specific options (can be updated anytime)
        ⚠️ Create-only: variable_type (set during creation, immutable after)
        🚫 Read-only: created_at, updated_at (auto-generated, never user-modifiable)

    Workflow:
        1. Use templates_list_variables() to see all available templates
        2. Use this tool to get specific requirements and mutability info for your chosen template
        3. Use variables_create() with the template information to create variables
        4. Use variables_update() with editable fields only to update variables
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
template_nameYes

Implementation Reference

  • MCP tool handler and registration for templates_get_variable. Decorated with @mcp.tool, defines the input schema via type hints (template_name: str -> dict), and delegates logic to helper function get_variable_template.
    @mcp.tool(annotations={"title": "Piwik PRO: Get Variable Template", "readOnlyHint": True})
    def templates_get_variable(template_name: str) -> dict:
        """Get detailed information about a specific Piwik PRO Tag Manager variable template.
    
        This tool provides comprehensive guidance for using variable templates with both create_variable
        and update_variable operations. It includes complete field mutability information to help you
        understand which fields can be modified after creation.
    
        Args:
            template_name: Name of the variable template to get details for
                          Available templates include: 'data_layer', 'custom_javascript', 'constant'
    
        Returns:
            Dictionary containing complete variable template information including:
            - template_name and display_name
            - description and ai_usage_guide
            - mcp_usage: Separate guidance for create_variable and update_variable
            - required_attributes, optional_attributes, read_only_attributes
            - field_mutability_guide: Detailed explanation of field editability
            - complete_examples: Working examples for both create and update operations
            - troubleshooting and best practices
    
        Examples:
            # Get dataLayer variable template info
            template = templates_get_variable(template_name='data_layer')
    
            # Get custom JavaScript variable template info
            template = templates_get_variable(template_name='custom_javascript')
    
        Field Mutability Overview:
            ✅ Editable: name, is_active, template-specific options (can be updated anytime)
            ⚠️ Create-only: variable_type (set during creation, immutable after)
            🚫 Read-only: created_at, updated_at (auto-generated, never user-modifiable)
    
        Workflow:
            1. Use templates_list_variables() to see all available templates
            2. Use this tool to get specific requirements and mutability info for your chosen template
            3. Use variables_create() with the template information to create variables
            4. Use variables_update() with editable fields only to update variables
        """
        return get_variable_template(template_name)
  • Core helper function that implements the logic for retrieving the variable template by loading the corresponding JSON asset file and handling errors with available templates list.
    def get_variable_template(template_name: str) -> Dict[str, Any]:
        try:
            assets_dir: Path = get_assets_base_path() / "tag_manager" / "variables"
            template_file: Path = assets_dir / f"{template_name}.json"
    
            if not template_file.exists():
                available_templates = list_template_names(assets_dir)
                available_msg = (
                    f" Available variable templates: {', '.join(available_templates)}" if available_templates else ""
                )
                raise RuntimeError(f"Variable template '{template_name}' not found.{available_msg}")
    
            return load_template_asset(template_file)
    
        except Exception as e:
            raise RuntimeError(f"Failed to get variable template information: {str(e)}")
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations provide readOnlyHint=true, indicating this is a safe read operation. The description adds valuable context beyond this: it explains that the tool provides 'comprehensive guidance' for create_variable and update_variable operations, includes 'field mutability information,' and offers 'complete examples,' 'troubleshooting,' and 'best practices.' While it doesn't mention rate limits or authentication needs, it significantly enhances understanding of what information the tool returns and how to use it.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (Args, Returns, Examples, Field Mutability Overview, Workflow) and front-loads the core purpose. However, it includes some redundant elements (e.g., repeating mutability information in both the description body and Field Mutability Overview) and could be slightly more concise while maintaining clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (providing detailed template information with mutability guidance) and the absence of an output schema, the description is remarkably complete. It thoroughly explains what the tool returns (dictionary with template_name, display_name, description, ai_usage_guide, mcp_usage, attributes, field_mutability_guide, examples, troubleshooting), provides usage examples, and integrates the tool into a broader workflow. This compensates fully for the lack of structured output documentation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage (the schema only has a generic 'Template Name' title), the description fully compensates by providing rich parameter semantics. It explains that template_name is the 'Name of the variable template to get details for' and lists specific examples ('data_layer', 'custom_javascript', 'constant'). This adds crucial meaning beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the tool's purpose: 'Get detailed information about a specific Piwik PRO Tag Manager variable template.' It specifies the verb ('Get detailed information'), resource ('variable template'), and distinguishes it from siblings like templates_list_variables (which lists templates) and variables_create/update (which create/update variables).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool versus alternatives. It includes a 'Workflow' section that outlines: 1) Use templates_list_variables() first to see available templates, 2) Use this tool to get specific requirements, 3) Use variables_create() with the template information, 4) Use variables_update() with editable fields only. This clearly defines the tool's role in the workflow and distinguishes it from related operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/PiwikPRO/mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server