Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

r-package-mcp

A skill that turns an R package into a small, self-contained MCP knowledge server — an MCP an AI assistant can query for the package's functions, arguments, datasets, dependencies, and examples, so it can look the API up instead of guessing.

It reads documentation from the package's own .Rd files (via R's tools::Rd_db) into a knowledge.json, then serves it through a generic FastMCP server. The server needs no R at runtime; pair it with an R runtime if you also want to run code.

Requirements

  • R with Rscript on PATH (for extraction)
  • uv — runs the generated server and the tests; it provisions Python and the mcp package itself, so nothing else to install

Quickstart

# 1. extract the package's docs into knowledge.json
Rscript scripts/extract_rpkg.R <package> <package>_knowledge.json --install

# 2. assemble the server
python scripts/build_server.py <package>_knowledge.json <package>-mcp

# 3. test it — protocol (tools respond) and content (examples run)
uv run scripts/test_server.py <package>-mcp
Rscript scripts/check_examples.R <package>

The build step also writes a paste-ready registration snippet (mcp.config.json). See SKILL.md for the full workflow and options (e.g. --update to match the current CRAN version instead of a stale local install).

Tools the generated server exposes

package_overview, search_functions, get_function, list_functions, get_examples, get_related, get_recipes, list_datasets, get_dataset, get_dependencies.

Using it as a skill

This is an agent skill: point a coding agent at SKILL.md (or drop this directory into your agent's skills folder) and ask it to build an MCP for an R package. The scripts can also be run directly, as shown above.

Layout

  • SKILL.md — the workflow an agent follows
  • scripts/ — extractor, builder, server template, and test/validate scripts
  • references/ — the knowledge.json schema, extraction notes, and server/registration notes

License

MIT.

About

Turn an R package into an MCP knowledge server — searchable functions, arguments, datasets, and examples for AI assistants.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages