Configure MCPClient for connecting to MCP servers
mcpServers
object has a server_name
and then specific options depending on how mcp-use
should connect to and/or manage the server.
server_name
: (Required) A unique string identifier for this MCP server configuration. This name is used to select the server, for example, in agent.run(..., server_name="your_server_name")
.mcp-use
will start and manage as local child processes, communicating via their standard input/output streams.
command
: (Required) The executable command to start the server (e.g., "npx"
, "python"
).args
: (Optional) An array of string arguments to pass to the command
(e.g., ["-y", "@playwright/mcp@latest"]
).env
: (Optional) An object defining environment variables to set for the server’s process (e.g., {"DISPLAY": ":1"}
).mcp-use
acts as an HTTP client to communicate with them.
url
: (Required) The full URL where the MCP server is listening (e.g., "http://localhost:7777/mcp"
, "https://api.example.com/mcp"
).headers
: (Optional) An object containing custom HTTP headers to be sent with every request to this server (e.g., for authentication: {"Authorization": "Bearer your_api_token"}
).MCPClient
can be configured with multiple MCP servers, allowing your agent to access tools from different sources. This capability enables complex workflows spanning various domains (e.g., web browsing and API interaction).
When an MCPClient
with multiple servers is passed to an MCPAgent
, the agent gains access to tools from all configured servers. By default, you might need to guide the agent or explicitly specify which server to use for a given task using the server_name
parameter in the agent.run()
method.
SandboxOptions
type provides the following configuration options:
Option | Description | Default |
---|---|---|
api_key | E2B API key. Required - can be provided directly or via E2B_API_KEY environment variable | None |
sandbox_template_id | Template ID for the sandbox environment | ”base” |
supergateway_command | Command to run supergateway | ”npx -y supergateway” |