Skip to content

Commit bcc3e35

Browse files
authored
feat: Add Merge Agent Handler tool (#3911)
* feat: Add Merge Agent Handler tool * Fix linting issues * Empty
1 parent d160f08 commit bcc3e35

File tree

6 files changed

+1099
-0
lines changed

6 files changed

+1099
-0
lines changed

lib/crewai-tools/src/crewai_tools/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
from crewai_tools.tools.linkup.linkup_search_tool import LinkupSearchTool
9191
from crewai_tools.tools.llamaindex_tool.llamaindex_tool import LlamaIndexTool
9292
from crewai_tools.tools.mdx_search_tool.mdx_search_tool import MDXSearchTool
93+
from crewai_tools.tools.merge_agent_handler_tool.merge_agent_handler_tool import (
94+
MergeAgentHandlerTool,
95+
)
9396
from crewai_tools.tools.mongodb_vector_search_tool.vector_search import (
9497
MongoDBVectorSearchConfig,
9598
MongoDBVectorSearchTool,
@@ -235,6 +238,7 @@
235238
"LlamaIndexTool",
236239
"MCPServerAdapter",
237240
"MDXSearchTool",
241+
"MergeAgentHandlerTool",
238242
"MongoDBVectorSearchConfig",
239243
"MongoDBVectorSearchTool",
240244
"MultiOnTool",

lib/crewai-tools/src/crewai_tools/tools/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
from crewai_tools.tools.linkup.linkup_search_tool import LinkupSearchTool
8080
from crewai_tools.tools.llamaindex_tool.llamaindex_tool import LlamaIndexTool
8181
from crewai_tools.tools.mdx_search_tool.mdx_search_tool import MDXSearchTool
82+
from crewai_tools.tools.merge_agent_handler_tool.merge_agent_handler_tool import (
83+
MergeAgentHandlerTool,
84+
)
8285
from crewai_tools.tools.mongodb_vector_search_tool import (
8386
MongoDBToolSchema,
8487
MongoDBVectorSearchConfig,
@@ -218,6 +221,7 @@
218221
"LinkupSearchTool",
219222
"LlamaIndexTool",
220223
"MDXSearchTool",
224+
"MergeAgentHandlerTool",
221225
"MongoDBToolSchema",
222226
"MongoDBVectorSearchConfig",
223227
"MongoDBVectorSearchTool",
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
# MergeAgentHandlerTool Documentation
2+
3+
## Description
4+
5+
This tool is a wrapper around the Merge Agent Handler platform and gives your agent access to third-party tools and integrations via the Model Context Protocol (MCP). Merge Agent Handler securely manages authentication, permissions, and monitoring of all tool interactions across platforms like Linear, Jira, Slack, GitHub, and many more.
6+
7+
## Installation
8+
9+
### Step 1: Set up a virtual environment (recommended)
10+
11+
It's recommended to use a virtual environment to avoid conflicts with other packages:
12+
13+
```shell
14+
# Create a virtual environment
15+
python3 -m venv venv
16+
17+
# Activate the virtual environment
18+
# On macOS/Linux:
19+
source venv/bin/activate
20+
21+
# On Windows:
22+
# venv\Scripts\activate
23+
```
24+
25+
### Step 2: Install CrewAI Tools
26+
27+
To incorporate this tool into your project, install CrewAI with tools support:
28+
29+
```shell
30+
pip install 'crewai[tools]'
31+
```
32+
33+
### Step 3: Set up your Agent Handler credentials
34+
35+
You'll need to set up your Agent Handler API key. You can get your API key from the [Agent Handler dashboard](https://ah.merge.dev).
36+
37+
```shell
38+
# Set the API key in your current terminal session
39+
export AGENT_HANDLER_API_KEY='your-api-key-here'
40+
41+
# Or add it to your shell profile for persistence (e.g., ~/.bashrc, ~/.zshrc)
42+
echo "export AGENT_HANDLER_API_KEY='your-api-key-here'" >> ~/.zshrc
43+
source ~/.zshrc
44+
```
45+
46+
**Alternative: Use a `.env` file**
47+
48+
You can also use a `.env` file in your project directory:
49+
50+
```shell
51+
# Create a .env file
52+
echo "AGENT_HANDLER_API_KEY=your-api-key-here" > .env
53+
54+
# Load it in your Python script
55+
from dotenv import load_dotenv
56+
load_dotenv()
57+
```
58+
59+
**Note**: Make sure to add `.env` to your `.gitignore` to avoid committing secrets!
60+
61+
## Prerequisites
62+
63+
Before using this tool, you need to:
64+
65+
1. **Create a Tool Pack** in Agent Handler with the connectors and tools you want to use
66+
2. **Register a User** who will be executing the tools
67+
3. **Authenticate connectors** for the registered user (using Agent Handler Link)
68+
69+
You can do this via the [Agent Handler dashboard](https://ah.merge.dev) or the [Agent Handler API](https://docs.ah.merge.dev).
70+
71+
## Example Usage
72+
73+
### Example 1: Using a specific tool
74+
75+
The following example demonstrates how to initialize a specific tool and use it with a CrewAI agent:
76+
77+
```python
78+
from crewai_tools import MergeAgentHandlerTool
79+
from crewai import Agent, Task
80+
81+
# Initialize a specific tool
82+
create_issue_tool = MergeAgentHandlerTool.from_tool_name(
83+
tool_name="linear__create_issue",
84+
tool_pack_id="134e0111-0f67-44f6-98f0-597000290bb3",
85+
registered_user_id="91b2b905-e866-40c8-8be2-efe53827a0aa"
86+
)
87+
88+
# Define agent with the tool
89+
project_manager = Agent(
90+
role="Project Manager",
91+
goal="Create and manage project tasks efficiently",
92+
backstory=(
93+
"You are an experienced project manager who tracks tasks "
94+
"and issues across various project management tools."
95+
),
96+
verbose=True,
97+
tools=[create_issue_tool],
98+
)
99+
100+
# Execute task
101+
task = Task(
102+
description="Create a new issue in Linear titled 'Implement user authentication' with high priority",
103+
agent=project_manager,
104+
expected_output="Confirmation that the issue was created with its ID",
105+
)
106+
107+
task.execute()
108+
```
109+
110+
### Example 2: Loading all tools from a Tool Pack
111+
112+
You can load all tools from a Tool Pack at once:
113+
114+
```python
115+
from crewai_tools import MergeAgentHandlerTool
116+
from crewai import Agent, Task
117+
118+
# Load all tools from a Tool Pack
119+
tools = MergeAgentHandlerTool.from_tool_pack(
120+
tool_pack_id="134e0111-0f67-44f6-98f0-597000290bb3",
121+
registered_user_id="91b2b905-e866-40c8-8be2-efe53827a0aa"
122+
)
123+
124+
# Define agent with all tools
125+
support_agent = Agent(
126+
role="Support Engineer",
127+
goal="Handle customer support requests across multiple platforms",
128+
backstory=(
129+
"You are a skilled support engineer who can access customer "
130+
"data and create tickets across various support tools."
131+
),
132+
verbose=True,
133+
tools=tools,
134+
)
135+
```
136+
137+
### Example 3: Loading specific tools from a Tool Pack
138+
139+
You can also load only specific tools from a Tool Pack:
140+
141+
```python
142+
from crewai_tools import MergeAgentHandlerTool
143+
144+
# Load only specific tools
145+
tools = MergeAgentHandlerTool.from_tool_pack(
146+
tool_pack_id="134e0111-0f67-44f6-98f0-597000290bb3",
147+
registered_user_id="91b2b905-e866-40c8-8be2-efe53827a0aa",
148+
tool_names=["linear__create_issue", "linear__get_issues", "slack__send_message"]
149+
)
150+
```
151+
152+
### Example 4: Using with local/staging environment
153+
154+
For development, you can point to a different Agent Handler environment:
155+
156+
```python
157+
from crewai_tools import MergeAgentHandlerTool
158+
159+
# Use with local or staging environment
160+
tool = MergeAgentHandlerTool.from_tool_name(
161+
tool_name="linear__create_issue",
162+
tool_pack_id="your-tool-pack-id",
163+
registered_user_id="your-user-id",
164+
base_url="http://localhost:8000" # or your staging URL
165+
)
166+
```
167+
168+
## API Reference
169+
170+
### Class Methods
171+
172+
#### `from_tool_name()`
173+
174+
Create a single tool instance for a specific tool.
175+
176+
**Parameters:**
177+
- `tool_name` (str): Name of the tool (e.g., "linear__create_issue")
178+
- `tool_pack_id` (str): UUID of the Tool Pack
179+
- `registered_user_id` (str): UUID or origin_id of the registered user
180+
- `base_url` (str, optional): Base URL for Agent Handler API (defaults to "https://api.ah.merge.dev")
181+
182+
**Returns:** `MergeAgentHandlerTool` instance
183+
184+
#### `from_tool_pack()`
185+
186+
Create multiple tool instances from a Tool Pack.
187+
188+
**Parameters:**
189+
- `tool_pack_id` (str): UUID of the Tool Pack
190+
- `registered_user_id` (str): UUID or origin_id of the registered user
191+
- `tool_names` (List[str], optional): List of specific tool names to load. If None, loads all tools.
192+
- `base_url` (str, optional): Base URL for Agent Handler API (defaults to "https://api.ah.merge.dev")
193+
194+
**Returns:** `List[MergeAgentHandlerTool]` instances
195+
196+
## Available Connectors
197+
198+
Merge Agent Handler supports 100+ integrations including:
199+
200+
**Project Management:** Linear, Jira, Asana, Monday, ClickUp, Height, Shortcut
201+
202+
**Communication:** Slack, Microsoft Teams, Discord
203+
204+
**CRM:** Salesforce, HubSpot, Pipedrive
205+
206+
**Development:** GitHub, GitLab, Bitbucket
207+
208+
**Documentation:** Notion, Confluence, Google Docs
209+
210+
**And many more...**
211+
212+
For a complete list of available connectors and tools, visit the [Agent Handler documentation](https://docs.ah.merge.dev).
213+
214+
## Authentication
215+
216+
Agent Handler handles all authentication for you. Users authenticate to third-party services via Agent Handler Link, and the platform securely manages tokens and credentials. Your agents can then execute tools without worrying about authentication details.
217+
218+
## Security
219+
220+
All tool executions are:
221+
- **Logged and monitored** for audit trails
222+
- **Scanned for PII** to prevent sensitive data leaks
223+
- **Rate limited** based on your plan
224+
- **Permission-controlled** at the user and organization level
225+
226+
## Support
227+
228+
For questions or issues:
229+
- 📚 [Documentation](https://docs.ah.merge.dev)
230+
- 💬 [Discord Community](https://merge.dev/discord)
231+
- 📧 [Support Email](mailto:[email protected])
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Merge Agent Handler tool for CrewAI."""
2+
3+
from crewai_tools.tools.merge_agent_handler_tool.merge_agent_handler_tool import (
4+
MergeAgentHandlerTool,
5+
)
6+
7+
8+
__all__ = ["MergeAgentHandlerTool"]

0 commit comments

Comments
 (0)