ado_package_install
Install Stata ado packages from SSC, GitHub, or net sources to access third-party commands.
Instructions
Install a Stata ado package from SSC, GitHub, or net sources. Use before running commands that require third-party packages.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package | Yes | ||
| source | No | ssc | |
| is_replace | No | ||
| package_source_from | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/stata_mcp/api/ado_install.py:24-65 (handler)Primary handler: Installs ado packages from SSC, net, or GitHub. On Unix uses installer classes (SSC_Install, NET_Install, GITHUB_Install); on Windows writes a dofile and executes via stata_do. Supports replace, timeout, and config_file parameters.
def ado_package_install( package: str, source: str = "ssc", is_replace: bool = True, package_source_from: str = None, config_file: str | Path | None = None, timeout: int = 300, ) -> str: """Install an ado package from SSC, net, or GitHub.""" runtime = create_runtime_context(config_file=config_file, require_stata=True) source = source.lower() if runtime.is_unix: installer_cls = SOURCE_MAPPING.get(source, SSC_Install) install_args = [package, package_source_from] if source == "net" else [package] install_message = installer_cls(runtime.stata_cli, is_replace, timeout=timeout).install(*install_args) if not installer_cls.check_installed_from_msg(install_message): error_summary = installer_cls.extract_error_summary(install_message) install_message += ( f"\nError: Failed to install package '{package}' from source '{source}'. " f"Details: {error_summary}" ) if source == "github": install_message += ( "\nPlease check the GitHub repository URL, verify case sensitivity, " "and ensure the github command is installed in Stata." ) else: try: from ..mcp_servers import _load_help_cls _load_help_cls().help(package, replace=True) except Exception: pass return install_message from_message = f"from({package_source_from})" if (package_source_from and source == "net") else "" replace_flag = "replace" if is_replace else "" command = f"{source} install {package}, {replace_flag} {from_message}".strip() dofile_path = write_dofile(command, config_file=config_file) return str(stata_do(dofile_path, read_log_when_error=False, config_file=config_file).get("log_content", {}))