Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
docs: updating MCP docs with connect_timeout attribute (#3273)
Lucas Gomide246cf588cdb8
diff --git a/docs/en/mcp/overview.mdx b/docs/en/mcp/overview.mdxindex a5c18b106..6b2268454 100644--- a/docs/en/mcp/overview.mdx+++ b/docs/en/mcp/overview.mdx@@ -44,6 +44,19 @@ The `MCPServerAdapter` class from `crewai-tools` is the primary way to connect tUsing a Python context manager (`with` statement) is the **recommended approach** for `MCPServerAdapter`. It automatically handles starting and stopping the connection to the MCP server.+## Connection Configuration++The `MCPServerAdapter` supports several configuration options to customize the connection behavior:++- **`connect_timeout`** (optional): Maximum time in seconds to wait for establishing a connection to the MCP server. Defaults to 30 seconds if not specified. This is particularly useful for remote servers that may have variable response times.++```python+# Example with custom connection timeout+with MCPServerAdapter(server_params, connect_timeout=60) as tools:+ # Connection will timeout after 60 seconds if not established+ pass+```+```pythonfrom crewai import Agentfrom crewai_tools import MCPServerAdapter@@ -70,7 +83,7 @@ server_params = {}# Example usage (uncomment and adapt once server_params is set):-with MCPServerAdapter(server_params) as mcp_tools:+with MCPServerAdapter(server_params, connect_timeout=60) as mcp_tools:print(f"Available tools: {[tool.name for tool in mcp_tools]}")my_agent = Agent(@@ -95,7 +108,7 @@ There are two ways to filter tools:### Accessing a specific tool using dictionary-style indexing.```python-with MCPServerAdapter(server_params) as mcp_tools:+with MCPServerAdapter(server_params, connect_timeout=60) as mcp_tools:print(f"Available tools: {[tool.name for tool in mcp_tools]}")my_agent = Agent(@@ -112,7 +125,7 @@ with MCPServerAdapter(server_params) as mcp_tools:### Pass a list of tool names to the `MCPServerAdapter` constructor.```python-with MCPServerAdapter(server_params, "tool_name") as mcp_tools:+with MCPServerAdapter(server_params, "tool_name", connect_timeout=60) as mcp_tools:print(f"Available tools: {[tool.name for tool in mcp_tools]}")my_agent = Agent(diff --git a/docs/pt-BR/mcp/overview.mdx b/docs/pt-BR/mcp/overview.mdxindex 5ce4444c9..5ceaaa144 100644--- a/docs/pt-BR/mcp/overview.mdx+++ b/docs/pt-BR/mcp/overview.mdx@@ -44,6 +44,19 @@ A classe `MCPServerAdapter` da `crewai-tools` é a principal forma de conectar-sO uso de um gerenciador de contexto Python (`with`) é a **abordagem recomendada** para o `MCPServerAdapter`. Ele lida automaticamente com a abertura e o fechamento da conexão com o servidor MCP.+## Configuração de Conexão++O `MCPServerAdapter` suporta várias opções de configuração para personalizar o comportamento da conexão:++- **`connect_timeout`** (opcional): Tempo máximo em segundos para aguardar o estabelecimento de uma conexão com o servidor MCP. O padrão é 30 segundos se não especificado. Isso é particularmente útil para servidores remotos que podem ter tempos de resposta variáveis.++```python+# Exemplo com timeout personalizado para conexão+with MCPServerAdapter(server_params, connect_timeout=60) as tools:+ # A conexão terá timeout após 60 segundos se não estabelecida+ pass+```+```pythonfrom crewai import Agentfrom crewai_tools import MCPServerAdapter@@ -70,7 +83,7 @@ server_params = {}# Exemplo de uso (descomente e adapte após definir server_params):-with MCPServerAdapter(server_params) as mcp_tools:+with MCPServerAdapter(server_params, connect_timeout=60) as mcp_tools:print(f"Available tools: {[tool.name for tool in mcp_tools]}")meu_agente = Agent(@@ -88,7 +101,7 @@ Este padrão geral mostra como integrar ferramentas. Para exemplos específicos## Filtrando Ferramentas```python-with MCPServerAdapter(server_params) as mcp_tools:+with MCPServerAdapter(server_params, connect_timeout=60) as mcp_tools:print(f"Available tools: {[tool.name for tool in mcp_tools]}")meu_agente = Agent(