get_data_info
Get descriptive statistics and a data preview for Stata, CSV, or Excel files. Understand variable details and optionally view head rows to explore a dataset without prior knowledge.
Instructions
Get descriptive statistics and a data preview for a data file (dta, csv, xlsx). Returns overview, variable details, and optional head rows filtered by requested variables. Use when you need to understand a dataset or have no prior knowledge of the data.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data_path | Yes | ||
| vars_list | No | ||
| encoding | No | utf-8 | |
| head | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/stata_mcp/api/get_data_info.py:18-42 (handler)Primary handler function for the get_data_info tool. Accepts data_path, optional vars_list, encoding, and config_file. Resolves the path, determines file extension, fetches the appropriate data handler class, instantiates it, and returns JSON-serialized dataset info.
def get_data_info( data_path: str, vars_list: List[str] | None = None, encoding: str = "utf-8", config_file: str | Path | None = None, ) -> str: """Return descriptive statistics for a supported dataset.""" runtime = create_runtime_context(config_file=config_file) resolved_data_path = Path(data_path).expanduser().resolve() data_extension = resolved_data_path.suffix.lower().strip(".") data_info_cls = get_data_handler(data_extension) if not data_info_cls: return f"Unsupported file extension now: {data_extension}" data_info = data_info_cls( resolved_data_path, vars_list, encoding=encoding, cache_dir=runtime.tmp_base_path, ) try: return json.dumps(data_info.info, ensure_ascii=False) except Exception as error: return f"Failed to generate data summary for {resolved_data_path}: {error}" - src/stata_mcp/api/__init__.py:12-27 (schema)Re-export of get_data_info from the api package, making it available via from ..api import get_data_info.
from .get_data_info import get_data_info from .read_log import read_log from .stata_do import stata_do from .stata_help import stata_help from .write_dofile import write_dofile __all__ = [ "RuntimeContext", "create_runtime_context", "ado_package_install", "get_data_info", "read_log", "stata_do", "stata_help", "write_dofile", ]