> ## Documentation Index
> Fetch the complete documentation index at: https://docs.invokehq.run/llms.txt
> Use this file to discover all available pages before exploring further.

# CrewAI

> Route a CrewAI agent's tool calls through Invoke over MCP: each call checked, recorded as your agent, and receipted.

Your crew keeps its roles, tasks and models. Each agent gets its tools from your Invoke workspace over MCP, so every tool call goes through Invoke.

## Before you start

In the [console](https://console.invokehq.run/sign-in), open **API** and copy two things: the **MCP endpoint** and an **Agent key**. The key belongs to one agent, so every call your agent makes is recorded as that agent's, and it can't act as another.

```bash theme={null}
export INVOKE_MCP_URL=https://api.invokehq.run/v1/workspaces/ws_…/mcp
export INVOKE_API_KEY=inv_live_…
```

**1. Install**

```bash theme={null}
pip install crewai mcp
export OPENAI_API_KEY=sk-…
```

**2. Write the agent**

Save this as `agent.py`:

```python agent.py theme={null}
"""A CrewAI agent whose tool calls go through Invoke.

pip install crewai mcp
export INVOKE_API_KEY=inv_live_...      # your agent's own key
export INVOKE_MCP_URL=https://...       # from `invoke gateway url`
export OPENAI_API_KEY=sk-...
python agent.py
"""
import os
import sys

from crewai import LLM, Agent, Crew, Task
from crewai.mcp import MCPServerHTTP

PROMPT = " ".join(sys.argv[1:]) or (
    "Remember that the staging deploy is frozen until Friday. "
    "Then recall your notes and tell me what you know."
)

invoke = MCPServerHTTP(
    url=os.environ["INVOKE_MCP_URL"],
    headers={"Authorization": f"Bearer {os.environ['INVOKE_API_KEY']}"},
    streamable=True,
)

agent = Agent(
    role="Assistant",
    goal="Do what the user asks, using your tools.",
    backstory="Your tool calls go through Invoke, which checks and records each one.",
    llm=LLM(model=os.environ.get("MODEL", "openai/gpt-5.4-mini")),
    mcps=[invoke],
)
task = Task(description=PROMPT, expected_output="A short answer saying what you did and found.", agent=agent)

print(Crew(agents=[agent], tasks=[task]).kickoff())
```

`MCPServerHTTP` with `streamable=True` connects to the workspace. Give each agent in a crew its own key, so their calls are recorded apart.

**3. Run it**

```bash theme={null}
python agent.py
```

The agent uses Invoke's own memory tools, so it works on a new workspace with nothing connected. You'll see something like:

```text theme={null}
I have saved the note that the staging deploy is frozen until Friday. When I recalled my notes, it was there: "The staging deploy is frozen until Friday."
```

## Give it a real tool

In the console, open **Connectors** and connect a tool: GitHub, Slack, Linear, Notion or any MCP server. Its tools appear to your agent on the next run, with names a model API accepts (a GitHub connector's `create_issue` is listed as `github_create_issue`). Then ask for something that changes the world:

```bash theme={null}
python agent.py "Open an issue in acme/api titled 'Staging deploy frozen until Friday'"
```

Read back what happened with the [CLI](https://docs.invokehq.run/sdk/cli.md):

```bash theme={null}
invoke login --api-key "$INVOKE_API_KEY"
invoke gateway use ws_…        # the id in your MCP endpoint
invoke gateway receipts
```

Each write has a receipt that names your agent. If the agent claims a task first (`invoke_claim_task`), a retried write for that task is answered with its first receipt instead of running twice.

## What happened

* **Your agent acted as itself.** The key is its identity: Invoke records every call as that agent's.
* **Every call was checked before it ran:** the agent's permissions, your workspace's policies and its budget.
* **`invoke_remember` and `invoke_recall` are Invoke's own memory.** Notes an agent keeps across runs. Claiming a task again brings back its history and notes, and the workspace's other agents can read them.

## Other models

`MODEL` takes a CrewAI model string. For Claude, `pip install "crewai[anthropic]"` and set `MODEL=anthropic/claude-opus-5-5`.

## Next steps

* [CLI](https://docs.invokehq.run/sdk/cli.md): connect tools, then read receipts and the event log
* [Authentication](https://docs.invokehq.run/configuration/authentication.md): agent keys and account keys
* [Traces](https://docs.invokehq.run/concepts/traces.md): read a run back stage by stage


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.