from crewai import Agent, Task, Crew, Process
from crewai.mcp import MCPServerHTTP
xquik_mcp = MCPServerHTTP(
url="https://xquik.com/mcp",
headers={"x-api-key": "xq_YOUR_KEY_HERE"},
)
researcher = Agent(
role="X Researcher",
goal="Gather raw data from X about a given topic",
backstory="Data collection specialist who finds relevant tweets and profiles",
mcps=[xquik_mcp],
)
analyst = Agent(
role="Engagement Analyst",
goal="Analyze engagement patterns and identify trends",
backstory="Data analyst who turns raw social data into actionable insights",
mcps=[xquik_mcp],
)
writer = Agent(
role="Report Writer",
goal="Write a concise executive summary from the analysis",
backstory="Technical writer who creates clear, data-driven reports",
)
research_task = Task(
description="Search X for tweets about '{topic}' from the last 24 hours. Collect the top 20 by engagement.",
expected_output="Raw tweet data with engagement metrics",
agent=researcher,
)
analysis_task = Task(
description="Analyze the collected tweets. Identify sentiment distribution, peak posting times, and top contributors.",
expected_output="Structured analysis with charts-ready data",
agent=analyst,
)
report_task = Task(
description="Write a 3-paragraph executive summary of the findings.",
expected_output="Executive summary in markdown format",
agent=writer,
)
crew = Crew(
agents=[researcher, analyst, writer],
tasks=[research_task, analysis_task, report_task],
process=Process.sequential,
verbose=True,
)
result = crew.kickoff(inputs={"topic": "AI agents"})
print(result)