|
| 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]) |
0 commit comments