# CrewAI

## Install

```bash
pip install crewai "crewai-tools[mcp]"
```

---

## Connect

`MCPServerAdapter` wraps MCP tools as CrewAI-compatible tools. It requires a context manager to manage the connection lifecycle:

```python
from crewai_tools import MCPServerAdapter

MEWCP_API_KEY = "API_KEY"

server_params = {
    "url": "https://gateway.mewcp.com/personal/mcp",
    "transport": "streamable-http",
    "headers": {"Authorization": f"Bearer {MEWCP_API_KEY}"},
}

with MCPServerAdapter(server_params) as mcp_tools:
    print("Available tools:", [t.name for t in mcp_tools])
    # -> ["search", "get_schema", "list_accounts", "call_tool"]
```

> Note: `transport` must be `"streamable-http"` (hyphenated).

You get four tools rather than the tools of each app. Your agent uses them to reach every app you have connected. See [How MewCP works](/mewcp/getting-started#how-mewcp-works).

---

## Call a tool directly

```python
with MCPServerAdapter(server_params) as mcp_tools:
    call_tool = next(t for t in mcp_tools if t.name == "call_tool")

    result = call_tool.run({
        "server_maskedId": "google-calendar",
        "tool_name": "list_events",
        "args": {
            "calendar_id": "primary",
            "time_min": "2026-01-15T00:00:00Z",
            "time_max": "2026-01-16T00:00:00Z",
        },
    })
    print(result)
```

If you have connected more than one account for the same app, add `"alias": "work"` to select one.

---

## Use with a CrewAI agent

Hand all four tools to the agent and let it work out the rest:

```python
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter

server_params = {
    "url": "https://gateway.mewcp.com/personal/mcp",
    "transport": "streamable-http",
    "headers": {"Authorization": f"Bearer {MEWCP_API_KEY}"},
}

with MCPServerAdapter(server_params) as mcp_tools:
    agent = Agent(
        role="Assistant",
        goal="Answer questions using the user's connected apps",
        backstory="Expert at finding and using the right tool for the job.",
        tools=list(mcp_tools),
        verbose=True,
    )
    task = Task(
        description="Check what is on my calendar tomorrow and summarise the day.",
        expected_output="A short summary of tomorrow's schedule.",
        agent=agent,
    )
    crew = Crew(agents=[agent], tasks=[task])
    crew.kickoff()
```

---

## Where to find your values

| Value          | Where to get it       |
| -------------- | --------------------- |
| `API_KEY`      | Dashboard -> API Keys |
| Connected apps | Dashboard -> Servers  |
