docs/developer/mcp-configuration.md
This guide provides comprehensive technical details for configuring and utilizing external tool providers through the Model Context Protocol (MCP) with Agent Zero. This allows Agent Zero to leverage tools hosted by separate local or remote MCP-compliant servers.
[!NOTE] For a quick start guide on adding MCP servers through the UI, see MCP Setup.
[!NOTE] This guide covers Agent Zero as an MCP client. To expose Agent Zero as an MCP server, see Connectivity → MCP Server.
Agent Zero supports three main types of MCP servers:
Agent Zero discovers and integrates MCP tools dynamically through the following process:
usr/settings.json, specifically the "mcp_servers" key.npx/uvx based servers, the first run downloads packages.{{tools}} placeholder in templates (e.g., prompts/agent.system.mcp_tools.md) is replaced with the formatted tool list.process_tools method (mcp_handler.py) routes the request to the appropriate MCP server.MCP server configurations are stored in:
usr/settings.json (primary storage)mcp_servers SettingWithin usr/settings.json, MCP servers are defined under the "mcp_servers" key:
"mcpServers" (recommended, matches UI){"mcpServers": {}}){
"mcpServers": {
"sqlite": {
"command": "uvx",
"args": ["mcp-server-sqlite", "--db-path", "/root/db.sqlite"]
},
"deep-wiki": {
"description": "Use this MCP to analyze GitHub repositories",
"url": "https://mcp.deepwiki.com/sse"
}
}
}
[!NOTE] In
usr/settings.json, the entire"mcp_servers"value is stored as a single string. The Settings UI handles escaping automatically.
For existing settings.json files without MCP support:
"mcp_servers": ""{
"name": "My Local Tool Server",
"description": "Optional: A brief description of this server.",
"type": "stdio",
"command": "python",
"args": ["path/to/your/mcp_stdio_script.py", "--some-arg"],
"env": {
"PYTHONPATH": "/path/to/custom/libs:.",
"ANOTHER_VAR": "value"
},
"encoding": "utf-8",
"encoding_error_handler": "strict",
"disabled": false
}
Configuration Fields:
type: Optional, auto-detected. Can be "stdio", "sse", or streaming variantscommand: Required. The executable to runargs: Optional list of command argumentsenv: Optional environment variables for the processencoding: Optional, default "utf-8"encoding_error_handler: Optional, can be "strict", "ignore", or "replace"{
"name": "My Remote API Tools",
"description": "Optional: Description of the remote SSE server.",
"type": "sse",
"url": "https://api.example.com/mcp-sse-endpoint",
"headers": {
"Authorization": "Bearer YOUR_API_KEY_OR_TOKEN",
"X-Custom-Header": "some_value"
},
"timeout": 5.0,
"sse_read_timeout": 300.0,
"disabled": false
}
Configuration Fields:
url: Required. Full URL for the SSE endpointheaders: Optional HTTP headers for authentication/custom headerstimeout: Optional connection timeout in seconds (default: 5.0)sse_read_timeout: Optional read timeout for SSE stream (default: 300.0){
"name": "My Streaming HTTP Tools",
"description": "Optional: Description of the remote streaming HTTP server.",
"type": "streaming-http",
"url": "https://api.example.com/mcp-http-endpoint",
"headers": {
"Authorization": "Bearer YOUR_API_KEY_OR_TOKEN",
"X-Custom-Header": "some_value"
},
"timeout": 5.0,
"sse_read_timeout": 300.0,
"disabled": false
}
Streaming HTTP Variants:
Type can be: "http-stream", "streaming-http", "streamable-http", or "http-streaming"
{
"mcp_servers": "[{'name': 'MyPythonTools', 'command': 'python3', 'args': ['mcp_scripts/my_server.py'], 'disabled': false}, {'name': 'ExternalAPI', 'url': 'https://data.example.com/mcp', 'headers': {'X-Auth-Token': 'supersecret'}, 'disabled': false}]"
}
name: Unique server identifier. Used to prefix tools (e.g., server_name.tool_name). Normalized internally (lowercase, spaces/hyphens → underscores)type: Optional explicit type. Auto-detected if omitted based on command (stdio) or url (defaults to sse)disabled: Boolean. Set true to ignore this server without removing configurationdescription: Optional human-readable descriptioncommandurlmacOS/Windows:
{
"url": "http://host.docker.internal:PORT/endpoint"
}
Linux:
http://container_name:PORT/endpointUse standard HTTPS URLs:
{
"url": "https://api.example.com/mcp-endpoint"
}
MCP tools are prefixed with the normalized server name:
"sequential-thinking""run_chain"sequential_thinking.run_chainInstruct the agent to use MCP tools directly:
"Agent, use the sequential_thinking.run_chain tool with the following input..."
The LLM formulates the appropriate JSON request automatically.
process_tools method receives tool requestmcp_handler.py checks if tool name exists in MCPConfigThis prioritization allows MCP tools to extend or override built-in functionality.
Check status in UI:
Common issues:
Verification steps:
npx/uvx servers, first run downloads packages (may take time)Adjust encoding settings:
{
"encoding": "utf-8",
"encoding_error_handler": "replace"
}
Error handler options:
"strict": Fail on encoding errors (default)"ignore": Skip problematic characters"replace": Replace with placeholder characterStore sensitive data securely:
Adjust for network conditions:
{
"timeout": 10.0, // Initial connection
"sse_read_timeout": 600.0 // Long-running operations
}
For high-frequency tool usage:
{
"mcpServers": {
"browser": {
"command": "npx",
"args": ["-y", "chrome-devtools-mcp@latest"]
},
"database": {
"command": "uvx",
"args": ["mcp-server-sqlite", "--db-path", "/data/app.db"]
},
"external-api": {
"url": "https://api.example.com/mcp",
"headers": {
"Authorization": "Bearer token123"
}
},
"backup-api": {
"url": "https://backup.example.com/mcp",
"disabled": true
}
}
}
{
"mcpServers": {
"python-tools": {
"command": "python3",
"args": ["/opt/tools/mcp_server.py"],
"env": {
"PYTHONPATH": "/opt/libs:/usr/local/lib/python3.9",
"API_KEY": "secret_key",
"DEBUG": "true"
}
}
}
}
Combine multiple MCP servers for complex workflows:
Agent Zero can chain these tools automatically based on task requirements.
{
"mcpServers": {
"primary-service": {
"url": "https://primary.example.com/mcp"
},
"fallback-service": {
"url": "https://fallback.example.com/mcp",
"disabled": true
}
}
}
Enable fallback manually when primary service is unavailable.
disabled: falseFor developing custom MCP servers:
See MCP Protocol Documentation for implementation details.