Skip to contents

console_tool() starts mcp-console serve and returns its send tool as an ellmer::ToolDef. The server process and its persistent R, Python, and DuckDB state live as long as the returned tool remains reachable.

Usage

console_tool(
  ...,
  path = NULL,
  version = NULL,
  config = discover_console_config(path = path, version = version, project = project),
  project = getwd()
)

Arguments

...

Must be empty. Reserved for future use.

path

NULL, or a path to an mcp-console executable.

version

NULL, or one published mcp-console version, such as "0.0.2".

config

A ConsoleConfig(). By default, discover_console_config() reads optional global/project files once and materializes their settings. Pass ConsoleConfig() to skip files and use built-in defaults: host reads, private temporary writes, and no worker networking. Resolver defaults are independent. A supplied config reads no files unless its discovery property explicitly requests it. Explicit NULL is equivalent to ConsoleConfig(). Use the same path, version, and project when inspecting and launching a config.

project

Existing directory to use as the child process's working directory, defaulting to getwd(). Relative config and runtime paths use this directory; the caller's working directory is unchanged.

Value

An ellmer::ToolDef to pass to an ellmer chat's $register_tool() method.

Details

When the tool is garbage collected, it closes the server's input to request shutdown and waits up to 15 seconds before forcibly stopping the server. With sandboxing enabled, the sandbox manager owns cleanup of worker descendants; the R wrapper's fallback targets only the server process. With ConsoleConfig(sandbox = FALSE), worker descendants may survive server shutdown.

See vignette("autonomous-report", package = "mcp.console") for an explicit configuration, permission edits, inspection, and an ellmer launch.

Executable resolution

  • If path is supplied, console_tool() uses that executable directly.

  • Otherwise, if version is supplied, it resolves that published version with reticulate::uv_run_tool() without consulting PATH.

  • Otherwise, it uses mcp-console from PATH when available and falls back to the latest published version through reticulate::uv_run_tool().

path and version are mutually exclusive.

Examples

if (FALSE) { # \dontrun{
chat <- ellmer::chat_openai()
chat$register_tool(console_tool())
chat$chat(
  "Tell me something interesting about mtcars. Use the console as a workbench."
)

console_tool(path = Sys.which("mcp-console"))
console_tool(version = "0.0.2")
} # }