Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit 1ad7592

Browse files
authored
Merge branch 'crewAIInc:main' into main
2 parents 4dbac16 + daab6ab commit 1ad7592

File tree

81 files changed

+8342
-1573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+8342
-1573
lines changed

.github/workflows/tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Run Tests
2+
3+
on: [pull_request]
4+
5+
permissions:
6+
contents: write
7+
8+
env:
9+
OPENAI_API_KEY: fake-openai-key
10+
BRAVE_API_KEY: fake-brave-key
11+
SNOWFLAKE_USER: fake-snowflake-user
12+
SNOWFLAKE_PASSWORD: fake-snowflake-password
13+
SNOWFLAKE_ACCOUNT: fake-snowflake-account
14+
SNOWFLAKE_WAREHOUSE: fake-snowflake-warehouse
15+
SNOWFLAKE_DATABASE: fake-snowflake-database
16+
SNOWFLAKE_SCHEMA: fake-snowflake-schema
17+
EMBEDCHAIN_DB_URI: sqlite:///test.db
18+
19+
jobs:
20+
tests:
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 15
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v3
29+
with:
30+
enable-cache: true
31+
32+
- name: Set up Python
33+
run: uv python install 3.12.8
34+
35+
- name: Install the project
36+
run: uv sync --dev --all-extras
37+
38+
- name: Run tests
39+
run: uv run pytest tests -vv
40+

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ test.py
88
docs_crew/
99
chroma.sqlite3
1010
venv
11-
.venv/
11+
.venv/
12+
13+
# chroma db
14+
db

README.md

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ CrewAI provides an extensive collection of powerful tools ready to enhance your
2626
- **Web Scraping**: `ScrapeWebsiteTool`, `SeleniumScrapingTool`
2727
- **Database Integrations**: `PGSearchTool`, `MySQLSearchTool`
2828
- **API Integrations**: `SerperApiTool`, `EXASearchTool`
29-
- **AI-powered Tools**: `DallETool`, `VisionTool`
29+
- **AI-powered Tools**: `DallETool`, `VisionTool`, `StagehandTool`
3030

3131
And many more robust tools to simplify your agent integrations.
3232

@@ -66,6 +66,123 @@ def my_custom_function(input):
6666

6767
---
6868

69+
## CrewAI Tools and MCP
70+
71+
CrewAI Tools supports the Model Context Protocol (MCP). It gives you access to thousands of tools from the hundreds of MCP servers out there built by the community.
72+
73+
Before you start using MCP with CrewAI tools, you need to install the `mcp` extra dependencies:
74+
75+
```bash
76+
pip install crewai-tools[mcp]
77+
# or
78+
uv add crewai-tools --extra mcp
79+
```
80+
81+
To quickly get started with MCP in CrewAI you have 2 options:
82+
83+
### Option 1: Fully managed connection
84+
85+
In this scenario we use a contextmanager (`with` statement) to start and stop the the connection with the MCP server.
86+
This is done in the background and you only get to interact with the CrewAI tools corresponding to the MCP server's tools.
87+
88+
For an STDIO based MCP server:
89+
90+
```python
91+
from mcp import StdioServerParameters
92+
from crewai_tools import MCPServerAdapter
93+
94+
serverparams = StdioServerParameters(
95+
command="uvx",
96+
args=["--quiet", "pubmedmcp@0.1.3"],
97+
env={"UV_PYTHON": "3.12", **os.environ},
98+
)
99+
100+
with MCPServerAdapter(serverparams) as tools:
101+
# tools is now a list of CrewAI Tools matching 1:1 with the MCP server's tools
102+
agent = Agent(..., tools=tools)
103+
task = Task(...)
104+
crew = Crew(..., agents=[agent], tasks=[task])
105+
crew.kickoff(...)
106+
```
107+
For an SSE based MCP server:
108+
109+
```python
110+
serverparams = {"url": "http://localhost:8000/sse"}
111+
with MCPServerAdapter(serverparams) as tools:
112+
# tools is now a list of CrewAI Tools matching 1:1 with the MCP server's tools
113+
agent = Agent(..., tools=tools)
114+
task = Task(...)
115+
crew = Crew(..., agents=[agent], tasks=[task])
116+
crew.kickoff(...)
117+
```
118+
119+
### Option 2: More control over the MCP connection
120+
121+
If you need more control over the MCP connection, you can instanciate the MCPServerAdapter into an `mcp_server_adapter` object which can be used to manage the connection with the MCP server and access the available tools.
122+
123+
**important**: in this case you need to call `mcp_server_adapter.stop()` to make sure the connection is correctly stopped. We recommend that you use a `try ... finally` block run to make sure the `.stop()` is called even in case of errors.
124+
125+
Here is the same example for an STDIO MCP Server:
126+
127+
```python
128+
from mcp import StdioServerParameters
129+
from crewai_tools import MCPServerAdapter
130+
131+
serverparams = StdioServerParameters(
132+
command="uvx",
133+
args=["--quiet", "pubmedmcp@0.1.3"],
134+
env={"UV_PYTHON": "3.12", **os.environ},
135+
)
136+
137+
try:
138+
mcp_server_adapter = MCPServerAdapter(serverparams)
139+
tools = mcp_server_adapter.tools
140+
# tools is now a list of CrewAI Tools matching 1:1 with the MCP server's tools
141+
agent = Agent(..., tools=tools)
142+
task = Task(...)
143+
crew = Crew(..., agents=[agent], tasks=[task])
144+
crew.kickoff(...)
145+
146+
# ** important ** don't forget to stop the connection
147+
finally:
148+
mcp_server_adapter.stop()
149+
```
150+
151+
And finally the same thing but for an SSE MCP Server:
152+
153+
```python
154+
from mcp import StdioServerParameters
155+
from crewai_tools import MCPServerAdapter
156+
157+
serverparams = {"url": "http://localhost:8000/sse"}
158+
159+
try:
160+
mcp_server_adapter = MCPServerAdapter(serverparams)
161+
tools = mcp_server_adapter.tools
162+
# tools is now a list of CrewAI Tools matching 1:1 with the MCP server's tools
163+
agent = Agent(..., tools=tools)
164+
task = Task(...)
165+
crew = Crew(..., agents=[agent], tasks=[task])
166+
crew.kickoff(...)
167+
168+
# ** important ** don't forget to stop the connection
169+
finally:
170+
mcp_server_adapter.stop()
171+
```
172+
173+
### Considerations & Limitations
174+
175+
#### Staying Safe with MCP
176+
177+
Always make sure that you trust the MCP Server before using it. Using an STDIO server will execute code on your machine. Using SSE is still not a silver bullet with many injection possible into your application from a malicious MCP server.
178+
179+
#### Limitations
180+
181+
* At this time we only support tools from MCP Server not other type of primitives like prompts, resources...
182+
* We only return the first text output returned by the MCP Server tool using `.content[0].text`
183+
184+
---
185+
69186
## Why Use CrewAI Tools?
70187

71188
- **Simplicity & Flexibility**: Easy-to-use yet powerful enough for complex workflows.

crewai_tools/__init__.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
from .adapters.enterprise_adapter import EnterpriseActionTool
2+
from .adapters.mcp_adapter import MCPServerAdapter
3+
from .aws import (
4+
BedrockInvokeAgentTool,
5+
BedrockKBRetrieverTool,
6+
S3ReaderTool,
7+
S3WriterTool,
8+
)
19
from .tools import (
210
AIMindTool,
311
ApifyActorsTool,
@@ -6,6 +14,7 @@
614
CodeDocsSearchTool,
715
CodeInterpreterTool,
816
ComposioTool,
17+
CrewaiEnterpriseTools,
918
CSVSearchTool,
1019
DallETool,
1120
DatabricksQueryTool,
@@ -15,6 +24,7 @@
1524
EXASearchTool,
1625
FileReadTool,
1726
FileWriterTool,
27+
FileCompressorTool,
1828
FirecrawlCrawlWebsiteTool,
1929
FirecrawlScrapeWebsiteTool,
2030
FirecrawlSearchTool,
@@ -51,18 +61,14 @@
5161
SnowflakeConfig,
5262
SnowflakeSearchTool,
5363
SpiderTool,
64+
StagehandTool,
5465
TXTSearchTool,
5566
VisionTool,
5667
WeaviateVectorSearchTool,
5768
WebsiteSearchTool,
5869
XMLSearchTool,
5970
YoutubeChannelSearchTool,
6071
YoutubeVideoSearchTool,
72+
ZapierActionTools,
6173
)
62-
63-
from .aws import (
64-
S3ReaderTool,
65-
S3WriterTool,
66-
BedrockKBRetrieverTool,
67-
BedrockInvokeAgentTool,
68-
)
74+
from .adapters.zapier_adapter import ZapierActionTool

0 commit comments

Comments
 (0)