r-packagedev-mcp
v1.0.1MCP server for R package development using usethis, devtools, renv, and testthat
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
create_package
Create a new R package skeleton at the specified path using usethis::create_package(). Sets up DESCRIPTION, NAMESPACE, and the R/ directory.
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path where the new package directory should be created (e.g. '/home/user/mypackage'). |
fields | object | Named list of extra DESCRIPTION fields, e.g. {Author: 'Jane Doe', Version: '0.1.0'}. |
open | boolean | Whether to open the new package in RStudio (default false). |
use_r
Add a new R source file under R/ in an existing package using usethis::use_r(). Creates 'R/<name>.R' with minimal boilerplate.
| Parameter | Type | Description |
|---|---|---|
name * | string | Name of the R script (without .R extension). |
project_path * | string | Absolute path to the root of the R package. |
use_test
Create a matching test file under tests/testthat/ for a given function or module using usethis::use_test(). Automatically sets up testthat if not already configured.
| Parameter | Type | Description |
|---|---|---|
name * | string | Name of the function or module to create a test file for. |
project_path * | string | Absolute path to the root of the R package. |
use_readme_md
Add a README.md to the package root using usethis::use_readme_md().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
use_vignette
Create a new vignette stub (Rmd file) under vignettes/ using usethis::use_vignette().
| Parameter | Type | Description |
|---|---|---|
name * | string | Short name/identifier for the vignette. |
project_path * | string | Absolute path to the root of the R package. |
title | string | Human-readable title of the vignette. |
use_mit_license
Add an MIT LICENSE file and update DESCRIPTION License field using usethis::use_mit_license().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
copyright_holder | string | Name to include in the copyright notice (defaults to package author). |
use_gpl3_license
Add a GPL-3 LICENSE file and update DESCRIPTION License field using usethis::use_gpl3_license().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
use_package
Add a package dependency to DESCRIPTION using usethis::use_package(). Supports Imports, Suggests, Depends, LinkingTo, and Enhances.
| Parameter | Type | Description |
|---|---|---|
package * | string | Name of the R package to add as a dependency. |
project_path * | string | Absolute path to the root of the R package. |
type | string | Dependency type in DESCRIPTION (default 'Imports'). |
use_testthat
Configure the testthat testing infrastructure for a package using usethis::use_testthat(). Creates tests/testthat/ and adds testthat to Suggests.
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
edition | integer | testthat edition to use (e.g. 3). Defaults to latest stable edition. |
use_git
Initialise a Git repository in the package and make an initial commit using usethis::use_git().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
message | string | Message for the initial commit (default: 'Initial commit'). |
use_github
Create a GitHub remote for the package and push using usethis::use_github(). Requires a GitHub PAT configured via GITHUB_PAT or gh_token().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
organisation | string | GitHub organisation to create the repo under (optional, defaults to personal account). |
private | boolean | Create as a private repository (default false). |
use_data
Export one or more R objects as package data files under data/ using usethis::use_data(). The objects must already be loaded in the R environment.
| Parameter | Type | Description |
|---|---|---|
object_names * | array | Character vector of R object names already loaded in the workspace to export as package data. |
project_path * | string | Absolute path to the root of the R package. |
overwrite | boolean | Overwrite existing data files (default false). |
use_pipe
Add the magrittr pipe (%>%) to the package via usethis::use_pipe(). Creates utils-pipe.R and updates NAMESPACE.
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
export | boolean | Whether to export the pipe operator (default true). |
load_all
Simulate installing and attaching the package using devtools::load_all(). Makes all functions available in the current R session for interactive testing.
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
recompile | boolean | Whether to recompile C/C++/Fortran code (default false). |
reset | boolean | Whether to reset the namespace before loading (default false). |
document
Generate roxygen2 documentation and update NAMESPACE using devtools::document(). Reads @-tags from R source and creates man/*.Rd files.
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
roclets | array | Character vector of roclet names to use (e.g. ['rd', 'namespace']). Defaults to all. |
test
Run the package's test suite (or a filtered subset) using devtools::test(). Reports test results in the chosen format.
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
filter | string | Regex pattern to restrict which test files are run (e.g. 'my_func'). |
reporter | string | testthat reporter to use (e.g. 'progress', 'summary'). Defaults to 'progress'. |
check
Run R CMD check on the package using devtools::check(). Identifies errors, warnings, and notes that would prevent CRAN submission.
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
cran | boolean | Whether to use CRAN-specific settings (default false). |
document | boolean | Whether to run devtools::document() before checking (default true). |
error_on | string | Minimum check severity that causes an error: 'never', 'note', 'warning', or 'error' (default 'warning'). |
install
Install the package into the local R library using devtools::install().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
dependencies | boolean | Whether to install package dependencies (default TRUE for Imports/Depends/Suggests). |
upgrade | string | Whether to upgrade dependencies (default 'default'). |
build
Build a source (or binary) package tarball using devtools::build().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
binary | boolean | Whether to build a binary package instead of source (default false). |
path | string | Destination directory for the built tarball/zip (defaults to the parent of the package directory). |
vignettes | boolean | Whether to build vignettes (default true). |
build_readme
Render README.Rmd to README.md and update GitHub preview using devtools::build_readme().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
spell_check
Spell-check the package documentation and vignettes using devtools::spell_check().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the root of the R package. |
vignettes | boolean | Whether to spell-check vignettes (default true). |
renv_init
Initialise an renv project-local library for the project using renv::init(). Creates renv/ and renv.lock, and updates .Rprofile.
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the project root where renv should be initialised. |
bare | boolean | If TRUE, initialise without installing any packages into the new library (default false). |
restart | boolean | Whether to restart the R session after initialising (default false). |
renv_snapshot
Record the current package dependencies into renv.lock using renv::snapshot().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the renv-managed project root. |
type | string | Snapshot type: 'implicit' (DESCRIPTION), 'explicit' (renv.lock packages), 'all' (everything installed), or 'custom' (default 'implicit'). |
renv_restore
Restore packages from renv.lock to recreate the recorded environment using renv::restore().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the renv-managed project root. |
rebuild | boolean | Whether to rebuild packages from source (default false). |
renv_status
Report whether the project library is synchronised with renv.lock using renv::status().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the renv-managed project root. |
renv_install
Install packages into the renv project library using renv::install(). Supports CRAN packages, GitHub (user/repo), or version-pinned installs.
| Parameter | Type | Description |
|---|---|---|
packages * | array | Package names (and optional version specifiers) to install, e.g. ['ggplot2', 'dplyr@1.0.0']. |
project_path * | string | Absolute path to the renv-managed project root. |
rebuild | boolean | Whether to rebuild packages from source (default false). |
renv_update
Update packages in the renv project library using renv::update(). If no package names are given, all outdated packages are updated.
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the renv-managed project root. |
packages | array | Package names to update. If omitted, all packages are updated. |
renv_clean
Remove unused packages or temporary files from the renv library using renv::clean().
| Parameter | Type | Description |
|---|---|---|
project_path * | string | Absolute path to the renv-managed project root. |
actions | array | Specific cleaning actions to perform (default: all applicable actions). |
test_file
Run a single testthat test file using testthat::test_file(). Useful for rapid iteration on a specific file.
| Parameter | Type | Description |
|---|---|---|
file * | string | Absolute path to the test file to run (e.g. '/path/to/tests/testthat/test-utils.R'). |
project_path | string | Optional absolute path to the package root (used to set the working directory). |
reporter | string | testthat reporter to use (e.g. 'progress', 'summary', 'tap'). Defaults to 'progress'. |
stop_on_failure | boolean | Whether to stop immediately on the first test failure (default false). |
test_dir
Run all test files in a directory (optionally filtered) using testthat::test_dir(). Returns a summary of pass/fail/skip counts.
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path to the directory containing test files. |
filter | string | Regex pattern to restrict which test files are run (e.g. 'my_func'). |
reporter | string | testthat reporter to use (e.g. 'progress', 'summary', 'tap'). Defaults to 'progress'. |
stop_on_failure | boolean | Whether to stop immediately on the first test failure (default false). |