home / mcp / mcptools mcp server
Provides MCP access for R sessions, enabling models to run and query active R sessions and package context.
Configuration
View docs{
"mcpServers": {
"posit-dev-mcptools": {
"command": "Rscript",
"args": [
"-e",
"mcptools::mcp_server()"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}You can run MCP-enabled tools against your active R sessions by configuring MCP schemas that let models access your R environment. This server enables you to expose R functions to models and to register sessions so they can query and work with data in real time.
Configure MCP clients to connect to one or more MCP servers that run locally or remotely. Once connected, you can tell models to describe objects in your R session, query data, or run R functions directly in the sessions you have running. You’ll typically register a server to point to your R process and then register specific sessions you want accessible. Use these connections to enable semantic querying, data exploration, and reproducible analyses from model prompts.
Prerequisites you need before installing this MCP server are a working R environment and a client that supports MCP (for example, Claude Desktop or Claude Code). If you plan to run this on your machine, follow these steps.
# Install the MCP server package from CRAN
install.packages("mcptools")
# If you want the development version, run
pak::pak("posit-dev/mcptools")Two common ways to connect are shown below. The first starts an R-based MCP server locally in an R session. The second demonstrates a configuration that uses a Docker-based MCP server command for a GitHub MCP server.
{
"mcpServers": {
"r_mcptools": {
"type": "stdio",
"command": "Rscript",
"args": ["-e", "mcptools::mcp_server()"]
}
}
}
```
```bash
claude mcp add -s "user" r-mcptools -- Rscript -e "mcptools::mcp_server()"
```
```json
{
"mcpServers": {
"github": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}Launchs an MCP server inside an R session to accept MCP requests from clients.
Registers a specific R session for MCP access so models can interact with its objects and context.
Alternative entry point to start an MCP server using the btw package ecosystem.
Register an MCP session via the btw toolkit to enable session-level context sharing.