AI agent interview questions and answers
Questions on designing and running agents: tools, the agent loop, permissions, context, multi-agent systems, security and evaluation.
Conformance checks, tool design for models, SDKs and deployment.
What would a real client test catch that the handler's own unit test might miss?
Handler tests check business behavior with direct inputs. Protocol and conformance tests add message shape, discovery, transport, and compatibility checks to that evidence.
Unit test exercises one handler's result
Client test sends an actual protocol exchange
Conformance check compares deployed behavior against the contract
Unit test exercises one handler's result
Client test sends an actual protocol exchange
Conformance check compares deployed behavior against the contract
Given Unit test exercises one handler's result and Conformance check compares deployed behavior against the contract, write down the missing step that connects them.
Client test sends an actual protocol exchange
Now take Client test sends an actual protocol exchange and the result above. Write an input and an implementation that could produce this trace.
Unit test exercises one handler's result. Check that your implementation produces the result shown above.
A handler test shows two pages of reports, but a client receives only one. Where should you investigate first?
Check the second request made by the client and the cursor in the first response. The defect may be in how the protocol passes page state even though direct handler calls work.
Check this when debugging. Mapping every API endpoint to its own tool.
A server that works with one host on your laptop isn't done. It has to work with every host, keep working as the protocol evolves, and actually help models get tasks done. That last part is a design problem as much as a coding one. This lesson covers how professionals test servers, the tool design habits that separate useful servers from frustrating ones, and how servers get packaged, found and run.
Protocol tests that send whole JSON-RPC messages
Unit tests check each tool's logic; only tests that speak the protocol end to end check behavior like ids, notifications and errors, which every client depends on.
This rests on Build a client: a test plays a client's part. It sends a message, reads the reply and matches it by id, then compares what it got with what the protocol requires.
A car maker tests each part, then the assembled engine, then runs a standard road test that every car must pass. Servers get the same three levels:
server/discover work, does an unknown method give -32601, does a missing _meta give -32602? Run them in CI, so a refactor can't silently break compatibility.For poking at a server by hand, the MCP Inspector is a developer tool that connects to a server and lets you browse and call its tools, resources and prompts in a browser:
npx @modelcontextprotocol/inspector uv run shop_server.py
Finally, take it for a test drive: a real host, with a real model, on real tasks. That's where you learn whether the tools are well designed.
pending = {12: "tools/list", 13: "tools/call"}
def on_reply(reply):
return pending.pop(reply["id"], "ignored")
print(on_reply({"id": 13, "result": {}}), on_reply({"id": 12, "result": {}}),
on_reply({"id": 99, "result": {}}), len(pending))tools/call tools/list ignored 0
The reply to 13 arrives first and still finds its own request, and then 12 finds its own. A reply to an id nobody asked about is dropped, and the table ends up empty. A test for a server plays this client's part: send a message, read the reply, match it by id.
def handle(msg): if msg.get("method") == "server/discover": return {"id": msg["id"], "result": {"supportedVersions": ["2026-07-28"]}} return {"id": msg["id"], "error": {"code": -32601}} print(handle({"id": 9, "method": "nope"})["error"]["code"])
-32601
The method isn't "server/discover", so the reply carries the error, and ["error"]["code"] reads -32601. A protocol test feeds in a whole message and checks the reply's error code.
Protocol tests: whole JSON-RPC messages through an in-memory transport
Handler tests call tool functions directly, so they never see notifications. Protocol tests check the message handling itself.
A model only knows your tools through their names, descriptions and schemas, and it pays in tokens for every result. Ask a waiter what's good tonight and you want a recommendation, not the supplier list. The habits that work:
campaign_report(name) tool than with a chain of list_campaigns, get_campaign and get_metrics calls.Wrong calls fail fast, with a clear message
A call with a bad value is refused straight away and the model can correct itself, instead of the tool doing something odd.
detail parameter ("summary" or "full"). Include ids the model will need for follow-up calls.isError results for these, not protocol errors.In plain words: design tools for what people ask, and read how the model uses them.
Tools that mirror your API make the model do the joining. Count what it takes to answer "where's Ann's order?" with each design.
CUSTOMERS = {"ann@shop.example": "c1"}
ORDERS = {"c1": ["o9"]}
STATUS = {"o9": "shipped"}
calls = []
def find_customer(email):
calls.append("find_customer"); return CUSTOMERS[email]
def list_orders(customer):
calls.append("list_orders"); return ORDERS[customer]
def get_order(order):
calls.append("get_order"); return STATUS[order]
status = get_order(list_orders(find_customer("ann@shop.example"))[0])
print("API-shaped:", status, "after", len(calls), "tool calls")
calls.clear()
def latest_order_status(email):
calls.append("latest_order_status")
return STATUS[ORDERS[CUSTOMERS[email]][0]]
print("Task-shaped:", latest_order_status("ann@shop.example"), "after", len(calls),
"tool call")Each extra call is another trip to the model, with more waiting, more tokens and another chance to go wrong. Design tools around what people ask for, not around your database tables.
A handful of task-shaped tools (find_contact, log_call, deal_summary) with clear descriptions
Fewer, higher-level tools mean fewer choices, fewer calls per task, and less context spent on definitions.
A probe table drawn as a conversation: four probes against a good server, then one against a faulty one. Each gate is a probe's verdict.
Write a sentence or two, then compare it with a good answer in the lesson.
This part writes a conformance suite that works on any server, and a check that catches a rename before it ships.
Conformance probes are ordinary requests with expected answers. Here are two, run against the live practice server.
import requests URL = "https://api.gradient.test/mcp" GOOD = {"io.modelcontextprotocol/protocolVersion": "2026-07-28", "io.modelcontextprotocol/clientCapabilities": {}} def post(method, meta, id=1, version="2026-07-28"): body = {"jsonrpc": "2.0", "id": id, "method": method, "params": {"_meta": meta}} headers = {"MCP-Protocol-Version": version, "Mcp-Method": method} return requests.post(URL, json=body, headers=headers, timeout=10) r = post("resources/unknown", GOOD) print("unknown method:", r.status_code, r.json()["error"]["code"], "(want 404, -32601)") r = post("tools/list", {**GOOD, "io.modelcontextprotocol/protocolVersion": "1999-01-01"}, version="1999-01-01") err = r.json()["error"] print("bad version:", r.status_code, err["code"], err["data"]["supported"], "(want 400, -32022)")
Each probe sends one request and compares the answer with what the spec requires. A conformance suite is a few dozen of these, run against any server. The exercise builds one that works on any in-memory server.
Protocol behavior every client relies on: error codes, ids, notifications, discovery and versions
Handler tests check your tools; conformance checks your server speaks MCP correctly, whatever its tools are.
Wrapping 35 endpoints as 35 tools overwhelms a model; grouping by resource is a better start. Write by_resource(endpoints): each endpoint is like "GET /customers/{id}/orders". Return a dictionary from the first path segment (customers) to the number of endpoints under it, with keys in alphabetical order.
ENDPOINTS = [
"GET /customers", "GET /customers/{id}", "POST /customers",
"GET /customers/{id}/orders", "GET /orders/{id}", "POST /orders/{id}/refund",
"GET /products",
]
def by_resource(endpoints):
return {}
print(by_resource(ENDPOINTS))
Rename a street, and every map and delivery route that used the old name goes wrong. A tool's name is a public interface. Models, prompts and saved approvals all depend on it, so treat a rename as a breaking change.
After a rename, old clients still call the old name. Write resolve(name, renames, tools): follow renames (old name to new name) until you reach a name in tools, and return it. Raise KeyError if a name leads nowhere, or if the renames loop.
TOOLS = {"search_products", "get_order"}
RENAMES = {"search": "find_products", "find_products": "search_products",
"order": "get_order"}
def resolve(name, renames, tools):
return renames.get(name, name)
print(resolve("search", RENAMES, TOOLS))
Write a sentence or two, then compare it with a good answer in the lesson.
Purpose. The same three levels of tests, written with the official SDK, and what changes when the server is public.
uvx shop-mcp, which installs and runs them in an isolated environment. Node servers are published to npm and run with npx. Many are also published as container images.Renaming a tool
Every host and every prompt that uses the old name stops working. The first number of the version goes up.
Modern MCP is stateless, which makes deployment ordinary web engineering:
ttlMs on list results, so clients don't hammer tools/list.traceparent) in _meta, so one trace can follow a request from the host through your server to the APIs it calls.In an engineer's week. A server release goes out on Friday. The checklist: handler tests green, protocol tests green, the conformance suite green in CI, the version bumped by the rules above, and one real task run in a real host. What goes wrong is a rename in a "small" release. Models, prompts and saved approvals depend on the old name, and nothing in the unit tests fails.
Write a sentence or two, then compare it with a good answer in the lesson.
Start with a short baseline or choose guided, independent, or AI-assisted practice.
What is the MCP Inspector for?
575 lessons in thirteen phases. 176 are free without an account, and a free account opens the rest. See every lesson.
Questions on designing and running agents: tools, the agent loop, permissions, context, multi-agent systems, security and evaluation.
Build a Model Context Protocol client and server, then verify the integration with a compatible host.
Never trained an AI? Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account. Teach it to write