Skip to main content
mcp-agent uses YAML configuration files to manage application settings, MCP servers, and model providers.

Configuration files

Start with two YAML files at the root of your project:

mcp_agent.config.yaml

Application configuration, MCP servers, logging, execution engine, model defaults

mcp_agent.secrets.yaml

API keys, OAuth credentials, and other secrets (gitignored)
See Specify Secrets for credential management patterns and production tips.

Basic configuration

Here’s a minimal configuration:

Execution Engine

Choose how your workflows execute:
In-memory execution for development and simple deployments:
Best for:
  • Local development
  • Simple agents
  • Quick prototyping
Learn more about Execution Engines →

Logging

Configure logging output and level:
mcp_agent.config.yaml
You can also use dynamic log filenames:
Learn more about Logging →

MCP Servers

Define MCP servers your agents can connect to:
mcp_agent.config.yaml
Learn more about MCP Servers →

Model Providers

Configure your LLM provider. Many examples follow this layout—for instance, the basic finder agent sets OpenAI defaults exactly this way.
mcp_agent.config.yaml
mcp_agent.secrets.yaml

OAuth configuration

Two places control OAuth behaviour:
  1. Global OAuth settings (settings.oauth) configure token storage and callback behaviour (loopback ports, preload timeouts, Redis support).
  2. Per-server auth (mcp.servers[].auth.oauth) specifies client credentials, scopes, and provider overrides.
mcp_agent.config.yaml
Pair this with secrets in mcp_agent.secrets.yaml or environment variables. For concrete walkthroughs, study the OAuth basic agent and the interactive OAuth tool. The pre-authorize workflow example shows how to seed credentials before a background workflow runs.

Programmatic configuration

You can bypass file discovery by passing a fully-formed Settings object (or a path) to MCPApp. This is especially useful for tests and scripts that compose configuration dynamically.
Because Settings extends BaseSettings, environment variables still override any fields you set explicitly.

Configuration discovery

When MCPApp starts, it resolves settings in this order:
  • MCP_APP_SETTINGS_PRELOAD / MCP_APP_SETTINGS_PRELOAD_STRICT
  • Explicit settings argument passed to MCPApp
  • mcp_agent.config.yaml (or mcp-agent.config.yaml) discovered in the working directory, parent directories, .mcp-agent/ folders, or ~/.mcp-agent/
  • mcp_agent.secrets.yaml / mcp-agent.secrets.yaml merged on top
  • Environment variables (including values from .env, using __ for nesting)
Environment variables override file-based values, while the preload option short-circuits everything else—handy for containerised deployments that mount secrets from a vault. Specify Secrets covers strategies for each stage.

Environment Variables

You can reference environment variables in configuration:
mcp_agent.config.yaml
Use environment variables for deployment-specific settings like endpoints and regions, while keeping model choices in the config file.

Project Structure

Recommended project layout:
Add to .gitignore:

Complete Configuration Reference

For all available configuration options, see the Configuration Reference.

Next Steps

Specify Secrets

Learn about secrets management

MCPApp

Understand the application context

Agents

Create your first agent

Configuration Reference

Complete configuration documentation