get_sample_data_info
Retrieve sample dataset information for data visualization tasks. Provides details on iris, tips, stocks, and gapminder datasets to help select appropriate data for charts and graphs.
Instructions
If user provides no data, use this tool to get sample data information.
Use the following data for the below purposes:
- iris: mostly numerical with one categorical column, good for scatter, histogram, boxplot, etc.
- tips: contains mix of numerical and categorical columns, good for bar, pie, etc.
- stocks: stock prices, good for line, scatter, generally things that change over time
- gapminder: demographic data, good for line, scatter, generally things with maps or many categories
Returns:
Data info object containing information about the dataset.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data_name | Yes | Name of the dataset to get sample data for |
Implementation Reference
- The primary handler function for the 'get_sample_data_info' MCP tool, which is also where it is registered using the @mcp.tool() decorator. It dispatches predefined sample dataset metadata based on the input data_name.@mcp.tool() def get_sample_data_info( data_name: Literal["iris", "tips", "stocks", "gapminder"] = Field( description="Name of the dataset to get sample data for" ), ) -> DFMetaData: """If user provides no data, use this tool to get sample data information. Use the following data for the below purposes: - iris: mostly numerical with one categorical column, good for scatter, histogram, boxplot, etc. - tips: contains mix of numerical and categorical columns, good for bar, pie, etc. - stocks: stock prices, good for line, scatter, generally things that change over time - gapminder: demographic data, good for line, scatter, generally things with maps or many categories Returns: Data info object containing information about the dataset. """ if data_name == "iris": return IRIS elif data_name == "tips": return TIPS elif data_name == "stocks": return STOCKS elif data_name == "gapminder": return GAPMINDER
- Pydantic-style dataclass defining the DFMetaData type, which serves as the schema for the tool's return value.@dataclass class DFMetaData: file_name: str file_path_or_url: str file_location_type: Literal["local", "remote"] read_function_string: Literal["pd.read_csv", "pd.read_json", "pd.read_html", "pd.read_parquet", "pd.read_excel"] column_names_types: dict[str, str] | None = None
- Supporting dataclass instances providing metadata for the four sample datasets returned by the tool.IRIS = DFMetaData( file_name="iris_data", file_path_or_url="https://raw.githubusercontent.com/plotly/datasets/master/iris-id.csv", file_location_type="remote", read_function_string="pd.read_csv", column_names_types={ "sepal_length": "float", "sepal_width": "float", "petal_length": "float", "petal_width": "float", "species": "str", }, ) TIPS = DFMetaData( file_name="tips_data", file_path_or_url="https://raw.githubusercontent.com/plotly/datasets/master/tips.csv", file_location_type="remote", read_function_string="pd.read_csv", column_names_types={ "total_bill": "float", "tip": "float", "sex": "str", "smoker": "str", "day": "str", "time": "str", "size": "int", }, ) STOCKS = DFMetaData( file_name="stocks_data", file_path_or_url="https://raw.githubusercontent.com/plotly/datasets/master/stockdata.csv", file_location_type="remote", read_function_string="pd.read_csv", column_names_types={ "Date": "str", "IBM": "float", "MSFT": "float", "SBUX": "float", "AAPL": "float", "GSPC": "float", }, ) GAPMINDER = DFMetaData( file_name="gapminder_data", file_path_or_url="https://raw.githubusercontent.com/plotly/datasets/master/gapminder_unfiltered.csv", file_location_type="remote", read_function_string="pd.read_csv", column_names_types={ "country": "str", "continent": "str", "year": "int", "lifeExp": "float", "pop": "int", "gdpPercap": "float", }, )