Convenience function to create and connect to an MCP server.
Usage
create_mcp_client(command, args = character(), env = NULL)Examples
if (FALSE) { # \dontrun{
# Connect to GitHub MCP server
client <- create_mcp_client(
"npx",
c("-y", "@modelcontextprotocol/server-github"),
env = c(GITHUB_PERSONAL_ACCESS_TOKEN = Sys.getenv("GITHUB_TOKEN"))
)
# List available tools
tools <- client$list_tools()
# Use tools with generate_text
result <- generate_text(
model = "openai:gpt-4o",
prompt = "List my GitHub repos",
tools = client$as_sdk_tools()
)
client$close()
} # }