Skip to main content
This guide shows you how to configure and use multiple MCP servers simultaneously with mcp_use, enabling complex workflows that span different domains.

Overview

Using multiple MCP servers allows your agent to access a diverse set of tools from different sources. For example, you might want to:
  • Web scraping with Playwright + File operations with filesystem server
  • Database queries with SQLite + API calls with HTTP server
  • Code execution with Python server + Git operations with GitHub server
The MCPClient can manage multiple servers, and the optional ServerManager can dynamically select the appropriate server for each task.

Basic Multi-Server Configuration

Create a configuration file that defines multiple servers:
multi_server_config.json

Using Multiple Servers

Basic Approach (Manual Server Selection)

Advanced Approach (Server Manager)

Enable the server manager for more efficient resource usage:

Configuration Patterns

Web Scraping + Data Processing

Usage example:

Development Workflow

Usage example:

Research and Documentation

Managing Server Dependencies

Environment Variables

Use environment variables for sensitive information:
.env
Reference them in your configuration:

Conditional Server Loading

You can conditionally include servers based on availability:

Performance Optimization

Server Manager Benefits

The server manager provides several performance benefits:

Tool Filtering

Control which tools are available to prevent confusion:

Troubleshooting Multi-Server Setups

Common Issues

Check server logs and ensure all dependencies are installed:
Different servers might provide tools with the same name:
Too many servers can slow down the agent:

Debug Configuration

Enable comprehensive debugging:

Best Practices

Start Simple

Begin with 2-3 servers and add more as needed. Too many servers can overwhelm the LLM.

Use Server Manager

Enable use_server_manager=True for better performance and resource management.

Environment Variables

Store sensitive configuration like API keys in environment variables, not config files.

Error Handling

Implement graceful degradation when servers are unavailable or fail.

Next Steps

Server Manager

Learn more about dynamic server selection and management

Security Guide

Best practices for secure multi-server configurations

Agent Configuration

Configure agents for optimal performance