r/rstats • u/itkonen • 18h ago
I just published rairai on CRAN! It’s an MCP server built to speed up R package development.
Hi folks! If you use AI coding agents to develop R packages, you might find rairai useful. It’s an MCP server that uses Tree-sitter to give agents a structured view of an R package. For example, an agent can find where a function is defined and used, check what the package imports, or look up a help page. Think of it as a language server designed for AI agents.
I built rairai out of frustration with a few things I kept seeing in my own work. I’d watch an agent burn tokens searching for a function and fill its context with unrelated code along the way. Sometimes it would miss that a function was already imported and add namespace prefixes where they weren’t needed. Other times it would guess what an argument did or what a function returned instead of checking the docs, and miss an important side effect.
The idea behind rairai is simple: give agents easy access to the same information I’d look up myself. Language servers are built around what an editor needs. I built `rairai` around the questions I want an agent to ask, like “What should I check before changing this function?” The goal is to get the relevant information in one call without filling the context with unrelated code.
You can find it on CRAN, and the source is on GitHub. If you try it on one of your own packages, I’d love to hear what worked and what you’d change!