1 minute read

MCP = LLM lifeline when models hallucinate most.

Image 03

Hallucination Triggers (Use MCP)

1. Knowledge Beyond Cutoff

❌ “2026 Q1 earnings?” → “Made up numbers”

✅ MCP: get_earnings(“2026‑Q1”) → Real API/DB

2. Ambiguous/Edge Prompts

❌ “Fix login bug” → Generic broken code

✅ MCP: validate_user_login(email, password) → Your auth logic

3. High Temperature/Creative

❌ Temp=1.0 → Creative but wrong test cases

✅ MCP: generate_test_cases(product_id) → Your test suite

MCP Shines Here

Scenario Without MCP With MCP
Real‑time data “Stock price?” → stale/guess get_stock_price("AAPL")
Private data “My Q4 sales?” → hallucinated get_user_sales(user_id)
Complex logic “Risk score?” → simple formula calculate_risk_score(params)
Test automation “Edge cases?” → invented get_edge_cases(product)

Code Patterns

Real‑time external data:

@mcp.tool()
def current_weather(city: str) -> dict:
    return api.openmeteo(city)  # Fresh data every call

User‑specific data:

@mcp.tool()
def user_orders(user_id: str) -> list:
    return db.user_orders(user_id)  # Private data

Business logic:

// Schema enforces valid inputs
{
  "risk_score": {
    "inputSchema": {
      "properties": {
        "age": {"type": "number", "minimum": 18},
        "income": {"type": "number", "minimum": 0}
      }
    }
  }
}

Don’t Use MCP When

  • Static knowledge (Shakespeare quotes)
  • Pure generation (creative writing)
  • Simple math (2+2)

MCP = External truth + complex logic.

Call‑to‑Action

“Know WHEN to use MCP. Next: WHERE hallucinations hide worst.”

References