Prepare for AI agent developer interviews with 15 Model Context Protocol (MCP) questions covering tools, resources, prompts, JSON-RPC, transports, roots, sampling, security, and practical MCP server design.
Describe the host, client, and server actors in an MCP integration.
MCP separates responsibilities into three roles:
Example flow:
User -> Host -> MCP Client -> MCP Server -> External SystemThe host controls the user experience and consent flow. The server provides capabilities. The client handles protocol messages between them.
Explain Model Context Protocol at a high level and why it is useful in AI applications.
Model Context Protocol (MCP) is an open standard for connecting AI applications to external systems such as databases, files, APIs, tools, and reusable prompt workflows.
Instead of building a custom connector for every model and every tool, MCP defines a common client-server protocol. An AI application can connect to an MCP server and discover what context or actions it exposes.
Common MCP capabilities include:
In interview terms, MCP is similar to a standardized integration layer between AI clients and external systems.
JSON-RPC?Explain the role of JSON-RPC messages in MCP and show an example request.
MCP uses JSON-RPC 2.0 as the message format between clients and servers. Requests include a method name, optional parameters, and an id. Responses return the same id with either a result or an error.
Example tools/list request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}Example response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"tools": [
{
"name": "search_docs",
"description": "Search internal documentation",
"inputSchema": {
"type": "object",
"properties": {
"query": { "type": "string" }
},
"required": ["query"]
}
}
]
}
}Notifications are also JSON-RPC messages, but they do not include an id and do not require a response.
Compare the three main server-side capabilities in MCP: tools, resources, and prompts.
In MCP, tools, resources, and prompts solve different integration problems.
Tools are functions the model can call to perform an action:
{
"name": "create_ticket",
"inputSchema": {
"type": "object",
"properties": {
"title": { "type": "string" }
},
"required": ["title"]
}
}Resources are readable pieces of context, identified by URI:
{
"uri": "db://schema/orders",
"name": "Orders schema",
"mimeType": "application/json"
}Prompts are reusable message templates or workflows selected by the user:
{
"name": "review_pr",
"description": "Review a pull request for correctness and risk"
}Use tools for actions, resources for context, and prompts for guided workflows.
stdio and Streamable HTTP transports in MCP?Compare the stdio and Streamable HTTP transports and when to use each.
MCP defines two common transport styles:
stdio is usually used for local tools. The client starts the MCP server as a subprocess and exchanges newline-delimited JSON-RPC messages over stdin and stdout.
Host process
-> starts local server
-> sends JSON-RPC over stdin
<- receives JSON-RPC over stdoutStreamable HTTP is used when the MCP server runs as an independent HTTP service. The client sends JSON-RPC messages with HTTP POST, and the server may use Server-Sent Events for streaming responses or server-to-client messages.
Use stdio for local developer tools, filesystem integrations, and simple desktop workflows. Use Streamable HTTP for remote services, shared infrastructure, and multi-client deployments.
API and MCP?Explain when to use a traditional API and when to expose functionality through MCP.
An API is a general contract for software-to-software communication. MCP is a protocol designed specifically for connecting AI hosts and agents to external context, tools, and workflows.
Use a traditional API when:
Use MCP when:
In short: an API is usually built for applications. MCP is built for AI agents that need to discover capabilities, read context, and call tools safely.
Show how an MCP server should validate tool input before executing server-side logic.
An MCP server should validate tool input at runtime, even when the tool already exposes an inputSchema. The schema helps clients construct valid calls, but the server still receives untrusted input.
Example validation in JavaScript:
function validateCreateTicketArgs(args) {
if (!args || typeof args !== 'object') {
throw new Error('Arguments must be an object');
}
if (typeof args.title !== 'string' || args.title.trim().length === 0) {
throw new Error('title is required');
}
if (args.priority && !['low', 'medium', 'high'].includes(args.priority)) {
throw new Error('priority must be low, medium, or high');
}
return {
title: args.title.trim(),
priority: args.priority || 'medium'
};
}Good validation should check type, required fields, allowed values, length limits, authorization, and whether the requested operation is safe for the current user.
Explain the difference between protocol errors and tool execution errors.
Use a JSON-RPC error when the request itself is invalid, such as an unknown method or malformed parameters.
Use a normal tools/call result with isError: true when the MCP tool ran but failed at the domain level, such as a failed search, denied permission, or invalid business operation.
Example tool-level error:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [
{
"type": "text",
"text": "Permission denied: you cannot create tickets in project FINANCE."
}
],
"isError": true
}
}This distinction matters because the client can treat protocol failures as integration problems, while tool-level errors can be shown to the model or user as task feedback.
Create a basic search_docs MCP tool with input validation metadata.
An MCP tool should have a stable name, a clear description, and an inputSchema that defines the arguments the client may pass.
Example tool definition:
{
"name": "search_docs",
"title": "Search Documentation",
"description": "Search the internal documentation index.",
"inputSchema": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "Search query"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 10,
"default": 5
}
},
"required": ["query"]
}
}Example tools/call request:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "search_docs",
"arguments": {
"query": "MCP resources",
"limit": 3
}
}
}In production, validate arguments on the server as well. The schema helps clients, but it should not be treated as the only security boundary.
Design a parameterized resource template for reading documentation pages by slug.
Use a resource template when the server can expose many resources following the same URI pattern.
Example template:
{
"uriTemplate": "docs://pages/{slug}",
"name": "Documentation Page",
"description": "Read a documentation page by slug",
"mimeType": "text/markdown"
}Example read request:
{
"jsonrpc": "2.0",
"id": 10,
"method": "resources/read",
"params": {
"uri": "docs://pages/getting-started"
}
}Example response:
{
"jsonrpc": "2.0",
"id": 10,
"result": {
"contents": [
{
"uri": "docs://pages/getting-started",
"mimeType": "text/markdown",
"text": "# Getting Started\n\nInstall the CLI and run the setup command."
}
]
}
}Resource templates are useful when the client should discover a pattern without the server listing every possible resource.
Prepare for AI agent developer interviews with 15 Model Context Protocol (MCP) questions covering tools, resources, prompts, JSON-RPC, transports, roots, sampling, security, and practical MCP server design....
Amazone runs the internet as we know it. Amazon Web Services (AWS) offers a comprehensive suite of machine learning (ML) services that cater to various needs and expertise levels. Follow along and learn the 23 most common AWS machine-learning intervi...
Azure Machine Learning (Azure ML) is a cloud-based service for creating and managing machine learning solutions. It’s designed to scale, distribute, and deploy machine learning models to the cloud. Follow along and learn the 23 most common Azure Mach...