AI agent interview questions and answers
Questions on designing and running agents: tools, the agent loop, permissions, context, multi-agent systems, security and evaluation.
A standard way to plug tools and data into any AI app.
What problem does a common tool interface solve when several applications want the same capability?
MCP gives clients and servers a common way to discover and call capabilities. The host connects the model to those capabilities while preserving tool ownership and approval policy.
Host connects a client to a reporting server
Client discovers the server's declared tool
Host maps an approved model proposal into a tool call
Host connects a client to a reporting server
Client discovers the server's declared tool
Host maps an approved model proposal into a tool call
Given Host connects a client to a reporting server and Host maps an approved model proposal into a tool call, write down the missing step that connects them.
Client discovers the server's declared tool
Now take Client discovers the server's declared tool and the result above. Write an input and an implementation that could produce this trace.
Host connects a client to a reporting server. Check that your implementation produces the result shown above.
A reports server publishes a read tool. Does discovery mean the model can execute that tool without the host?
Discovery describes what exists. The host still mediates the action through its client and applies the application's permission rules.
A learning assistant shows a report from a separate campaign service. Name the host, client and server in this interaction. Which component decides whether the assistant may use the report?
The assistant application is the host. Its client holds the protocol connection. The campaign service is the MCP server exposing the report. The host sets its own permissions and the server still authorizes each operation on its side.
Write the method order for a client that starts a connection, discovers the report tool, and calls it with a campaign ID. Which field associates a reply with its request?
Start with initialize, send the initialized notification after a successful response, then use tools/list and tools/call. Set a distinct id on each request. The response echoes that id. The initialized notification has no id and gets no response.
A discovered tool is named get_report and takes a required string campaign_id. List the parts of its description and schema you would preserve when exposing the tool to a model.
Preserve the tool name, description, and object input schema, including the campaign_id property type and required list. Keep the mapping from model-facing names to server names so a returned tool request can call the intended server.
A server bundles read-only reports with the ability to publish a report. A learner only needs to read one campaign. Name two checks that stop this access from granting publishing rights.
Scope the session to reading that campaign and permit only the read operation in the host. The server independently checks resource ownership and operation authorization. A tool description or a hidden button does not enforce a permission boundary.
Check this when debugging. Thinking MCP is a model or replaces tool use (it's a standard way to supply tools).
Without a shared standard, every AI app needs its own custom connection to every tool. Your CRM for Claude. Your CRM again for a code editor. Again for a support bot. The Model Context Protocol (MCP) fixes this. It's an open standard, introduced by Anthropic in 2024 and now widely supported. A tool is written once, as an MCP server, and any app that speaks MCP can use it. When a vendor says "we have an MCP server", this lesson is what that means.
Writing the connector once, as a server any MCP host can use
MCP is a shared standard, like USB for AI tools: a tool written once as an MCP server works in any app that speaks MCP, instead of one custom integration per app.
This lesson rests on Tool use: the model asks for a tool, your code runs it. MCP changes where the tool comes from, not how it is called.
Think of USB. Before it, every printer and keyboard needed its own special port. With USB, one plug fits any computer. MCP is that plug for AI tools.
There are three roles:
Most servers are mostly tools.
A server runs in one of two places. It can run locally, as a program the host starts on your computer. Then they talk through the program's standard input and output ("stdio"). Or it can run remotely, as a web service the host reaches over HTTPS. Either way, the messages are the same.
Locally, over stdio, or remotely, over HTTPS
A local server is a program the host starts on your computer, and they talk through its standard input and output. A remote one is a web service. The messages are the same either way.
MCP messages use JSON-RPC 2.0, a simple format for asking another program to run a function. A request has three parts:
method: the name of what to run,params: its inputs,id: a number to match the answer to the question.The response carries the same id, plus either a result or an error:
{"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}
{"jsonrpc": "2.0", "id": 2, "result": {"tools": [{"name": "get_campaign",
"description": "...", "inputSchema": {...}}]}}
A session goes in this order:
initialize: client and server agree on a protocol version and say what they support.tools/list: the client asks which tools exist. Each has a name, a description and an inputSchema. That's a JSON schema, the same idea as Claude's input_schema.tools/call: the client runs a tool with {"name": ..., "arguments": {...}}. It gets back {"content": [{"type": "text", "text": ...}], "isError": false}.tool = {"name": "get_campaign", "description": "Look up one campaign by its id.",
"input_schema": {"type": "object", "properties": {"id": {"type": "string"}},
"required": ["id"]}}
print(len(tool), tool["input_schema"]["required"])3 ['id']
A tool definition has a name, a description and an input schema: three parts. The schema says the input is an object whose id is required. An MCP server answers a tools/list request with definitions in this same form, which is how one server's tools can be offered to any host.
initialize, then tools/list, then tools/call
First they agree on a protocol version, then the client learns which tools exist and what inputs they take, and only then can it call one.
The academy's practice server at https://api.gradient.test/mcp speaks this format. It's simplified. Real remote servers can also stream, and MCP libraries handle that for you.
Note: This handshake-based flow is what most servers and apps spoke through 2025, and many still do. The newest revision of MCP, dated 2026-07-28, drops the
initializestep. Each request carries its own protocol version in a_metafield instead. Phase 9 covers both.
Three lifelines the learner steps, and a fourth for the model.
import json msg = json.dumps({"jsonrpc": "2.0", "id": 1, "method": "tools/list"}) print(json.loads(msg)["method"])
tools/list
json.dumps turns the dictionary into text, and json.loads turns it back, so ["method"] reads tools/list. Every MCP request is a small JSON object naming a method.
The response carries the same id as the request
The id is the matching number. A request with "id": 2 gets a response with "id": 2, whether it holds a result or an error.
Write a sentence or two, then compare it with a good answer in the lesson.
Purpose. Send the three messages with a small helper, and watch the id rise.
Each call is one POST request with a JSON-RPC body. The widget below sends them one at a time.
JSON-RPC answers can arrive in any order; the id says which request each belongs to. Write match(requests, responses): return a dictionary from each request's method to the result of the response with the same id, or to "error: " plus the error's message if that response has an error.
requests = [
{"jsonrpc": "2.0", "id": 1, "method": "tools/list"},
{"jsonrpc": "2.0", "id": 2, "method": "tools/call"},
]
responses = [
{"jsonrpc": "2.0", "id": 2,
"result": {"content": [{"type": "text", "text": "ROAS 4.1"}]}},
{"jsonrpc": "2.0", "id": 1, "result": {"tools": [{"name": "get_campaign"}]}},
]
def match(requests, responses):
return {r["method"]: s.get("result") for r, s in zip(requests, responses)}
print(match(requests, responses))
Wrap those calls in a small helper, and the protocol turns into ordinary function calls:
import requests def rpc(method, params, id): body = {"jsonrpc": "2.0", "id": id, "method": method, "params": params} return requests.post("https://api.gradient.test/mcp", json=body).json()["result"] info = rpc("initialize", {"protocolVersion": "2025-06-18", "capabilities": {}}, 1) print("server:", info["serverInfo"]["name"], "| protocol:", info["protocolVersion"]) for tool in rpc("tools/list", {}, 2)["tools"]: print("-", tool["name"], "| needs:", tool["inputSchema"].get("required", [])) call = {"name": "search_docs", "arguments": {"query": "gift card expiry"}} print(rpc("tools/call", call, 3)["content"][0]["text"][:90])
The helper rpc builds the body, sends it and returns the reply's result. The code then does the three steps in order: initialize, tools/list and one tools/call.
This is what Claude's apps and other hosts do behind the scenes. It uses only things you already know:
tools/list. Turn each MCP tool into a Claude tool: same name and description, with inputSchema renamed to input_schema.tool_use block, send tools/call to the server, with the block's name and its input as arguments.tool_result. Set is_error when isError is true. Then continue the agent loop.The model doesn't know or care that a tool lives on an MCP server.
Step 1 above, in code. An MCP server describes a tool with inputSchema. Claude's API wants input_schema. Everything else carries over unchanged:
mcp_tool = {"name": "get_campaign", "description": "Get one campaign by id.",
"inputSchema": {"type": "object", "properties": {"id": {"type": "string"}},
"required": ["id"]}}
claude_tool = {"name": mcp_tool["name"], "description": mcp_tool["description"],
"input_schema": mcp_tool["inputSchema"]}
print(sorted(claude_tool))
print(claude_tool["input_schema"]["required"])It prints ['description', 'input_schema', 'name'], then ['id']. The schema itself isn't changed at all, only the key it sits under. A host does this for every tool a server lists.
Connect their tools to any MCP-capable AI app without a custom integration
Write it once, use it from any host that speaks MCP.
Write a sentence or two, then compare it with a good answer in the lesson.
Purpose. Know what a server costs you in context, how it is built, and when not to connect it.
You'll rarely write the JSON-RPC by hand. The official Python SDK (the mcp package, version 2) turns ordinary typed functions into a server, much like the Claude SDK's tool runner. The card shows a server with one tool and reads its schema back.
Each host has its own way to add a server: a settings screen or a config file. For a local server, you list the command that starts it. For a remote one, you give its web address. In Claude Code it's the claude mcp add command. In an engineer's week, the work is mostly choosing which servers to connect and keeping their tool lists short, because every tool's description is paid for on every request and read by the model.
An MCP server runs code and sees what you send it. Its tool descriptions also go straight into the model's context. Before you connect one:
MCP doesn't replace tool use. It's a standard way to supply tools, and the model still asks for them the same way. The newest revision of MCP, dated 2026-07-28, drops initialize; Phase 9 covers it.
Keep approval prompts on and give it a limited key, or prefer a read-only server
A server can do whatever its tools allow when the model asks. Narrow access and approval prompts limit the damage if it misbehaves.
Before connecting a server you found online, list the tools that can change or send things. Write risky_tools(tools): return the names of MCP tools whose name or description contains any of delete, send, pay, update or write (ignoring case), in the server's order.
TOOLS = [
{"name": "search_contacts", "description": "Find contacts by name or email."},
{"name": "send_email", "description": "Email a contact."},
{"name": "get_invoice", "description": "Read an invoice."},
{"name": "tidy_contacts", "description": "Delete duplicate contacts."},
{"name": "set_note", "description": "Write a note on a contact's record."},
]
def risky_tools(tools):
return [t["name"] for t in tools if "send" in t["name"]]
print(risky_tools(TOOLS))
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.
In MCP, what is the "host"?
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.
Learn how to build AI agents by building one: tools, the agent loop, MCP, permissions, context management and evals, ending with a coding agent that stops when its tests pass.
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