Connect to and communicate with an MCP server process.
processThe processx process object
server_infoInformation about the connected server
capabilitiesServer capabilities
new()Create a new MCP Client
McpClient$new(command, args = character(), env = NULL)commandThe command to run (e.g., "npx", "python")
argsCommand arguments (e.g., c("-y", "@modelcontextprotocol/server-github"))
envEnvironment variables as a named character vector
A new McpClient object
list_tools()List available tools from the MCP server
McpClient$list_tools()A list of tool definitions
call_tool()Call a tool on the MCP server
McpClient$call_tool(name, arguments = list())nameThe tool name
argumentsTool arguments as a named list
The tool result
list_resources()List available resources from the MCP server
McpClient$list_resources()A list of resource definitions
read_resource()Read a resource from the MCP server
McpClient$read_resource(uri)uriThe resource URI
The resource contents
is_alive()Check if the MCP server process is alive
McpClient$is_alive()TRUE if alive, FALSE otherwise
as_sdk_tools()Convert MCP tools to SDK Tool objects
McpClient$as_sdk_tools()A list of Tool objects
clone()The objects of this class are cloneable with this method.
McpClient$clone(deep = FALSE)deepWhether to make a deep clone.
Manages connection to an external MCP server via stdio.