Using a schema-constrained model to pick the right query in an MCP tool, with permission-filtered options, keyword fallback and shadow-mode rollout.

An AI agent facing a long list of queries picks near-misses, probes candidates, or gives up and runs the broadest one. Each wrong pick is a wasted round trip — some expensive.

The fix: classify, don't chat

  • A small, cheap model receives the question plus the query list and returns one pick, constrained by a JSON schema so the response is always parseable.
  • The option list is permission-filtered first — the model never sees queries the caller can't run.
  • A keyword matcher is the fallback when the model is unsure or down. Degraded, not dead.

Rollout: shadow mode first — log what the model would have picked versus what the agent actually used, and only switch when agreement is high.

The lesson: most "AI features" in production are classification problems. A small model with a strict schema beats a large model with a prompt full of hope — cheaper, faster, and testable like any other component.