| create_agent | R Documentation |
Convenience function that sets up MCP connections and returns a function for chatting with tools.
create_agent(servers = list(), system = NULL, model = NULL,
provider = c("anthropic", "openai", "moonshot", "ollama"),
verbose = TRUE)
servers |
Named list of server configs. Each can be: - 'list(port = 7850)' for already-running servers - 'list(command = "r", args = "server.R", port = 7850)' to start and connect |
system |
Character. Default system prompt. |
model |
Character. Default model. |
provider |
Character. Provider: "anthropic", "openai", "moonshot", or "ollama". |
verbose |
Logical. Print tool calls. |
A function that takes a prompt and returns a response.
## Not run:
# Connect to already-running server
chat_fn <- create_agent(
servers = list(codeR = list(port = 7850)),
system = "You are a helpful coding assistant."
)
# Or start server automatically
chat_fn <- create_agent(
servers = list(
codeR = list(command = "r", args = "mcp_server.R", port = 7850)
)
)
result <- chat_fn("List files in current directory")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.