r-packagedev-mcp

v1.0.1
io.github.B0ydT/r-packagedev-mcp Checked 2 days ago Published 8 months ago

MCP 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.

ParameterTypeDescription
path *stringAbsolute path where the new package directory should be created (e.g. '/home/user/mypackage').
fieldsobjectNamed list of extra DESCRIPTION fields, e.g. {Author: 'Jane Doe', Version: '0.1.0'}.
openbooleanWhether 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.

ParameterTypeDescription
name *stringName of the R script (without .R extension).
project_path *stringAbsolute 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.

ParameterTypeDescription
name *stringName of the function or module to create a test file for.
project_path *stringAbsolute path to the root of the R package.

use_readme_md

Add a README.md to the package root using usethis::use_readme_md().

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.

use_vignette

Create a new vignette stub (Rmd file) under vignettes/ using usethis::use_vignette().

ParameterTypeDescription
name *stringShort name/identifier for the vignette.
project_path *stringAbsolute path to the root of the R package.
titlestringHuman-readable title of the vignette.

use_mit_license

Add an MIT LICENSE file and update DESCRIPTION License field using usethis::use_mit_license().

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
copyright_holderstringName 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().

ParameterTypeDescription
project_path *stringAbsolute 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.

ParameterTypeDescription
package *stringName of the R package to add as a dependency.
project_path *stringAbsolute path to the root of the R package.
typestringDependency 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.

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
editionintegertestthat 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().

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
messagestringMessage 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().

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
organisationstringGitHub organisation to create the repo under (optional, defaults to personal account).
privatebooleanCreate 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.

ParameterTypeDescription
object_names *arrayCharacter vector of R object names already loaded in the workspace to export as package data.
project_path *stringAbsolute path to the root of the R package.
overwritebooleanOverwrite 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.

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
exportbooleanWhether 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.

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
recompilebooleanWhether to recompile C/C++/Fortran code (default false).
resetbooleanWhether 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.

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
rocletsarrayCharacter 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.

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
filterstringRegex pattern to restrict which test files are run (e.g. 'my_func').
reporterstringtestthat 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.

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
cranbooleanWhether to use CRAN-specific settings (default false).
documentbooleanWhether to run devtools::document() before checking (default true).
error_onstringMinimum 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().

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
dependenciesbooleanWhether to install package dependencies (default TRUE for Imports/Depends/Suggests).
upgradestringWhether to upgrade dependencies (default 'default').

build

Build a source (or binary) package tarball using devtools::build().

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
binarybooleanWhether to build a binary package instead of source (default false).
pathstringDestination directory for the built tarball/zip (defaults to the parent of the package directory).
vignettesbooleanWhether to build vignettes (default true).

build_readme

Render README.Rmd to README.md and update GitHub preview using devtools::build_readme().

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.

spell_check

Spell-check the package documentation and vignettes using devtools::spell_check().

ParameterTypeDescription
project_path *stringAbsolute path to the root of the R package.
vignettesbooleanWhether 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.

ParameterTypeDescription
project_path *stringAbsolute path to the project root where renv should be initialised.
barebooleanIf TRUE, initialise without installing any packages into the new library (default false).
restartbooleanWhether to restart the R session after initialising (default false).

renv_snapshot

Record the current package dependencies into renv.lock using renv::snapshot().

ParameterTypeDescription
project_path *stringAbsolute path to the renv-managed project root.
typestringSnapshot 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().

ParameterTypeDescription
project_path *stringAbsolute path to the renv-managed project root.
rebuildbooleanWhether to rebuild packages from source (default false).

renv_status

Report whether the project library is synchronised with renv.lock using renv::status().

ParameterTypeDescription
project_path *stringAbsolute 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.

ParameterTypeDescription
packages *arrayPackage names (and optional version specifiers) to install, e.g. ['ggplot2', 'dplyr@1.0.0'].
project_path *stringAbsolute path to the renv-managed project root.
rebuildbooleanWhether 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.

ParameterTypeDescription
project_path *stringAbsolute path to the renv-managed project root.
packagesarrayPackage names to update. If omitted, all packages are updated.

renv_clean

Remove unused packages or temporary files from the renv library using renv::clean().

ParameterTypeDescription
project_path *stringAbsolute path to the renv-managed project root.
actionsarraySpecific 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.

ParameterTypeDescription
file *stringAbsolute path to the test file to run (e.g. '/path/to/tests/testthat/test-utils.R').
project_pathstringOptional absolute path to the package root (used to set the working directory).
reporterstringtestthat reporter to use (e.g. 'progress', 'summary', 'tap'). Defaults to 'progress'.
stop_on_failurebooleanWhether 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.

ParameterTypeDescription
path *stringAbsolute path to the directory containing test files.
filterstringRegex pattern to restrict which test files are run (e.g. 'my_func').
reporterstringtestthat reporter to use (e.g. 'progress', 'summary', 'tap'). Defaults to 'progress'.
stop_on_failurebooleanWhether to stop immediately on the first test failure (default false).