Skip to contents

One-stop setup: gets the natverse index and registers the natmcp server with the Claude desktop app (chat) and Claude Code (terminal, IDEs and the desktop app's Code tab). Run it once, then fully quit and reopen Claude.

Usage

natmcp_setup(
  clients = c("desktop", "code"),
  index = c("fetch", "build", "skip"),
  rprofile = FALSE,
  ask = interactive(),
  overwrite = FALSE,
  rscript = .rscript_path()
)

Arguments

clients

Which Claude apps to configure: "desktop" (desktop app chat) and/or "code" (Claude Code, including the desktop app's Code tab).

index

How to get the index: "fetch", "build" or "skip".

rprofile

If TRUE, register every interactive R session with Claude via your .Rprofile.

ask

If TRUE, ask before each step.

overwrite

If TRUE, replace an existing, different natmcp entry without asking.

rscript

Full path to the Rscript Claude should launch.

Value

Invisibly, a named list recording what was done for each step.

Details

Interactively (ask = TRUE) you are asked about each step, with the arguments as the default answers. With ask = FALSE the arguments are applied as given.

Index. "fetch" downloads the published index with fetch_index(); "build" runs build_index() on your installed natverse packages, writing to the same user cache so the server finds it without extra configuration (a later fetch_index() replaces it with the published one). "skip" does neither; the server then fetches on first use.

Claude configuration. The server entry runs Rscript -e "natmcp::natmcp_mcp_server()" using the full path to Rscript (apps started outside a shell don't see your PATH). It is added under mcpServers in claude_desktop_config.json ("desktop", macOS and Windows only) and ~/.claude.json ("code", user scope). The rest of each file is kept intact and a timestamped backup is written alongside it before any change. An existing entry that already matches is left alone; one that differs is only replaced after confirmation (or with overwrite = TRUE). Claude Code rewrites ~/.claude.json while running, so quit it before running this if you can, and restart it afterwards.

R profile. With rprofile = TRUE, a line calling natmcp_session()(quiet = TRUE) is appended to your user .Rprofile so every interactive session is available to Claude (look-ups only; Claude can run code only after natmcp_session(run_r = TRUE)). A project-level .Rprofile takes precedence over the user one.

Examples

if (FALSE) { # \dontrun{
natmcp_setup()
# non-interactive: Claude Code only, keep any existing index
natmcp_setup(clients = "code", index = "skip", ask = FALSE)
} # }