Overview
mcp-agent reads configuration from YAML files, environment variables, and optional preload strings to assemble a Settings object that powers every MCPApp. This page explains the load order, file format, and key sections you will customize for local development, automated workflows, and MCP Agent Cloud deployments.
How settings are loaded
- Preload string — if
MCP_APP_SETTINGS_PRELOADis set, the CLI andMCPAppparse it first. SetMCP_APP_SETTINGS_PRELOAD_STRICT=trueto fail fast on invalid YAML. - Explicit paths — CLI commands such as
dev serve --configor code that callsget_settings(config_path=...)override the search logic. - Discovered files —
Settings.find_config()andSettings.find_secrets()scan the current directory, each parent,./.mcp-agent/, and finally~/.mcp-agent/. - Secrets merge —
mcp_agent.secrets.yamlis merged over the main config so sensitive values override defaults. - Environment variables — every field exposes aliases like
OPENAI_API_KEY,ANTHROPIC_DEFAULT_MODEL, or nested keys such asMCP__SERVERS__filesystem__args=.... A.envfile in the project root is read automatically. - Programmatic overrides — passing a
Settingsinstance toMCPApp(settings=...)takes precedence over disk files.
Primary files
mcp_agent.config.yaml
Main configuration: execution engine, MCP servers, logging, providers, OAuth, and temporal settings.
mcp_agent.secrets.yaml
Sensitive material such as API keys, OAuth client secrets, and passwords. Always add this file to
.gitignore.Minimal example
Programmatic configuration
Secrets management
- Prefer storing secrets in
mcp_agent.secrets.yamlor environment variables; the CLI andget_settings()automatically merge them. - For temporary runs (CI, notebooks), serialize a
Settingsinstance and setMCP_APP_SETTINGS_PRELOADto the YAML string. This keeps secrets out of disk. - When deploying with
mcp-agent deploy, you will be prompted to classify each secret as developer- or user-provided; the CLI generatesmcp_agent.configured.secrets.yamlwith the required runtime schema.
Top-level keys
Execution engine
The defaultasyncio engine suits most agents:
Logging
LoggerSettings controls the event logger used by MCPApp:
transportsaccepts any combination ofconsole,file, orhttp.path_settingsgenerates unique filenames per run without writing fragile scripts.- For HTTP logging, set
http_endpoint,http_headers, andbatch_size.
Tracing and usage telemetry
Enable OpenTelemetry exporters to ship spans and metrics:MCP servers
Each entry inmcp.servers defines how to reach an upstream MCP server. Common patterns:
allowed_toolsrestricts which tools the LLM sees per server.rootslets you remap local directories into server roots usingfile://URIs.- For long-running HTTP transports, set
terminate_on_close: falseto keep sessions alive.
Server authentication and OAuth
Per-serverauth blocks support API keys or OAuth clients:
authorization section:
Model providers
OpenAI-compatible APIs
- Override
base_urlto target OpenAI-compatible services such as Groq (https://api.groq.com/openai/v1), Together, or local Ollama (http://localhost:11434/v1). Provide a dummyapi_keyfor services that do not check it. - Use
default_headersto inject custom headers when talking to proxies or gateways.
Anthropic
Azure OpenAI
credential_scopes if you authenticate with Entra ID tokens instead of API keys.
Google Gemini and Vertex AI
vertexai and providing project metadata:
Bedrock (generic) and Cohere
Subagents
Useagents to auto-load agent specifications from disk (Claude Code compatible):
Temporal configuration
Whenexecution_engine is temporal, every workflow and task decorator wires into the Temporal SDK. Ensure the queue name matches your worker process (uv run mcp-temporal-worker ...):
