179 questions
No questions match those filters.
How does an agent discover MCP tools at runtime, and wh...
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansThe discovery mechanism is what makes MCP genuinely plug-and-play, and also what makes it exploitable if left fully open.
The flow:
- The MCP client (the agent side) connects to a server over stdio or HTTP/SSE.
- Both sides negotiate capabilities during initialization.
- The client requests the tool list; the server responds with each tool’s name, description, and JSON input schema.
- The client folds those schemas directly into the model’s context — this is the step where the model “learns” what tools exist.
- The model decides, at runtime, whether and when to call one.
- The client relays the call to the server, gets a result, and passes it back to the model as an observation.
Why open discovery is the risk, not just the tool call itself. If an agent is free to connect to and enumerate any server it’s pointed at, discovery is itself an attack surface: an attacker needs only to get one malicious server into the discovery path and register a plausible tool description, and the agent will treat that description as trustworthy input with no human ever having reviewed it — this is the entry point tool-poisoning attacks actually use.
The fix in production is a static allowlist, not disabling discovery altogether. A fixed, reviewed set of server endpoints is allowed to be discovered from; anything outside that set is rejected before its schema ever reaches the model. You keep the flexibility of letting approved servers expose or update their own tool sets without new integration code — you just remove the ability for an unvetted server to enter the conversation at all.