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

# CrewAI

> Connect XentFi agent tools to a CrewAI crew via MCPServerAdapter.

CrewAI (Python) consumes MCP servers via `crewai-tools`' `MCPServerAdapter`, which spawns the server over stdio (or connects over SSE/HTTP) and turns its tools into CrewAI `Tool` objects.

<Steps>
  <Step title="Install">
    ```bash theme={null}
    pip install crewai crewai-tools
    npm install -g @xentfi/mcp-server   # so the `xentfi-mcp` binary is on PATH
    ```

    You can skip the global npm install and use `npx -y @xentfi/mcp-server` as the command instead — slightly slower to start, no PATH setup required.
  </Step>

  <Step title="Wire it into a Crew">
    ```python theme={null}
    import os
    from crewai import Agent, Task, Crew
    from crewai_tools import MCPServerAdapter
    from mcp import StdioServerParameters

    xentfi_params = StdioServerParameters(
        command="npx",
        args=["-y", "@xentfi/mcp-server"],
        env={
            **os.environ,
            "XENTFI_API_KEY": os.environ["XENTFI_API_KEY"],

        },
    )

    with MCPServerAdapter(xentfi_params) as xentfi_tools:
        print("Available XentFi tools:", [t.name for t in xentfi_tools])

        treasury_agent = Agent(
            role="Treasury Operator",
            goal="Monitor agent wallet balances and execute approved payments within policy limits",
            backstory="An operations agent responsible for XentFi wallet payments.",
            tools=xentfi_tools,
            verbose=True,
        )

        task = Task(
            description="Check the agent's XentFi policy and wallet balances, then report if any wallet is below 10 USD.",
            expected_output="A short report of each wallet's balance and whether it is below the 10 USD threshold.",
            agent=treasury_agent,
        )

        crew = Crew(agents=[treasury_agent], tasks=[task])
        result = crew.kickoff()
        print(result)
    ```
  </Step>
</Steps>

## Letting an agent actually pay

Give a CrewAI agent the `xentfi_create_payment` tool only if you intend for it to move funds. Because that tool requires `confirm: true`, a good pattern is a two-agent crew:

1. **Planner agent** — decides *what* payment should happen (recipient, asset, amount) and writes it out, without payment tools.
2. **Executor agent** — has only `xentfi_create_payment` (filter the tool list from `xentfi_tools` to just this one) and a task instructing it to call it with `confirm: true` **only if** the planner's output passed your own validation step.

This keeps "decide to pay" and "execute the payment" as separately auditable steps in your Crew, on top of XentFi's own server-side Policy checks.

<Note>
  `MCPServerAdapter` in newer `crewai-tools` versions also supports connecting to a remote server over SSE/Streamable HTTP if you'd rather run `xentfi-mcp-http` centrally and point every Crew at it — see [Remote HTTP Deployment](/agent/http-transport) and pass the `Authorization: Bearer <agent-api-key>` header via that adapter's HTTP params.
</Note>

Tool names arrive in CrewAI unchanged (`xentfi_get_agent_info`, etc.) — reference them by name if you filter/allowlist tools per agent.

## Next steps

<CardGroup cols={2}>
  <Card title="Tools Reference" icon="list" href="/agent/tools-reference">
    See every available tool.
  </Card>

  <Card title="Remote HTTP Deployment" icon="server" href="/agent/http-transport">
    Run one shared XentFi MCP endpoint for every Crew.
  </Card>
</CardGroup>
