Skip to main content
Glama
mckinsey
by mckinsey

load_and_analyze_data

Analyze and extract insights from data files stored locally or remotely. Supports CSV, JSON, Excel, Parquet, and more. Input absolute file paths or URLs to retrieve DataFrame information and metadata.

Instructions

Use to understand local or remote data files. Must be called with absolute paths or URLs.

Supported formats: - CSV (.csv) - JSON (.json) - HTML (.html, .htm) - Excel (.xls, .xlsx) - OpenDocument Spreadsheet (.ods) - Parquet (.parquet) Args: path_or_url: Absolute (important!) local file path or URL to a data file Returns: DataAnalysisResults object containing DataFrame information and metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
path_or_urlYes

Implementation Reference

  • The main handler function for the 'load_and_analyze_data' tool, decorated with @mcp.tool() for registration. It loads data from a path or URL, analyzes it, and returns DataAnalysisResults.
    @mcp.tool() def load_and_analyze_data( path_or_url: str = Field(description="Absolute (important!) local file path or URL to a data file"), ) -> DataAnalysisResults: """Use to understand local or remote data files. Must be called with absolute paths or URLs. Supported formats: - CSV (.csv) - JSON (.json) - HTML (.html, .htm) - Excel (.xls, .xlsx) - OpenDocument Spreadsheet (.ods) - Parquet (.parquet) Returns: DataAnalysisResults object containing DataFrame information and metadata """ # Handle files and URLs path_or_url_type = path_or_url_check(path_or_url) mime_type, _ = mimetypes.guess_type(str(path_or_url)) processed_path_or_url = path_or_url if path_or_url_type == "remote": processed_path_or_url = convert_github_url_to_raw(path_or_url) elif path_or_url_type == "local": processed_path_or_url = Path(path_or_url) else: return DataAnalysisResults(valid=False, message="Invalid path or URL", df_info=None, df_metadata=None) try: df, read_fn = load_dataframe_by_format(processed_path_or_url, mime_type) except Exception as e: return DataAnalysisResults( valid=False, message=f"""Failed to load data: {e!s}. Remember to use the ABSOLUTE path or URL! Alternatively, you can use any data analysis means available to you. Most important information are the column names and column types for passing along to the `validate_dashboard_config` or `validate_chart_code` tools.""", df_info=None, df_metadata=None, ) df_info = get_dataframe_info(df) df_metadata = DFMetaData( file_name=Path(path_or_url).stem if isinstance(processed_path_or_url, Path) else Path(path_or_url).name, file_path_or_url=str(processed_path_or_url), file_location_type=path_or_url_type, read_function_string=read_fn, ) return DataAnalysisResults(valid=True, message="Data loaded successfully", df_info=df_info, df_metadata=df_metadata)
  • Output schema for the load_and_analyze_data tool, defining the structure of DataAnalysisResults returned by the handler.
    class DataAnalysisResults: """Results of the data analysis tool.""" valid: bool message: str df_info: DFInfo | None df_metadata: DFMetaData | None

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