You are exposing retrieval as a tool to an agent, over MCP. How does designing a tool interface differ from designing a retrieval API?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
The consumer is a model with a token budget and no ability to read documentation, so the interface design is the quality work. A retrieval API optimizes for what a programmer can compose. A tool interface optimizes for what a model will call correctly on the first try, and the failure modes are different.
Full worked answer with diagram
The consumer is a model with a token budget and no ability to read documentation, so the interface design is the quality work. A retrieval API optimizes for what a programmer can compose. A tool interface optimizes for what a model will call correctly on the first try, and the failure modes are different.
What changes:
The description is the prompt. The tool description is not documentation, it is the instruction that determines whether the model calls it, and when. A vague 'searches the knowledge base' produces a model that calls it for everything or nothing. It needs to say what is in the corpus, what is not, and when to prefer it. This is where almost all the tuning happens, and it is genuinely more impactful than the retrieval config behind it.
Fewer tools, not more. The instinct is one tool per corpus: search_docs, search_tickets, search_code, search_crm. Past a handful, selection accuracy degrades and the model picks wrong. Prefer one search with a source enum, which turns a tool-selection problem into an argument-selection problem that models handle better.
Results are context, and context is the budget. Every returned token competes with the model's reasoning space. Return ~3-5 focused results with snippets, not 20 full chunks. Include a stable ID and support a separate fetch(id) for the full document. That two-step, search returns snippets, fetch expands the interesting one, mirrors how the model actually works and keeps the loop cheap.
Errors must be instructive. 'No results' is a dead end. 'No results for X. This corpus covers 2023 onward; try a broader query' tells the model what to do next. Tool errors are prompts too.
Determinism and idempotency. The model will retry. Same query, same results.
The MCP-specific trap: identity. An MCP server is a separate process, often a remote service. The retrieval tool must enforce the end user's permissions, not the server's service account. For remote servers the MCP authorization spec builds on OAuth 2.1: the server validates an access token issued for it and derives the user from that token, and it never trusts a user ID the model wrote into the tool arguments, because the model controls those. The spec also forbids passing the client's token straight through to downstream APIs, so the server either obtains its own downstream credential for that user or applies the ACL filter itself. A retrieval tool with ambient service-account credentials means any user can exfiltrate any document by asking nicely. That is the failure I would review for first.
Worth sketching. The two-step search-then-fetch, with identity entering at the tool boundary, is the whole design in one picture.
flowchart LR
M["Model"] -->|"search: query plus source enum"| T["Retrieval tool"]
T --> ID["Resolve the end user from the<br/>validated access token, never a tool argument"]
ID --> F["ACL-filtered retrieval"]
F --> S["3-5 snippets<br/>with stable IDs"]
S --> M
M -->|"fetch by ID, only for the<br/>snippet worth expanding"| T
F -->|"nothing matched"| E["Error naming what the corpus<br/>covers and what to try next"]
E --> M
What a good answer covers
- The consumer is a model with a token budget and no ability to read documentation, so the interface…
- A retrieval API optimizes for what a programmer can compose
- A tool interface optimizes for what a model will call correctly on the first try, and the failure modes…
- The tool description is not documentation, it is the instruction that determines whether the model calls…
- A vague 'searches the knowledge base' produces a model that calls it for everything or nothing
Key terms: What changes · The description is the prompt · Fewer tools, not more · Errors must be instructive · Determinism and idempotency · The MCP-specific trap: identity
In the glossary: Tool description · Accuracy · MCP
Interviewer follow-ups to expect
How would you propagate and verify end-user identity through an MCP tool call to the retrieval filter?
How do you evaluate a retrieval tool, given that the metric is now 'did the agent's task succeed' rather than recall@k?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep