Skip to main content
Glama
mckinsey
by mckinsey

get_model_json_schema

Retrieve the JSON schema for a specified Vizro model to understand its structure and requirements. Input the model name (e.g., 'Card', 'Dashboard') to receive the corresponding schema.

Instructions

Get the JSON schema for the specified Vizro model.

Args: model_name: Name of the Vizro model to get schema for (e.g., 'Card', 'Dashboard', 'Page') Returns: JSON schema of the requested Vizro model

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
model_nameYes

Implementation Reference

  • The handler function for the get_model_json_schema tool. It is decorated with @mcp.tool() for registration and implements the logic to fetch and return the JSON schema for Vizro models, handling special cases like modified, deprecated, and layout models.
    @mcp.tool(description=f"Get the JSON schema for the specified Vizro model. Server Vizro version: {vizro.__version__}") def get_model_json_schema( model_name: str = Field( description="Name of the Vizro model to get schema for (e.g., 'Card', 'Dashboard', 'Page')" ), ) -> ModelJsonSchemaResults: """Get the JSON schema for the specified Vizro model. Returns: JSON schema of the requested Vizro model """ if not hasattr(vm, model_name): return ModelJsonSchemaResults( model_name=model_name, json_schema={}, additional_info=f"Model '{model_name}' not found in vizro.models", ) modified_models = { "Graph": GraphEnhanced, "AgGrid": AgGridEnhanced, "Table": AgGridEnhanced, "Figure": FigureEnhanced, } if model_name in modified_models: return ModelJsonSchemaResults( model_name=model_name, json_schema=modified_models[model_name].model_json_schema(schema_generator=NoDefsGenerateJsonSchema), additional_info="""LLM must remember to replace `$ref` with the actual config. Request the schema of that model if necessary. Do NOT forget to call `validate_dashboard_config` after each iteration.""", ) deprecated_models = {"filter_interaction": "set_control", "Layout": "Grid"} if model_name in deprecated_models: return ModelJsonSchemaResults( model_name=model_name, json_schema={}, additional_info=f"Model '{model_name}' is deprecated. Use {deprecated_models[model_name]} instead.", ) model_class = getattr(vm, model_name) if model_name in {"Grid", "Flex"}: return ModelJsonSchemaResults( model_name=model_name, json_schema=model_class.model_json_schema(schema_generator=NoDefsGenerateJsonSchema), additional_info=LAYOUT_INSTRUCTIONS, ) return ModelJsonSchemaResults( model_name=model_name, json_schema=model_class.model_json_schema(schema_generator=NoDefsGenerateJsonSchema), additional_info="""LLM must remember to replace `$ref` with the actual config. Request the schema of that model if necessary. Do NOT forget to call `validate_dashboard_config` after each iteration.""", )
  • Dataclass defining the output schema/return type for the get_model_json_schema tool.
    @dataclass class ModelJsonSchemaResults: """Results of the get_model_json_schema tool.""" model_name: str json_schema: dict[str, Any] additional_info: str
  • The @mcp.tool() decorator registers the get_model_json_schema function as an MCP tool.
    @mcp.tool(description=f"Get the JSON schema for the specified Vizro model. Server Vizro version: {vizro.__version__}") def get_model_json_schema( model_name: str = Field( description="Name of the Vizro model to get schema for (e.g., 'Card', 'Dashboard', 'Page')" ), ) -> ModelJsonSchemaResults: """Get the JSON schema for the specified Vizro model. Returns: JSON schema of the requested Vizro model """ if not hasattr(vm, model_name): return ModelJsonSchemaResults( model_name=model_name, json_schema={}, additional_info=f"Model '{model_name}' not found in vizro.models", ) modified_models = { "Graph": GraphEnhanced, "AgGrid": AgGridEnhanced, "Table": AgGridEnhanced, "Figure": FigureEnhanced, } if model_name in modified_models: return ModelJsonSchemaResults( model_name=model_name, json_schema=modified_models[model_name].model_json_schema(schema_generator=NoDefsGenerateJsonSchema), additional_info="""LLM must remember to replace `$ref` with the actual config. Request the schema of that model if necessary. Do NOT forget to call `validate_dashboard_config` after each iteration.""", ) deprecated_models = {"filter_interaction": "set_control", "Layout": "Grid"} if model_name in deprecated_models: return ModelJsonSchemaResults( model_name=model_name, json_schema={}, additional_info=f"Model '{model_name}' is deprecated. Use {deprecated_models[model_name]} instead.", ) model_class = getattr(vm, model_name) if model_name in {"Grid", "Flex"}: return ModelJsonSchemaResults( model_name=model_name, json_schema=model_class.model_json_schema(schema_generator=NoDefsGenerateJsonSchema), additional_info=LAYOUT_INSTRUCTIONS, ) return ModelJsonSchemaResults( model_name=model_name, json_schema=model_class.model_json_schema(schema_generator=NoDefsGenerateJsonSchema), additional_info="""LLM must remember to replace `$ref` with the actual config. Request the schema of that model if necessary. Do NOT forget to call `validate_dashboard_config` after each iteration.""", )

Other Tools

Related 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