Connect to and communicate with an MCP server process.
Details
Manages connection to an external MCP server via stdio.
Public fields
process
The processx process object
server_info
Information about the connected server
capabilities
Server capabilities
Methods
Method new()
Create a new MCP Client
Arguments
command
The command to run (e.g., "npx", "python")
args
Command arguments (e.g., c("-y", "@modelcontextprotocol/server-github"))
env
Environment variables as a named character vector
Returns
A new McpClient object
List available tools from the MCP server
Returns
A list of tool definitions
Call a tool on the MCP server
Usage
McpClient$call_tool(name, arguments = list())
Arguments
name
The tool name
arguments
Tool arguments as a named list
Method list_resources()
List available resources from the MCP server
Usage
McpClient$list_resources()
Returns
A list of resource definitions
Method read_resource()
Read a resource from the MCP server
Usage
McpClient$read_resource(uri)
Returns
The resource contents
Method is_alive()
Check if the MCP server process is alive
Returns
TRUE if alive, FALSE otherwise
Close the MCP client connection
Convert MCP tools to SDK Tool objects
Returns
A list of Tool objects
Method clone()
The objects of this class are cloneable with this method.
Usage
McpClient$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.