gptr_mcp_add() writes a server into gptr's own mcp.json: the user file under
tools::R_user_dir("gptr", "config"), or .gptr/mcp.json of the project (used only when
you trust the project). It never edits another harness's files. Give exactly one of
command (a server started as a local process speaking stdio) and url (a Streamable HTTP
server). Secret values in env and headers must be ${VAR} placeholders: they are
expanded from the environment when gptr connects and never stored. Nothing connects until a
tool is used.
Arguments
- name
Server name: 1-64 letters, digits,
_or-. Its tools are reached aspeter$mcp$<name>$<tool>()inside thertool.- command, args
The program and its arguments for a stdio server.
- url
The endpoint of a Streamable HTTP server.
- env, headers
Named character vectors: environment variables of a stdio server, HTTP headers of an HTTP server. Write secrets as
${VAR}placeholders.- exposure
How the model reaches the tools:
"r"(R functions listed in the prompt),"direct"(declared as tools),"deferred"(found throughpeter$search()) or"hidden".- timeout
Seconds per request; progress notifications from the server extend it.
- scope
"user"(default) or"project".
Value
gptr_mcp_add() returns the server spec invisibly; gptr_mcp_remove() returns
TRUE invisibly when a server was removed, else FALSE.
Examples
proj = tempfile("proj")
dir.create(proj)
old = options(gptr.project_root = proj)
gptr_init(proj)
gptr_mcp_add("fs", command = "npx",
args = c("-y", "@modelcontextprotocol/server-filesystem", "."),
scope = "project")
gptr_mcp_remove("fs", scope = "project")
options(old)
unlink(proj, recursive = TRUE)