mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 17:18:29 +00:00
This commit implements the MCPTool class with a from_server() class method
that provides a user-friendly API for connecting to MCP servers and getting
tools that can be used with CrewAI agents.
Features:
- Support for server names (npm packages via npx, Python packages via uvx)
- Support for HTTP/SSE URLs
- Support for MCPServerConfig objects (MCPServerStdio, MCPServerHTTP, MCPServerSSE)
- Optional parameters: env, headers, tool_filter, cache_tools_list
- JSON schema to Pydantic model conversion for tool arguments
- Sync and async tool execution support
Example usage:
from crewai.tools import MCPTool
# Connect to MCP servers
cloud_tools = MCPTool.from_server('@anthropic/mcp-server-filesystem')
api_tools = MCPTool.from_server('https://api.example.com/mcp')
# Create agent with MCP tools
agent = Agent(role='Cloud Engineer', tools=[*cloud_tools, *api_tools])
Closes #4197
Co-Authored-By: João <joao@crewai.com>