Skip to content

CrewAI

Use AllMCP tools in CrewAI agents via langchain-mcp-adapters.


install
pip install crewai langchain-mcp-adapters langchain-anthropic

agent.py
import asyncio
from crewai import Agent, Task, Crew
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_anthropic import ChatAnthropic
async def run_crm_crew():
client = MultiServerMCPClient({
"allmcp": {
"url": "https://go.allmcp.co/mcp/",
"transport": "streamable_http",
"headers": {"X-API-Key": "YOUR_API_KEY"},
}
})
tools = await client.get_tools()
llm = ChatAnthropic(model="claude-sonnet-4-6")
crm_agent = Agent(
role="CRM Analyst",
goal="Analyze sales pipeline and surface actionable insights",
backstory="You are an expert sales analyst with deep CRM knowledge.",
tools=tools,
llm=llm,
verbose=True,
)
task = Task(
description=(
"List all open deals in Bitrix24, group them by stage, "
"and identify the top 3 deals most likely to close this week."
),
expected_output="A ranked list of top 3 deals with reasoning.",
agent=crm_agent,
)
crew = Crew(agents=[crm_agent], tasks=[task], verbose=True)
result = crew.kickoff()
return result
asyncio.run(run_crm_crew())

sales_ops_crew.py
async def run_sales_ops_crew():
client = MultiServerMCPClient({
"allmcp": {
"url": "https://go.allmcp.co/mcp/",
"transport": "streamable_http",
"headers": {"X-API-Key": "YOUR_API_KEY"},
}
})
tools = await client.get_tools()
llm = ChatAnthropic(model="claude-sonnet-4-6")
researcher = Agent(
role="Sales Researcher",
goal="Pull raw data from the CRM",
tools=tools,
llm=llm,
)
analyst = Agent(
role="Sales Analyst",
goal="Identify trends and insights from CRM data",
llm=llm,
)
gather_task = Task(
description="List all leads created in the last 7 days with their source and status.",
expected_output="Raw list of leads with source and status fields.",
agent=researcher,
)
analyze_task = Task(
description="Based on the leads data, identify the top 2 lead sources by conversion rate.",
expected_output="Top 2 lead sources with conversion rates.",
agent=analyst,
context=[gather_task],
)
crew = Crew(
agents=[researcher, analyst],
tasks=[gather_task, analyze_task],
)
return crew.kickoff()

multi_user.py
def make_crew_for_user(user_id: str):
return MultiServerMCPClient({
"allmcp": {
"url": f"https://go.allmcp.co/mcp/?user_id={user_id}",
"transport": "streamable_http",
"headers": {"X-API-Key": "YOUR_API_KEY"},
}
})