Start MCP Server
Description
Start the llamaR MCP server. This exposes R tools to MCP clients like Claude Desktop, VS Code, or the llamar CLI.
Usage
1serve(port = NULL, cwd = NULL, tools = NULL)
Arguments
port: Port number for socket transport. If NULL, uses stdio transport.cwd: Working directory for the server. Defaults to current directory.tools: Character vector of tools or categories to enable. Categories: file, code, r, data, web, git, chat. Use “core” for file+code+git, “all” for everything (default).
Details
The server supports two transport modes:
stdio (default): For Claude Desktop and other MCP clients. Communication happens via stdin/stdout.
socket: For the llamar CLI and R clients. Listens on a TCP port.
Tools Provided
read_file,write_file,list_files,grep_files- File operationsrun_r- Execute R code in the server sessionbash- Run shell commandsr_help- Query package docs via fyi (exports, internals, options)installed_packages- List installed packagesread_csv- Read and summarize CSV filesweb_search- Search the web via Tavily (requires TAVILY_API_KEY)fetch_url- Fetch web contentgit_status,git_diff,git_log- Git operationschat,chat_models- LLM chat (requires llm.api)
Value
NULL (runs until interrupted or client disconnects)
Examples
1# For Claude Desktop (stdio)
2serve()
3
4# For llamar CLI (socket) with all tools
5serve(port = 7850)
6
7# Minimal tools for small context models
8serve(port = 7850, tools = "core")
9
10# Specific categories
11serve(port = 7850, tools = c("file", "git"))