A host-owned connection to one configured server. A separate R worker keeps mcptools' connection registry independent of other connections. mcptools owns transport and authentication; the selected server owns execution.
This temporary adapter is qualified for mcptools 1.0.2 and uses its internal request and shutdown functions. Public replacements are tracked upstream in issues 129 and 130. Other versions fail explicitly.
Details
Construct an Agent first, then bind a connection to it. Tool, resource URI and
prompt allowlists are fixed at construction. Discovery never expands them.
Register the tools returned by $tools() to apply the Agent's normal
permissions, hooks and budgets. Direct host methods use the connection's
allowlists but do not constitute an Agent run.
Calls return promises, with at most one active call per connection. A concurrent
call fails with a busy error; unrelated connections and the host event loop remain
available. The host must call $close() when its conversation ends.
$cancel() terminates the connection and its process tree, discarding server
session state. It does not promise a state-preserving interpreter interrupt.
Timeouts also close the connection; old tools cannot reconnect implicitly.
Owner identifiers and run context prevent accidental cross-Agent reuse; the host remains responsible for authentication and assigning those identifiers. Connections and executable tools are not portable saved-session state.
Methods
McpConnection$new()
Connect and discover tools from one exact server entry.
Usage
McpConnection$new(
config,
server,
agent,
tools = character(),
resources = character(),
prompts = character(),
timeout = 60,
startup_timeout = 60
)Arguments
configPath to an mcptools JSON configuration.
serverExact configured server name.
agentAgent whose identity, session and run context own this connection.
toolsExact tool names the host allows. Empty by default.
resourcesExact resource URIs the host allows. Empty by default.
promptsExact prompt names the host allows. Empty by default.
timeoutMaximum seconds for each request.
startup_timeoutMaximum seconds for client and server startup.
McpConnection$discover()
Inspect one catalogue page without registering or authorizing items.
Usage
McpConnection$discover(
kind = c("tools", "resources", "resource_templates", "prompts"),
cursor = NULL
)McpConnection$get_prompt()
Retrieve one explicitly allowed prompt without changing any Chat.
Usage
McpConnection$get_prompt(name, arguments = list())McpConnection$capability_tools()
Build resource and prompt tools restricted to the fixed host allowlists.