Skip to main content
Glama
mckinsey

vizro-mcp

Official
by mckinsey

validate_dashboard_config

Validate Vizro dashboard configurations to ensure proper structure and functionality before deployment. Checks configuration syntax, data references, and custom chart integration for error-free dashboard creation.

Instructions

Validate Vizro model configuration. Run ALWAYS when you have a complete dashboard configuration.

If successful, the tool will return the python code and, if it is a remote file, the py.cafe link to the chart.
The PyCafe link will be automatically opened in your default browser if auto_open is True.

Returns:
    ValidationResults object with status and dashboard details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dashboard_configYesEither a JSON string or a dictionary representing a Vizro dashboard model configuration
data_infosYesList of DFMetaData objects containing information about the data files
custom_chartsYesList of ChartPlan objects containing information about the custom charts in the dashboard
auto_openNoWhether to automatically open the PyCafe link in a browser

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
validYes
messageYes
pycafe_urlYes
python_codeYes
browser_openedYes

Implementation Reference

  • The core handler function for the 'validate_dashboard_config' tool. Decorated with @mcp.tool(), it validates the provided dashboard configuration using Vizro's model_validate, handles custom charts, generates Python code and optional PyCafe preview link, and opens the browser if specified.
    @mcp.tool()
    def validate_dashboard_config(
        dashboard_config: dict[str, Any] = Field(
            description="Either a JSON string or a dictionary representing a Vizro dashboard model configuration"
        ),
        data_infos: list[DFMetaData] = Field(
            description="List of DFMetaData objects containing information about the data files"
        ),
        custom_charts: list[ChartPlan] = Field(
            description="List of ChartPlan objects containing information about the custom charts in the dashboard"
        ),
        auto_open: bool = Field(default=True, description="Whether to automatically open the PyCafe link in a browser"),
    ) -> ValidateResults:
        """Validate Vizro model configuration. Run ALWAYS when you have a complete dashboard configuration.
    
        If successful, the tool will return the python code and, if it is a remote file, the py.cafe link to the chart.
        The PyCafe link will be automatically opened in your default browser if auto_open is True.
    
        Returns:
            ValidationResults object with status and dashboard details
        """
        Vizro._reset()
    
        try:
            dashboard = vm.Dashboard.model_validate(
                dashboard_config,
                context={"allow_undefined_captured_callable": [custom_chart.chart_name for custom_chart in custom_charts]},
            )
        except ValidationError as e:
            return ValidateResults(
                valid=False,
                message=f"""Validation Error: {e!s}. Fix the error and call this tool again.
    Calling `get_model_json_schema` may help.""",
                python_code="",
                pycafe_url=None,
                browser_opened=False,
            )
    
        else:
            code_link = get_python_code_and_preview_link(dashboard, data_infos, custom_charts)
    
            pycafe_url = code_link.pycafe_url if all(info.file_location_type == "remote" for info in data_infos) else None
            browser_opened = False
    
            if pycafe_url and auto_open:
                try:
                    browser_opened = webbrowser.open(pycafe_url)
                except Exception:
                    browser_opened = False
    
            return ValidateResults(
                valid=True,
                message="""Configuration is valid for Dashboard! Do not forget to call this tool again after each iteration.
    If you are creating an `app.py` file, you MUST use the code from the validation tool, do not modify it, watch out for
    differences to previous `app.py`""",
                python_code=code_link.python_code,
                pycafe_url=pycafe_url,
                browser_opened=browser_opened,
            )
    
        finally:
            Vizro._reset()
  • Pydantic-style dataclass defining the output schema for the validate_dashboard_config tool (and similar validation tools), including validation status, error/success message, generated Python code, PyCafe URL, and browser open status.
    @dataclass
    class ValidateResults:
        """Results of validation tools."""
    
        valid: bool
        message: str
        python_code: str
        pycafe_url: str | None
        browser_opened: bool
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses that successful validation returns Python code and potentially opens a PyCafe link, which adds useful behavioral context. However, it doesn't mention error handling, performance characteristics, or what happens with invalid configurations.

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 appropriately sized with three focused paragraphs. The first sentence clearly states the purpose, the second provides usage guidance, and the third explains outputs. However, the second paragraph could be more concise by combining the PyCafe link explanation.

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

Completeness4/5

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

Given the tool has an output schema (returns ValidationResults object), the description doesn't need to explain return values in detail. It covers the main purpose, usage guidance, and key behavioral aspects adequately for a validation tool with comprehensive schema documentation.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description doesn't add any meaningful parameter semantics beyond what's in the schema, maintaining the baseline score of 3 for high schema coverage.

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

Purpose4/5

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

The description clearly states the verb ('validate') and resource ('Vizro model configuration'), making the purpose explicit. However, it doesn't distinguish this tool from its sibling 'validate_chart_code', which appears to validate only chart code rather than full dashboard configurations.

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 usage guidance: 'Run ALWAYS when you have a complete dashboard configuration.' This gives clear context about when to use this tool versus alternatives like 'validate_chart_code' for partial validation.

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/mckinsey/vizro'

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