What it is
The Model Context Protocol (MCP) standardizes how an AI host discovers and calls tools, resources, and prompts exposed by external servers. Each tool has a name, description, input schema, and execution handler—and the server remains the sole authoritative security boundary.
Why you need it
An agent can be tricked by ambiguous tool descriptions into picking the wrong action, or manipulated by prompt injection into passing another tenant’s ID as a tool argument.
How it works
- Design mutually exclusive verb-object tool names with explicit exclusion notes.
- Validate incoming tool arguments strictly against schemas before running side effects.
- Resolve caller identity and tenant scope from trusted server context—not model parameters.
- Enforce step limits, loop detection, and human confirmation for destructive operations.
Enforcing tenant scope inside an MCP tool handler
function handleGetTicket(trustedActor, args) {
if (typeof args.ticketId !== "string") throw new Error("Invalid ticketId")
const ticket = tickets.get(args.ticketId)
if (!ticket || ticket.organizationId !== trustedActor.organizationId) {
throw new Error("Ticket not found")
}
return ticket
}Even if a prompt tells the model to pass organizationId: "other-org", the handler ignores client-supplied tenancy and checks trustedActor.organizationId.
Good practices and why
- Expose only context-relevant tools and clearly state when NOT to use similar tools.
- Distinguish terminal tool errors (missing data, forbidden) from transient errors so agent loops stop instead of burning budget.
Common mistakes
- Trusting a model-supplied userEmail or tenantId without server-side verification.
- Giving an agent 30 overlapping tools with vague one-line descriptions.
Try it yourself
Design schemas for lookup_ticket and update_ticket_status, then trace what happens when an untrusted message asks the agent to read another customer’s record or retry a missing-field error repeatedly.
What a successful result looks like
Cross-tenant reads are rejected at the tool boundary, and terminal errors halt the retry loop.
0 / 6000 characters · Saved on this device. Do not include passwords or private data.
Check your understanding
Answer the understanding check correctly to record exercise completion.
Related interview practice
- The agent calls the wrong tool for every ambiguous request. ↗
- The AI agent accessed data it should not have seen. ↗
- The agent kept retrying until it exhausted the budget. ↗
These scenarios add constraints and follow-up questions to the concepts you just learned.
Further reading
Selected primary references · reviewed 2026-10-09. Examples are educational; use your framework’s documented integration guidance when building a deployed system.