category
Building a Hallucination-Free Chatbot with MCP Agents and CrewAI
Vibe: A practical walkthrough for builders who want their AI agents to actually tell the truth
The Problem: AI That Makes Stuff Up
You've probably seen it happen. You ask an AI assistant a question. It gives you a confident, polished answer. And then you fact-check it and realize half the details were completely made up.
This is hallucination — the AI's tendency to generate plausible-sounding but false information.
For a chatbot that needs to search databases, browse the web, and provide reliable answers, this is a dealbreaker. Especially if you're in a regulated industry or building something people actually depend on.
So how do you fix it?
Enter MCP (Model Context Protocol) and CrewAI — a combination that lets you build agents that actually verify their facts before speaking.
What We're Building
A multi-agent chatbot that:
- Understands user questions and determines what information is needed
- Searches multiple sources (your internal database, the web, verified knowledge bases)
- Verifies facts against trusted sources
- Cross-checks to prevent hallucinations
- Delivers answers with citations and confidence scores
All powered by CrewAI with MCP servers as the tool interface.
Quick Primer: MCP and CrewAI
Model Context Protocol (MCP) is a standard way for AI agents to connect to external tools and data sources. Think of it as a universal plug for your AI — instead of writing custom integrations for every database or API, you connect via MCP and the tools are automatically discovered.
CrewAI is a framework for orchestrating multiple AI agents that work together as a "crew". Each agent has a specific role, and they collaborate to complete complex tasks.
When you combine them, MCP servers become tools that CrewAI agents can use.
from crewai import Agent
agent = Agent(
role="Research Assistant",
goal="Help with research and analysis tasks",
backstory="Expert assistant with access to advanced research tools",
mcps=[
"https://mcp.exa.ai/mcp?api_key=your_key&profile=research"
]
)
# MCP tools are now automatically available!
That's the beauty of it — one line of configuration gives your agent access to an entire suite of tools.
The Hallucination-Fighting Architecture
Here's how we structure our chatbot crew to minimize hallucinations:
Agent 1: The Router
Role: Query Interpreter and Router Goal: Analyze the user's question and identify which tools are needed
This agent uses a technique called tool filtering — it examines the prompt and returns only the 2-3 most relevant tools instead of dumping all available tools into the context.
Why this matters: If an MCP server has 63 tools and you give all of them to an agent, you'll hit context window limits and confuse the model. Selecting only relevant tools keeps the agent focused and prevents it from "reaching" for unrelated capabilities.
Agent 2: The Searcher
Role: Multi-Source Researcher Goal: Gather information from databases, web, and verified knowledge bases
This agent uses:
- Database search tools (via MCP server connected to your internal docs)
- Web search tools (like Tavily or Exa for current information)
- Verified knowledge bases (like Swiss Truth MCP for certified facts)
The key here is reducing the agent's scope — if you remove its ability to browse the web freely and instead force it to use specific search tools, you get more reliable results.
Agent 3: The Verifier
Role: Fact Checker and Citation Expert Goal: Verify all claims against source data before passing to the final agent
This is your secret weapon against hallucinations. The verifier:
- Checks each claim against the original source data
- Assigns confidence scores to facts
- Rejects unverified claims
- Formats citations with source URLs
Services like Swiss Truth are built specifically for this — they provide a verified knowledge base with SHA256 integrity hashes and confidence scores on every fact.
Agent 4: The Writer
Role: Final Report Generator Goal: Present verified information clearly with citations
This agent only uses data that has been verified by the previous agent. It adds structure and readability but never introduces new facts.
Preventing Hallucinations: Practical Techniques
Based on real community experience building MCP agents, here are the most effective techniques:
1. Reduce Agent Scope
When agents have too many capabilities, they get confused and start inventing. Limit each agent to a specific role with specific tools.
"When I get hallucinations I tend to reduce the scope of the crew. Sometimes I remove the ability for a crew to use Google or Web browsing so it can only work with the tool." — CrewAI community member
2. Tool Filtering
MCP servers often expose dozens of tools. Use CrewAI's tool filtering to give each agent only what it needs:
# Get only the search tool from Exa
"https://mcp.exa.ai/mcp?api_key=key#web_search_exa"
# Get only specific tools from a server
"https://weather.api.com/mcp#get_forecast"
This prevents context overload and keeps the agent focused.
3. Multi-Agent Pipelines with Context Passing
Use CrewAI's sequential process with explicit context passing. Each agent passes its verified output to the next agent via the context parameter:
search_task = Task(description="Search for topic", agent=researcher)
verify_task = Task(
description="Verify facts",
agent=verifier,
context=[search_task] # Only verified data flows through
)
write_task = Task(
description="Write report",
agent=writer,
context=[verify_task] # Writer only sees verified info
)
This deterministic flow ensures each agent builds on verified data, not the agent's own "imagination".
4. Use Verified Knowledge Bases
Tools like Swiss Truth MCP provide a foundation of certified facts that agents can rely on:
- 2,000+ certified facts across 30 domains
- 5-stage validation pipeline (AI pre-screen, URL verification, expert review, peer review)
- SHA256 integrity hashes for every fact
- Confidence scores and source URLs
- EU AI Act compliant
This gives your agent a trusted source of truth to anchor its answers.
Sample Implementation: A Research Chatbot
Here's a complete example of a multi-source research chatbot using MCP and CrewAI:
from crewai import Agent, Task, Crew, Process
# Create agent with multiple MCP sources
multi_source_agent = Agent(
role="Multi-Source Research Analyst",
goal="Conduct comprehensive research using multiple verified data sources",
backstory="Expert researcher with access to web search, verified knowledge bases, and internal databases",
mcps=[
"https://mcp.exa.ai/mcp?api_key=exa_key&profile=research",
"https://swisstruth.org/mcp", # Verified knowledge base
"https://your-internal-db.com/mcp", # Your own data
"github#search_repositories" # Connected MCP from catalog
]
)
# Create research task with strict verification requirement
research_task = Task(
description="""Research the impact of AI agents on business productivity.
Use verified knowledge base for foundational facts.
Cross-check web sources against verified data.
Include citations and confidence scores for every claim.""",
expected_output="""Comprehensive report covering:
1. Key findings with citations
2. Confidence scores for each claim
3. Source verification status
4. Unverified claims clearly flagged""",
agent=multi_source_agent
)
# Execute the crew
research_crew = Crew(
agents=[multi_source_agent],
tasks=[research_task],
process=Process.sequential,
verbose=True
)
result = research_crew.kickoff()
For Specific Use Cases
Customer Support Chatbot
Integrate an MCP server connected to your knowledge base and ticketing system. Use a Router agent to identify the user's issue, a Search agent to pull relevant documentation, and a Verifier agent to ensure the response matches official sources before answering.
Financial Research Assistant
Use MCP servers for financial data (like DataForSEO for SEO metrics) with a separate Verifier agent to cross-check against source data. The community has encountered issues where agents hallucinate metrics even when the API returns correct data — a Verifier agent that compares outputs to source responses solves this.
Technical Documentation Assistant
Projects like Docs-ForAI use MCP to index documentation for LangChain, CrewAI, AutoGen, and more. Agents can pull verified, up-to-date documentation instead of relying on training data that might be outdated.
The Bottom Line
Building a reliable, hallucination-free chatbot isn't about having a smarter model. It's about architecture.
With MCP and CrewAI, you can:
- Connect your agent to verified data sources
- Route queries to the right tools
- Verify every fact before it reaches the user
- Provide citations and confidence scores so users know what to trust
The model is still the model — it's going to try to be helpful, which sometimes means making things up. Your job is to build a system that catches those fabrications before they reach the user.
MCP gives you the tools. CrewAI gives you the orchestration. Together, they give you a chatbot you can actually trust.
Need Help Building Your AI Agent?
We get it. MCP is new. CrewAI is powerful but complex. And building a production-grade, hallucination-free chatbot takes more than just reading a blog post.
At Quopa.io, we help teams:
- Design and architect multi-agent systems
- Integrate MCP servers with your existing data sources
- Build verification pipelines that actually prevent hallucinations
- Deploy and scale AI agents in production
- Staff projects with engineers who have real MCP and CrewAI experience
Whether you need a single consultant, a full team, or just someone to review your architecture, we've got you covered.
Ready to build an AI agent you can trust?
Tell us what you're building, and we'll help you figure out the right approach. No pressure. Just honest advice.
Enjoyed this post? Share it with your team. Or reach out — we love talking about this stuff.
Table of Contents
- The Problem: AI That Makes Stuff Up
- What We're Building
- Quick Primer: MCP and CrewAI
- The Hallucination-Fighting Architecture
- Preventing Hallucinations: Practical Techniques
- Sample Implementation: A Research Chatbot
- For Specific Use Cases
- The Bottom Line
- Need Help Building Your AI Agent?
Trending
category
Table of Contents
- The Problem: AI That Makes Stuff Up
- What We're Building
- Quick Primer: MCP and CrewAI
- The Hallucination-Fighting Architecture
- Preventing Hallucinations: Practical Techniques
- Sample Implementation: A Research Chatbot
- For Specific Use Cases
- The Bottom Line
- Need Help Building Your AI Agent?
