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:
- Local Stdio Servers: Local executables that Agent Zero communicates with via standard input/output (stdio).
- Remote SSE Servers: Network-accessible servers that use Server-Sent Events (SSE), usually over HTTP/S.
- Remote Streaming HTTP Servers: Servers using the streamable HTTP transport protocol for MCP communication.
Agent Zero discovers and integrates MCP tools dynamically through the following process:
- Configuration: MCP servers are defined in the Agent Zero configuration, primarily through the Settings UI.
- Saving Settings: When saved via the UI, Agent Zero updates
usr/settings.json, specifically the"mcp_servers"key. - Server Startup: Agent Zero initializes configured MCP servers (stdio) or connects to them (remote). For
npx/uvxbased servers, the first run downloads packages. - Tool Discovery: Upon initialization, Agent Zero connects to each enabled MCP server and queries for available tools, descriptions, and parameters.
- Dynamic Prompting: Tool information is injected into the agent's system prompt. The
{{tools}}placeholder in templates (e.g.,prompts/agent.system.mcp_tools.md) is replaced with the formatted tool list. - Tool Invocation: When the LLM requests an MCP tool, Agent Zero's
process_toolsmethod (mcp_handler.py) routes the request to the appropriate MCP server.
MCP server configurations are stored in:
usr/settings.json(primary storage)
Within usr/settings.json, MCP servers are defined under the "mcp_servers" key:
- Value Type: JSON formatted string containing:
- A JSON object with
"mcpServers"(recommended, matches UI) - Or a JSON array of server configurations
- A JSON object with
- Default Value: Empty config (
{"mcpServers": {}}) - Manual Editing: While UI configuration is recommended, manual editing is possible. Ensure proper JSON string formatting with escaped quotes.
{
"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:
- Ensure you're running a version with MCP support
- Open the settings UI
- Save settings (even without changes)
- This writes the complete settings structure including
"mcp_servers": "" - Configure servers via UI or careful manual editing
{
"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 oncommand(stdio) orurl(defaults to sse)disabled: Boolean. Settrueto ignore this server without removing configurationdescription: Optional human-readable description
- Stdio servers: Require
command - Remote servers: Require
url
macOS/Windows:
{
"url": "http://host.docker.internal:PORT/endpoint"
}Linux:
- Run MCP server in the same Docker network
- Reference by container name:
http://container_name:PORT/endpoint
Use standard HTTPS URLs:
{
"url": "https://api.example.com/mcp-endpoint"
}MCP tools are prefixed with the normalized server name:
- Server name:
"sequential-thinking" - Tool name from server:
"run_chain" - Final tool name in Agent Zero:
sequential_thinking.run_chain
Instruct 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_toolsmethod receives tool requestmcp_handler.pychecks if tool name exists inMCPConfig- If found: delegates to corresponding MCP server
- If not found: attempts to find built-in tool with that name
This prioritization allows MCP tools to extend or override built-in functionality.
Check status in UI:
- Settings → MCP/A2A → External MCP Servers
- Green indicator = connected
- Red indicator = connection failed
Common issues:
- Wrong URL or port
- Missing authentication headers
- Network/firewall blocking connection
- Server not running
Verification steps:
- Confirm server shows as connected (green status)
- Check server exposes tools (count shown in UI)
- Verify tool names match server documentation
- For
npx/uvxservers, 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 character
Store sensitive data securely:
- Use environment variables when possible
- Avoid committing secrets to version control
- Use header-based authentication for remote servers
- Use HTTPS for remote MCP servers
- Validate SSL certificates (default behavior)
- Restrict network access to trusted servers only
- Only run trusted executables
- Review server code before execution
- Use environment isolation when possible
Adjust for network conditions:
{
"timeout": 10.0, // Initial connection
"sse_read_timeout": 600.0 // Long-running operations
}For high-frequency tool usage:
- Agent Zero maintains persistent connections to remote servers
- Stdio servers are kept alive between tool calls
- Reduces overhead for repeated operations
{
"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:
- Browser MCP for data extraction
- Database MCP for storage
- Workflow MCP for orchestration
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.
- Add server with
disabled: false - Save and check connection status
- Test individual tools via agent prompts
- Monitor logs for errors
- Adjust configuration as needed
For developing custom MCP servers:
- Follow MCP protocol specifications
- Implement stdio or HTTP transport
- Provide clear tool descriptions
- Test with Agent Zero before production
See MCP Protocol Documentation for implementation details.
- MCP Setup - Quick start guide
- Connectivity: MCP Server - Exposing Agent Zero as MCP server
- Advanced: Extensions - Custom tools and extensions