Configuring Servers
MCP Servers are configured in the fastagent.config.yaml
file. Secrets can be kept in fastagent.secrets.yaml
, which follows the same format (fast-agent merges the contents of the two files).
Adding a STDIO Server
The below shows an example of configuring an MCP Server named server_one
.
mcp:
# name used in agent servers array
server_one:
# command to run
command: "npx"
# list of arguments for the command
args: ["@modelcontextprotocol/server-brave-search"]
# key/value pairs of environment variables
env:
BRAVE_API_KEY: your_key
KEY: value
server_two:
# and so on ...
This MCP Server can then be used with an agent as follows:
Adding an SSE Server
To use SSE Servers, specify the sse
transport and specify the endpoint URL and headers:
mcp:
# name used in agent servers array
server_two:
transport: "sse"
# url to connect
url: "http://localhost:8000/sse"
# timeout in seconds to use for sse sessions (optional)
read_transport_sse_timeout_seconds: 300
# request headers for connection
headers:
Authorization: "Bearer <secret>"
Roots
fast-agent supports MCP Roots. Roots are configured on a per-server basis:
mcp:
server_three:
transport: "sse"
url: "http://localhost:8000/sse"
roots:
uri: "file://...."
name: Optional Name
server_uri_alias: # optional
As per the MCP specification roots MUST be a valid URI starting with file://
.
If a server_uri_alias is supplied, fast-agent presents this to the MCP Server. This allows you to present a consistent interface to the MCP Server. An example of this usage would be mounting a local directory to a docker volume, and presenting it as /mnt/data
to the MCP Server for consistency.
The data analysis example (fast-agent quickstart data-analysis
has a working example of MCP Roots).
Sampling
Sampling is configured by specifying a sampling model for the MCP Server.
mcp:
server_four:
transport: "sse"
url: "http://localhost:8000/sse"
sampling:
model: "provider.model.<reasoning_effort>"
Read more about The model string and settings here. Sampling requests support vision - try @llmindset/mcp-webcam
for an example.