help
Retrieve documentation and usage information for any Stata command. Understand syntax, options, and troubleshoot errors before running your analysis.
Instructions
Retrieve documentation and usage information for a Stata command. Use when you need to understand a command's syntax, options, or troubleshoot errors before running it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cmd | Yes | ||
| replace | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- StataHelp class initializes with stata_cli, cache_dir, project_tmp_dir, and config. It creates a StataController for running Stata commands.
class StataHelp: def __init__( self, stata_cli: str, project_tmp_dir: Path | None = None, cache_dir: Path | None = None, config: "Config | None" = None, ): self._config = config self.help_cache_dir = cache_dir or ( config.HELP_CACHE_DIR if config else Path.home() / ".statamcp" / "help" ) self.help_cache_dir.mkdir(parents=True, exist_ok=True) - StataHelp.help() method implements the core logic: checks saved/cached results first, then runs `help {cmd}` in Stata via StataController, and caches/saves the result.
def help(self, cmd: str, replace: bool = False) -> str: if not replace: saved_help_result = self.load_from_project(cmd) cached_help_result = self.load_from_cache(cmd) if saved_help_result and self.IS_SAVE: return f"Saved result for {cmd}\n" + saved_help_result if cached_help_result and self.IS_CACHE: return f"Cached result for {cmd}\n" + cached_help_result # If no cached help found, get from Stata try: help_result = self.load_from_stata(cmd) except Exception as e: return str(e) self._cache_and_save(cmd, content=help_result, force=replace) return help_result