Preventing Hallucinations with MCP: Verify Before Writing

Ensure accuracy in MCP workflows by verifying data before using it. This accuracy guide shows you when to call tools to verify task details, how to cite sources from tool output, and how to avoid invented statuses, dates, and other hallucinated information.

What This Guide Covers

This guide teaches you to prevent hallucinations in MCP workflows:

Key Topics

  • Verification patterns: When to call tools to verify data
  • Citation methods: How to cite sources from tool output
  • Hallucination prevention: Avoid invented statuses, dates, IDs
  • Assistant checklist: Steps to ensure accuracy
  • Best practices: Patterns that prevent errors

When to Verify Task Details

Before Writing Operations

Always verify task details before updating or creating:

Safe Update Pattern

"Before updating task [Task ID], first get the current task details using get_task. Show me the current status, assignee, and due date. Then I'll tell you what to change."

What the AI does:

  1. Calls get_task to fetch current state
  2. Shows actual task details (not assumed)
  3. Uses verified data for updates
  4. Prevents updating wrong task or using wrong status

Before Reporting

Verify data before including it in reports:

Accurate Reporting Pattern

"Generate a status report from my Corcava tasks. For each task mentioned, call get_task to verify the current status and due date before including it in the report."

What the AI does:

  1. Calls list_tasks to get task list
  2. For key tasks, calls get_task to verify details
  3. Uses verified data in report
  4. Cites source: "According to task data retrieved at [time]"

Citing Sources from Tool Output

Always cite where information came from:

Citation Pattern

"List my tasks due this week. For each task, cite the source by saying 'According to the task data retrieved from Corcava:' before listing details."

What the AI does:

  1. Calls list_tasks to get data
  2. Formats output with citations
  3. Shows: "According to Corcava task data: [details]"
  4. Makes source clear to user

Example: Cited Report

Report with Citations

Status Report (with citations):

According to task data retrieved from Corcava at 10:00 AM:

  • Task "Implement auth" - Status: in_progress (verified via get_task)
  • Task "API refactor" - Status: open (verified via get_task)

This pattern: Makes source clear, shows verification happened

Avoiding Invented Information

Common Hallucinations

⚠️ What to Avoid

  • Invented statuses: Don't assume task status—always fetch it
  • Made-up dates: Don't infer due dates—get them from task data
  • Wrong IDs: Don't guess IDs—always list and select
  • Assumed assignees: Don't assume who's assigned—verify
  • Inferred progress: Don't guess completion—check actual status

Prevention Patterns

Always Verify Pattern

"When generating a status report, only use information from tool calls. If you don't have data from a tool call, say 'Information not available' rather than guessing."

Benefits:

  • Prevents inventing information
  • Forces tool calls for data
  • Makes missing data explicit

Assistant Checklist

Accuracy Checklist for Assistants

  1. Verify before write: Always call get_task/get_project before updating
  2. Cite sources: Always mention where data came from (tool call output)
  3. No assumptions: Never assume status, date, assignee—always fetch
  4. Verify IDs: Always list items to find correct IDs, don't guess
  5. Check timestamps: Note when data was retrieved (may be stale)
  6. Handle missing data: Say "not available" rather than inventing
  7. Double-check critical info: For important operations, verify twice

Complete Examples

Example 1: Safe Status Update

Complete Safe Update Prompt

"I want to update task [Task ID] status to 'in_progress'. First, call get_task to get the current task details. Show me: - Current status (from tool output) - Task title (from tool output) - Project name (from tool output) Then confirm this is the right task. Only then update the status. Don't assume the current status—always get it from the tool."

This pattern: Verify → Show → Confirm → Update

Example 2: Accurate Status Report

Complete Accurate Report Prompt

"Generate a status report from my Corcava tasks due this week. For each task in the report: 1. Call get_task to verify current status and due date 2. Cite the source: 'According to task data retrieved at [time]' 3. Only include information from tool calls 4. If any data is missing, say 'Information not available' Don't assume or invent any task details."

This pattern: Verify each task → Cite sources → No assumptions

Best Practices

Hallucination Prevention Best Practices

  • Always verify: Call tools to get current data before using it
  • Cite sources: Always mention where information came from
  • No assumptions: Never assume status, dates, or other details
  • Handle missing data: Explicitly state when data is unavailable
  • Verify IDs: Always list items to find correct IDs
  • Double-check critical: For important operations, verify twice
  • Note timestamps: Include when data was retrieved

Troubleshooting

AI Inventing Information

Symptom: AI reports statuses or dates that don't match reality

Fix:

  • Explicitly require tool calls: "Call get_task to verify"
  • Forbid assumptions: "Don't assume, always fetch"
  • Require citations: "Cite source for all information"

Stale Data in Reports

Symptom: Report shows outdated information

Fix:

  • Require fresh data: "Call get_task to get current status"
  • Include timestamps: "Note when data was retrieved"
  • Verify before reporting: "Verify each task before including"

Related Resources

Prevent Hallucinations in MCP

Use verification patterns and citations to ensure accuracy