MCPR
Expose R functions through the Model Context Protocol (MCP) for seamless integration with AI assistants.
mcpr
mcpr exposes R functions through the Model Context Protocol (MCP), enabling seamless integration with AI assistants like Claude Desktop.
Installation
# install.packages("devtools")
devtools::install_github("chi2labs/mcpr")
Quick Start
Basic Server
library(mcpr)
# Create and configure server
server <- mcp_http("My R Analysis Server", "1.0.0", port = 8080)
# Add tools
server$mcp_tool(
name = "calculate_mean",
fn = function(numbers) mean(numbers),
description = "Calculate the mean of a numeric vector"
)
# Run server
server$mcp_run()
Using Decorators
Create a file with decorated functions:
# analysis-tools.R
#* @mcp_tool
#* @description Calculate summary statistics for a numeric vector
#* @param x numeric vector to analyze
#* @param na.rm logical whether to remove NA values (default: TRUE)
calculate_stats <- function(x, na.rm = TRUE) {
list(
mean = mean(x, na.rm = na.rm),
median = median(x, na.rm = na.rm),
sd = sd(x, na.rm = na.rm),
min = min(x, na.rm = na.rm),
max = max(x, na.rm = na.rm)
)
}
Load and run:
server <- mcp("Analysis Server", "1.0.0")
server$mcp_source("analysis-tools.R")
server$mcp_run(transport = "http", port = 8080)
Configure Claude Desktop
Add to Claude Desktop's configuration:
{
"mcpServers": {
"r-analysis": {
"url": "http://localhost:8080/mcp"
}
}
}
Advanced Usage
Register Existing Functions
server <- mcp_http("Stats Server", "1.0.0")
server$mcp_tool(
name = "t_test",
fn = t.test,
description = "Perform t-test"
)
server$mcp_tool(
name = "cor_test",
fn = cor.test,
description = "Correlation test"
)
Production Deployment
server <- mcp_http(
name = "Production Server",
version = "1.0.0",
host = "0.0.0.0", # Listen on all interfaces
port = 8080,
log_file = "mcp-server.log",
log_level = "info"
)
Docker Deployment
FROM rocker/r-ver:4.3.0
RUN install.packages(c("mcpr", "plumber", "jsonlite"))
COPY server.R /app/
WORKDIR /app
EXPOSE 8080
CMD ["Rscript", "server.R"]
Examples
Complete examples in inst/examples/:
basic-server.R- Simple server with basic toolsstats-server.R- Statistical analysis toolsdata-server.R- Data manipulation and visualization
License
MIT + file LICENSE
関連サーバー
Alpha Vantage MCP Server
スポンサーAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
Tmux MCP Server
Provides persistent shell execution through tmux sessions.
MCP For Azure DevOps Boards
An MCP server that focuses on providing useful tools for Azure DevOps Boards
APS AEC Data Model MCP (.NET)
A .NET MCP server for interacting with the Autodesk AEC Data Model API and Viewer.
Divvi MCP Server
Automatically integrate the Divvi referral SDK into JavaScript and TypeScript blockchain applications.
SensorMCP Server
Automate dataset creation and train custom object detection models using natural language.
Hoofy
Your AI development companion. An MCP server that gives your AI persistent memory, structured specifications, and adaptive change management — so it builds what you actually want.
Developer Tools MCP Server
Developer resources including GitHub, npm, PyPI, Docker Hub, GitLab, and StackOverflow
AppDeploy
AppDeploy lets you deploy a real, full-stack web app directly from an AI chat and turn your AI conversations into live apps, without leaving the chat or touching infrastructure.
Stimulsoft Documentation MCP Server
Official MCP server for Stimulsoft Reports & Dashboards documentation. Semantic search across FAQ, Programming Manual, Server/User Manual, and Server/Cloud API for .NET, WPF, Avalonia, WEB, Blazor, Angular, React, JS, PHP, Java, and Python platforms.
Bonsai MCP
An MCP server that integrates IFC model support using Bonsai BIM (Blender) and IfcOpenShell.