r-coding-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@r-coding-mcprun R CMD check on my package and summarize the results"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
R Best Practices MCP Server
An MCP (Model Context Protocol) server that enforces best practices across all standard R development workflows. Provides workflow detection, project validation, and template generation for R scripts, Quarto documents, Shiny applications, R packages, and more.
Overview
The R Best Practices MCP Server helps developers write better R code by:
Detecting the R workflow type from a directory structure
Validating projects against best practices with detailed findings
Generating scaffold templates for new projects
Providing knowledge base access to 52+ best practices and recommendations
Supported Workflows
Workflow | Description |
r-script | Standalone R scripts for data processing and analysis |
quarto | Quarto documents for reproducible analysis and reporting |
shiny | Interactive web applications using Shiny |
package | R packages for code organization and distribution |
rmarkdown | R Markdown documents for dynamic reports |
renv | Projects using renv for dependency management |
targets | Pipeline projects using the targets framework |
plumber | REST APIs built with Plumber |
analysis | Data analysis projects with standard directory structure |
bookdown | Books and theses created with bookdown |
blogdown | Blogs and websites created with blogdown and Hugo |
shinytest | Shiny apps with automated testing using shinytest |
Related MCP server: mcp-github-pm
Features
š Workflow Detection
Automatically detects the R project type with confidence scoring:
Analyzes file patterns and directory structure
Identifies workflow-specific files (DESCRIPTION, app.R, _targets.R, etc.)
Returns confidence percentage (0-100%)
Includes indicators of detected workflow
ā Project Validation
Comprehensive validation against best practices:
Severity levels: critical, important, recommended, info
Categories: structure, naming, documentation, performance, security, testing
Actionable suggestions for every finding
File-level and project-level validation
šÆ Template Generation
Generate complete project scaffolds:
Realistic file structures for each workflow
Sample code demonstrating best practices
Configuration files (DESCRIPTION, .Rprofile, renv.lock, etc.)
Markdown documentation and setup instructions
Customizable project name and author info
š Knowledge Base
Access to 52 best practices:
Organized by workflow type (9 workflows)
Categorized by topic (documentation, testing, security, etc.)
Searchable and filterable
Includes examples and references
Installation
Prerequisites
Node.js >= 18.0.0
npm >= 9.0.0
From npm Registry (Recommended)
# Install the published package
npm install r-best-practices-mcp
# Or install globally for CLI usage
npm install -g r-best-practices-mcpFrom Source
# Clone the repository
git clone https://github.com/alexseymer/r-coding-mcp.git
cd r-coding-mcp
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run tests
npm testDocker Deployment
Run the server in a containerized environment with automatic dependency management:
Using Docker Hub (Recommended)
# Pull the latest image from Docker Hub
docker pull alexseymer/r-best-practices-mcp:latest
# Or use a specific version
docker pull alexseymer/r-best-practices-mcp:1.0.0
# Run the container
docker run -d \
--name r-practices \
-p 3000:3000 \
alexseymer/r-best-practices-mcp:latest
# Verify it's running
curl http://localhost:3000/healthUsing GitHub Packages
# Pull from GitHub Container Registry
docker pull ghcr.io/alexseymer/r-best-practices-mcp:latest
# Run the container
docker run -d \
--name r-practices \
-p 3000:3000 \
ghcr.io/alexseymer/r-best-practices-mcp:latestUsing Docker Compose
# Clone and deploy with Docker Compose
git clone https://github.com/alexseymer/r-coding-mcp.git
cd r-coding-mcp
# Start the API server
docker-compose up -d
# Verify it's running
curl http://localhost:3000/healthFeatures:
š³ Container-based deployment for any system
š Auto-restart on failure
š Health checks configured
š Security hardened (non-root user)
š Optional Nginx reverse proxy with SSL support
š¦ Volumes for mounting R projects
For complete Docker documentation, see DOCKER.md:
Configuration options
SSL/TLS setup
Production deployment
Troubleshooting
Performance tuning
Security best practices
Usage
Via MCP Server (Claude & other clients)
The server exposes 6 tools via the Model Context Protocol:
1. detect_workflow ā Identify project type
// Input
{ "path": "/path/to/project" }
// Output
{
"workflow": "package",
"confidence": 95,
"indicators": ["DESCRIPTION", "R/", "tests/testthat/"]
}2. validate_project ā Check best practices
// Input
{ "path": "/path/to/project", "workflow": "package" }
// Output
{
"workflow": "package",
"findings": [
{
"id": "pkg-tests",
"severity": "important",
"category": "testing",
"message": "Add tests/ directory with testthat tests"
}
],
"duration": 45
}3. validate_file ā Check single file
// Input
{ "path": "/path/to/file.R" }
// Output
{
"path": "/path/to/file.R",
"findings": [...]
}4. generate_template ā Create scaffolds
// Input
{
"workflow": "shiny",
"projectName": "my-dashboard",
"authorName": "John Doe"
}
// Output
{
"workflow": "shiny",
"files": [
{ "path": "app.R", "content": "..." },
{ "path": "README.md", "content": "..." }
],
"directories": [...]
}5. get_practice ā Details about a practice
// Input
{ "id": "pkg-roxygen" }
// Output
{
"id": "pkg-roxygen",
"title": "Use roxygen2 for documentation",
"workflow": "package",
"category": "documentation",
"description": "...",
"examples": [...]
}6. list_practices ā Browse best practices
// Input
{ "workflow": "package", "category": "documentation" }
// Output
{
"practices": [...],
"total": 52
}Via REST API (HTTP)
When running with Docker or the web server, access the same functionality via HTTP:
# Check server health
curl http://localhost:3000/health
# Detect workflow
curl -X POST http://localhost:3000/api/detect-workflow \
-H "Content-Type: application/json" \
-d '{"path": "/path/to/project"}'
# Validate project
curl -X POST http://localhost:3000/api/validate-project \
-H "Content-Type: application/json" \
-d '{"path": "/path/to/project", "workflow": "package"}'
# Validate file
curl -X POST http://localhost:3000/api/validate-file \
-H "Content-Type: application/json" \
-d '{"path": "/path/to/file.R"}'
# Get practice details
curl http://localhost:3000/api/practice/package-roxygen2
# List practices
curl "http://localhost:3000/api/practices?workflow=package&category=documentation"
# Generate template
curl -X POST http://localhost:3000/api/generate-template \
-H "Content-Type: application/json" \
-d '{"workflow": "package", "projectName": "mypackage"}'
# View all available endpoints
curl http://localhost:3000/api/toolsDocker Hub: Pull pre-built images from Docker Hub
See DOCKER.md for complete API documentation, including:
Request/response schemas
Query parameters
Error handling
Configuration options
Project Structure
r-best-practice-mcp/
āāā src/
ā āāā engine/
ā ā āāā detector.ts # Workflow detection (208 lines)
ā ā āāā validator.ts # Project validation (503 lines)
ā ā āāā template-generator.ts # Template generation (833 lines)
ā āāā data/
ā ā āāā knowledge-base.ts # 52 best practices (592 lines)
ā āāā analysis/ # Phase 6: Advanced features
ā ā āāā complexity.ts # Complexity analysis
ā ā āāā dependencies.ts # Dependency tracking
ā ā āāā performance.ts # Performance profiling
ā ā āāā auto-fixes.ts # Automated fixes
ā ā āāā index.ts # Exports
ā āāā cli/ # Phase 4: CLI interface
ā ā āāā index.ts # Command setup
ā ā āāā commands/
ā ā āāā detect.ts # Detect workflow
ā ā āāā validate.ts # Validate project
ā ā āāā template.ts # Generate template
ā ā āāā report.ts # Generate report
ā āāā config/
ā ā āāā rules-engine.ts # Custom validation rules
ā āāā types/
ā ā āāā workflow.ts, finding.ts, practice.ts, etc.
ā āāā utils/
ā ā āāā file.ts, logger.ts
ā āāā server.ts # MCP server (358 lines)
ā āāā index.ts
āāā vscode-extension/ # Phase 5: VS Code integration
ā āāā package.json
ā āāā src/
ā ā āāā extension.ts # Main extension
ā ā āāā client.ts # MCP communication
ā ā āāā diagnostics.ts # VS Code diagnostics
ā ā āāā commands.ts # Command handlers
āāā rstudio-addin/ # Phase 7: RStudio integration
ā āāā DESCRIPTION, NAMESPACE
ā āāā R/
ā ā āāā addins.R # 4 addin functions (337 lines)
ā ā āāā utils.R # MCP utilities (300+ lines)
ā āāā inst/rstudio/
ā ā āāā addins.dcf # RStudio registration
ā āāā tests/
āāā tests/
ā āāā unit/ # Unit tests (5 suites, 91 tests)
ā āāā fixtures/
āāā dist/, jest.config.js, tsconfig.json, package.json
āāā README.md, CLAUDE.md, CONTRIBUTING.mdCI/CD Pipeline
This project uses GitHub Actions for automated testing, building, and releasing:
Build Workflow ā Runs on every push and PR
ESLint linting
TypeScript building
Jest unit tests with coverage
Type checking
Matrix testing on Node 18.x and 20.x
Publish Workflow ā Triggered by version tags (v*..)
Runs full test suite
Publishes to npm registry
Builds and pushes Docker images to:
Docker Hub (
alexseymer/r-best-practices-mcp)GitHub Packages (
ghcr.io/alexseymer/r-best-practices-mcp)
Creates GitHub Release with installation instructions
Uses semantic versioning for tags
Publishing is fully automated via GitHub Actions:
Push a version tag:
git tag v1.0.0 && git push origin v1.0.0The workflow automatically publishes to npm and Docker registries
GitHub Release is created with release notes
For detailed publishing instructions, see PUBLISH.md and docs/versioning.md.
Development
Scripts
# Build TypeScript
npm run build
# Run all tests with coverage
npm test
# Watch mode for development
npm run test:watch
# Run specific test suite
npm test -- detector.test.ts
# Linting
npm run lint
# Code formatting
npm run formatTesting
Comprehensive test coverage (91 tests):
ā Workflow detection for all 9 types
ā Project validation across workflows
ā Template generation and content
ā Knowledge base functionality
ā File system utilities
Best Practices Coverage
The knowledge base includes 52+ best practices:
R Scripts (7) ā Headers, functions, naming, organization
Quarto (7) ā Chunks, YAML, caching, figures, tables
Shiny (7) ā Reactivity, validation, modules, feedback
Packages (9) ā roxygen2, testing, DESCRIPTION, coverage
R Markdown (4) ā YAML, chunks, options, inline code
renv (4) ā Init, lock, snapshot, restore
targets (4) ā Structure, naming, dependencies, branching
Plumber (6) ā Endpoints, validation, responses, errors
Analysis (3) ā Directory structure, docs, versioning
Examples
Validate an R Package
# Using the MCP server
mcp_tool_call "validate_project" '{"path": "/path/to/mypackage"}'
# Response includes:
# - Missing DESCRIPTION file (critical)
# - No tests/ directory (important)
# - Missing LICENSE (critical)
# - No README.md (recommended)Generate a Shiny Template
# Using the MCP server
mcp_tool_call "generate_template" '{
"workflow": "shiny",
"projectName": "my-app",
"authorName": "Jane Doe"
}'
# Returns scaffold with:
# - app.R with UI/server structure
# - README.md with setup instructions
# - .gitignore configuredDetect Project Type
# Using the MCP server
mcp_tool_call "detect_workflow" '{"path": "/path/to/project"}'
# Automatically identifies:
# - Workflow type with confidence
# - Detected indicators
# - TimestampPerformance
Detection: ~50-100ms per project
Validation: ~100-500ms depending on project size
Template Generation: <10ms
Knowledge base queries: <5ms
Dependencies
Runtime
@modelcontextprotocol/sdkā MCP protocol
Development
typescriptā Type safetyjestā Testing frameworkts-jestā TypeScript support@types/jestā Jest types@types/nodeā Node.js types
Contributing
Fork the repository
Create a feature branch
Make your changes
Run tests:
npm testSubmit a pull request
Interfaces Available
š REST API (HTTP)
Deploy as a web service with Docker for easy integration:
Express.js HTTP server on port 3000
All 6 tools available via REST endpoints
Health checks and API introspection
Optional Nginx reverse proxy with SSL/TLS
Perfect for self-hosted VPS deployment
Start with
docker-compose upornode dist/web-server-entry.js
š„ļø MCP Server
The core MCP server exposing 6 tools for Claude and other MCP clients. Start with node dist/index.js.
š» CLI Tool (Phase 4)
Local command-line tool for developers:
detectā Identify project workflow typevalidateā Check projects against best practicestemplateā Generate project scaffoldsreportā Create HTML validation reports--watchmode for continuous monitoring
š VS Code Extension (Phase 5)
Real-time validation within VS Code:
Inline diagnostics with severity coloring
Quick fix suggestions
Workflow detection
HTML report generation in WebView
Keyboard shortcut: Shift+Alt+V
šØ RStudio Addin (Phase 7)
In-IDE validation for RStudio:
Validate Project gadget with findings table
Detect Workflow dialog
Generate Template interactive UI
Show Report with statistics
Access via RStudio Addins menu
Advanced Features (Phase 6)
Complexity Analysis ā Cyclomatic complexity, nesting depth, LOC metrics
Dependency Tracking ā renv.lock, DESCRIPTION, library() analysis
Performance Profiling ā Operation timing and optimization suggestions
Automated Fixes ā roxygen2, imports, formatting, style fixes
Custom Rules ā Pattern-based validation rules
Roadmap (Future Phases)
Publish VS Code extension to marketplace
Publish CLI tool to npm registry
Publish RStudio addin to CRAN
Web dashboard
Additional workflows (bookdown, blogdown)
Community rule library
License
MIT License
Support
Issues: GitHub Issues
Questions: GitHub Discussions
Publishing: PUBLISH.md
Versioning: docs/versioning.md
This server cannot be deployed
Maintenance
Related MCP Connectors
Live SEO workflow tools for Claude Code, Codex, and AI agents.
Claude Code / MCP skills for the dev pipeline: discover, spec, design, build, ship, operate.
Source-checked CLI guides and model-aware planning for Claude Code, Codex, and Grok Build.
Package intelligence for AI agents across npm, PyPI, crates.io and deps.dev. No API keys.
Related MCP Servers
- AlicenseCqualityCmaintenanceEnables AI-powered automated testing, security scanning, code review, and maintenance tasks directly within Claude Code or desktop.124MIT
- AlicenseBqualityDmaintenanceEnables GitHub project management from Claude, supporting issue creation, milestones, labels, changelog generation, and repository stats.85 npm1MIT
- FlicenseAqualityDmaintenanceEnables Claude to access and manage GitHub repositories dynamically at runtime, including private repos, with tools for browsing files, searching code, and viewing commits, pull requests, and issues.111-
- AlicenseNot gradedqualityDmaintenanceEnables Claude to analyze GitHub repositories with tools for health scoring, contributor analysis, issue tracking, code search, and more.MIT