tealflow_setup_renv_environment
Prepare R project for Teal Shiny apps by initializing renv and installing required packages. Restores locked versions if lockfile exists, otherwise installs all.
Instructions
Prepare an R project directory so it is ready to run Teal Shiny applications.
This tool initializes an renv environment and installs required packages (shiny, teal, teal.modules.general, teal.modules.clinical).
Behavior:
If
renv.lockexists: Restores packages at locked versions, then installs only packages missing from the lockfile. User's pinned versions are respected.If no
renv.lock: Initializes a new renv environment and installs all packages.
Steps performed:
Validates project path and R installation
Installs renv package if missing
Initializes renv (or restores existing lockfile)
Installs required packages (only missing ones if lockfile exists)
Args: project_path (str, optional): ABSOLUTE path to the R project directory. MUST be an absolute path (e.g., "/home/user/project" or "C:\Users\user\project"). Relative paths like "." will resolve to the MCP server's directory, not the user's project. Defaults to "." but should always be explicitly provided as an absolute path. response_format (str, optional): Output format - 'json' or 'markdown'. Defaults to 'json'.
Returns: str: JSON/markdown with status, steps_completed, message, and logs_excerpt.
Error Types: - filesystem_error: Project path does not exist - rscript_not_found: R is not installed or not in PATH - renv_install_failed: Failed to install or initialize renv - package_install_failed: Failed to install required packages
Examples: - Setup current directory: (no parameters needed) - Setup specific project: project_path="/path/to/project"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | No | . | |
| response_format | No | json |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |