get_sample_data_info
Retrieve sample data info for datasets like iris, tips, stocks, and gapminder to support visualization tasks such as scatter plots, histograms, and line charts.
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
Args:
data_name: Name of the dataset to get sample data for
Returns:
Data info object containing information about the dataset.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data_name | Yes |
Implementation Reference
- Handler function implementing the logic of the 'get_sample_data_info' MCP tool. Registered via @mcp.tool() decorator. Selects and returns predefined metadata for sample datasets based on input.@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
- Dataclass defining the output schema DFMetaData used by the get_sample_data_info tool.@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
- Predefined DFMetaData instances (IRIS, TIPS, STOCKS, GAPMINDER) returned by the tool handler depending on the data_name input.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", },