Skip to main content

Overview

CrewAI’s MCP DSL (Domain Specific Language) integration provides the simplest way to connect your agents to MCP (Model Context Protocol) servers. Just add an mcps field to your agent and CrewAI handles all the complexity automatically.
This is the recommended approach for most MCP use cases. For advanced scenarios requiring manual connection management, see MCPServerAdapter.

Basic Usage

Add MCP servers to your agent using the mcps field:

Supported Reference Formats

External MCP Remote Servers

Specific Tool Selection

Use the # syntax to select specific tools from a server:

Connected MCP Integrations

Connect MCP servers from the CrewAI catalog or bring your own. Once connected in your account, reference them by slug:

Complete Example

Here’s a complete example using multiple MCP servers:

Tool Naming and Organization

CrewAI automatically handles tool naming to prevent conflicts:

Error Handling and Resilience

The MCP DSL is designed to be robust and user-friendly:

Graceful Server Failures

Timeout Protection

All MCP operations have built-in timeouts:
  • Connection timeout: 10 seconds
  • Tool execution timeout: 30 seconds
  • Discovery timeout: 15 seconds

Performance Features

Automatic Caching

Tool schemas are cached for 5 minutes to improve performance:

On-Demand Connections

Tool connections are established only when tools are actually used:

Integration with Existing Features

MCP tools work seamlessly with other CrewAI features:

Best Practices

1. Use Specific Tools When Possible

2. Handle Authentication Securely

3. Plan for Server Failures

4. Use Descriptive Agent Roles

Troubleshooting

Common Issues

No tools discovered:
Connection timeouts:
Authentication failures:

Advanced: MCPServerAdapter

For complex scenarios requiring manual connection management, use the MCPServerAdapter class from crewai-tools. Using a Python context manager (with statement) is the recommended approach as it automatically handles starting and stopping the connection to the MCP server.