Skip to main content

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.
Use uvx mcp-agent config builder for an interactive wizard that generates both config and secrets files. Run uvx mcp-agent config show --secrets (or uv run mcp-agent … inside your project) at any time to see what the CLI discovers.

How settings are loaded

  • Preload string — if MCP_APP_SETTINGS_PRELOAD is set, the CLI and MCPApp parse it first. Set MCP_APP_SETTINGS_PRELOAD_STRICT=true to fail fast on invalid YAML.
  • Explicit paths — CLI commands such as dev serve --config or code that calls get_settings(config_path=...) override the search logic.
  • Discovered filesSettings.find_config() and Settings.find_secrets() scan the current directory, each parent, ./.mcp-agent/, and finally ~/.mcp-agent/.
  • Secrets mergemcp_agent.secrets.yaml is 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 as MCP__SERVERS__filesystem__args=.... A .env file in the project root is read automatically.
  • Programmatic overrides — passing a Settings instance to MCPApp(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.yaml or environment variables; the CLI and get_settings() automatically merge them.
  • For temporary runs (CI, notebooks), serialize a Settings instance and set MCP_APP_SETTINGS_PRELOAD to 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 generates mcp_agent.configured.secrets.yaml with the required runtime schema.

Top-level keys

Execution engine

The default asyncio engine suits most agents:
Switch to Temporal when you need durable, resumable workflows:

Logging

LoggerSettings controls the event logger used by MCPApp:
  • transports accepts any combination of console, file, or http.
  • path_settings generates unique filenames per run without writing fragile scripts.
  • For HTTP logging, set http_endpoint, http_headers, and batch_size.

Tracing and usage telemetry

Enable OpenTelemetry exporters to ship spans and metrics:
Usage telemetry is opt-in by default; disable if you prefer zero reporting:

MCP servers

Each entry in mcp.servers defines how to reach an upstream MCP server. Common patterns:
  • allowed_tools restricts which tools the LLM sees per server.
  • roots lets you remap local directories into server roots using file:// URIs.
  • For long-running HTTP transports, set terminate_on_close: false to keep sessions alive.

Server authentication and OAuth

Per-server auth blocks support API keys or OAuth clients:
Global OAuth defaults configure token storage and callback behaviour:
To secure your own MCP server with OAuth 2.0, populate the authorization section:

Model providers

OpenAI-compatible APIs

  • Override base_url to target OpenAI-compatible services such as Groq (https://api.groq.com/openai/v1), Together, or local Ollama (http://localhost:11434/v1). Provide a dummy api_key for services that do not check it.
  • Use default_headers to inject custom headers when talking to proxies or gateways.

Anthropic

Run Claude via Bedrock or Vertex AI by adjusting the provider and credentials:

Azure OpenAI

Set credential_scopes if you authenticate with Entra ID tokens instead of API keys.

Google Gemini and Vertex AI

Enable Vertex AI by toggling vertexai and providing project metadata:

Bedrock (generic) and Cohere

Subagents

Use agents to auto-load agent specifications from disk (Claude Code compatible):

Temporal configuration

When execution_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 ...):

Example scenarios

Local development preset

Production with Temporal and OAuth

For CLI usage, see the CLI reference, and explore decorator capabilities in the Decorators reference.