MCP interviews often start with “What is a tool?” and quickly move to harder territory: who owns a connection, what happens when a request is cancelled, and which side is responsible for a security boundary?
This guide focuses on protocol lifecycles, transport choices, and production failure semantics. The questions progress from fundamentals to system design. Model answers aim for the precision expected in an experienced engineering interview: distinguish protocol guarantees from implementation choices, and explain the trade-offs rather than reciting terminology.
The examples use the official TypeScript SDK’s McpServer API. Pin the SDK version in a real project and check its documentation when upgrading; protocol concepts and SDK method signatures do not necessarily change in lockstep. See the MCP specification and the official TypeScript SDK.
Fundamentals
1. What problem does MCP solve, and what does it not standardize?
What the interviewer is testing: Whether you can describe MCP as an integration protocol without overstating what it provides.
Model answer: MCP gives an AI application a standard way to connect to external capabilities and context. It defines how clients and servers communicate about capabilities such as tools, resources, and prompts. That can reduce the need for every host application and integration to invent a different adapter.
MCP does not define the business meaning of every tool, guarantee that a tool is safe, or make an agent’s decisions correct. A server can expose a well-formed tool that still has dangerous side effects. Authentication, authorization, input validation, and operational controls remain design responsibilities.
A useful distinction in an interview is: MCP standardizes how capabilities are discovered and invoked; the application still owns whether those capabilities should be invoked.
Follow-up: If MCP standardizes invocation, who should decide whether a tool call needs user approval?
Hint: Separate protocol mechanics from host policy.
2. Explain the MCP roles and the usual connection shape.
What the interviewer is testing: Whether you understand the host-client-server relationship and can explain where orchestration belongs.
Model answer: The host is the AI application. It creates and manages MCP client connections, combines results, and applies application policy. An MCP client speaks the protocol to one server. An MCP server exposes capabilities to that client.
A host may connect to several servers, usually through separate client connections. It should not assume that two servers share state or trust each other. The host is also not required to expose every capability from every server to the model; it can filter or mediate what is available.
flowchart LR host["Host application"] clientA["MCP client A"] clientB["MCP client B"] serverA["MCP server A"] serverB["MCP server B"] host --> clientA host --> clientB clientA --> serverA clientB --> serverB
An MCP host can manage distinct clients and connections to multiple servers.
Follow-up: Why might a host intentionally hide a server tool from the model?
Hint: Consider user permissions, risk, and task-specific capability selection.
3. What happens during MCP initialization?
What the interviewer is testing: Whether you know that setup is a protocol exchange, not just opening a socket.
Model answer: The client and server begin with an initialization request. They negotiate a protocol version and exchange capability information and implementation details. If the client accepts the result, it sends an initialized notification to signal that initialization is complete. Normal operations should follow that handshake.
Capabilities matter because they describe which protocol features each side supports. They are not a promise that every possible operation will succeed: the server can still return an error for an unsupported or invalid request. Keep initialization state tied to the connection; reconnecting means establishing the protocol state again.
Client Server
| --- initialize request ---> |
| <-- initialize response --- |
| --- initialized notice ---> |
| --- tools/list request ---> |
Follow-up: What would you do if a server responds with a protocol version the client does not support?
Hint: Treat version negotiation as a compatibility decision, not a best-effort guess.
4. How do MCP tools, resources, and prompts differ?
What the interviewer is testing: Whether you can select the right capability shape instead of turning every interaction into a tool.
Model answer: A tool represents an operation the client can invoke, often with structured input and a result. A resource represents context the client can read, such as a document or other data identified by a URI. A prompt represents a reusable prompt template that a client can request.
Use a tool when the interaction is an action or query with defined inputs. Use a resource when the client needs to retrieve context. Use a prompt when the server provides a reusable prompt structure. These categories clarify intent, but they do not automatically enforce access control or make content trustworthy.
Follow-up: A server exposes a search_documents operation. Should it be a tool or a resource?
Hint: Ask whether the client is invoking a search action or reading an already-addressable item.
Intermediate
5. How would you build a minimal MCP server in TypeScript?
What the interviewer is testing: Whether you can connect the protocol concepts to an actual server without confusing an SDK example with the whole protocol.
Model answer: Register a capability with a schema and handler, then connect the server to a transport. The example below uses standard input and output, a common choice for a local server launched as a subprocess. Standard output belongs to protocol traffic, so do not write ordinary logs there.
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({ name: "math-server", version: "1.0.0" });
server.registerTool(
"add",
{
description: "Add two numbers",
inputSchema: { a: z.number(), b: z.number() },
},
async ({ a, b }) => ({
content: [{ type: "text", text: String(a + b) }],
}),
);
await server.connect(new StdioServerTransport());
Install the SDK and Zod, save this as server.ts, and run it with a TypeScript runner such as tsx.
What to notice: The SDK handles protocol framing; the handler supplies the tool’s behavior and result.
Follow-up: Where should diagnostics go in a stdio server?
Hint: Keep diagnostic output separate from the channel used for protocol messages.
6. When would you choose stdio versus Streamable HTTP?
What the interviewer is testing: Whether you can choose a transport based on deployment and operational constraints.
Model answer: Stdio fits a local process model: a host launches a server and communicates over its input and output streams. It avoids exposing a network listener, but process management, environment handling, and local trust boundaries become important.
Streamable HTTP fits a server reachable over HTTP, including remote deployments. It introduces network concerns such as authentication, request routing, availability, and transport security. It can support server responses over HTTP, but deployment details should follow the protocol and SDK behavior rather than assumptions from a hand-written HTTP API.
Neither choice makes the application secure by itself. A local process can still access sensitive files, and a remote endpoint still needs appropriate identity and authorization controls.
| Option | Often a good fit | Main concerns |
|---|---|---|
| Stdio | Host-managed local server process | Process lifecycle, local permissions, clean stdout |
| Streamable HTTP | Remotely reachable server | Authentication, network exposure, availability, request isolation |
| Custom REST API | A service designed around application-specific HTTP contracts | MCP clients need an adapter; capability discovery is application-defined |
| Direct model function calling | A model-provider-specific integration | Coupling to the provider’s function and tool interfaces |
Follow-up: Would you expose a filesystem-capable stdio server to an untrusted local user?
Hint: A local transport does not imply a trusted caller or safe filesystem scope.
7. How should a tool define and validate its input?
What the interviewer is testing: Whether you understand that a schema is useful but not a security boundary.
Model answer: Give the tool a narrow, explicit input schema. Validate again in the handler before using inputs to construct file paths, queries, commands, or downstream requests. Schema validation helps clients form correct calls, but the handler must still defend against malicious values and enforce authorization.
For example, a document-reading tool should accept an identifier or constrained relative path, resolve it under an approved directory, reject traversal, and impose a size limit. Avoid exposing general-purpose capabilities such as “run arbitrary shell command” when a narrowly defined operation is sufficient.
Follow-up: If the protocol describes a tool’s schema, is server-side validation still necessary?
Hint: The server must not assume every caller is well behaved.
8. What should happen when a tool call times out or is cancelled?
What the interviewer is testing: Whether you distinguish request lifecycle control from guaranteed rollback.
Model answer: The client should set a deadline appropriate to the operation and cancel work it no longer needs. The server should pass cancellation through to cancellable downstream operations where possible, stop unnecessary work, and release resources.
Cancellation is not the same as rollback. If a tool has already sent an email or committed a payment, cancellation cannot necessarily undo that side effect. For important operations, design explicit idempotency, status checks, or compensating actions. Return a clear error when work fails, and avoid turning a timeout into a success-shaped response.
Follow-up: A client times out after submitting a write, then retries. How do you prevent duplicate effects?
Hint: Consider idempotency keys and querying the operation’s final status.
Senior and system-design level
9. Design a remote MCP server that exposes read-only access to customer documents.
What the interviewer is testing: Whether you can design the security boundary and failure behavior, not just deploy an HTTP endpoint.
Model answer: Start by identifying the caller identity and the authorization decision. Authenticate the remote client using the supported authorization model for the deployment, then authorize each document request against the authenticated principal. Do not treat knowledge of a resource URI as permission to read it.
Keep the server’s backend credentials scoped to the operation it performs. Enforce tenant boundaries in the data-access layer, limit response size, and avoid returning sensitive fields the caller does not need. Apply network protections, rate limits, and timeouts. Treat document content as untrusted input: it may contain instructions or text designed to influence a downstream model.
Finally, test cross-tenant access, expired credentials, malformed requests, and backend timeouts. A healthy process is not proof that access control is working.
Follow-up: What would you log when a document read is denied?
Hint: Record a useful decision reason without copying document contents or credentials into logs.
10. How do you handle tool results that are untrusted or potentially hostile?
What the interviewer is testing: Whether you recognize that MCP transports data; they do not confer trust on it.
Model answer: Treat tool descriptions, inputs, and results as data from an integration boundary. A result may contain inaccurate claims, sensitive content, or instructions intended to manipulate the model. The host should keep the source and trust level visible to its orchestration logic, apply output controls appropriate to the application, and avoid treating returned text as an instruction with higher priority than system policy.
For consequential operations, separate observation from action. A read-only result can inform a later decision; a write-capable tool call should still be subject to authorization and, where appropriate, confirmation. Do not assume a server is safe because it is registered or because its tool metadata looks reasonable.
Follow-up: How would you reduce risk from a compromised third-party server?
Hint: Think about least privilege, capability selection, review, and limiting effects.
11. How would you make a realistic document-reading tool safe and useful?
What the interviewer is testing: Whether you can translate safety requirements into handler-level controls.
Model answer: Make the capability narrow: accept a document identifier, not an arbitrary path. Resolve it against a fixed base directory, reject traversal, limit the amount of data returned, and handle missing files without leaking host details. In a real service, authorization should also check whether the caller may read that document.
This example demonstrates filesystem containment and a byte limit. It is not a complete authorization system, and the local directory is only a stand-in for a tenant-aware storage layer.
import { readFile, realpath } from "node:fs/promises";
import path from "node:path";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const root = await realpath("./documents");
const server = new McpServer({ name: "docs-server", version: "1.0.0" });
server.registerTool(
"read_document",
{
description: "Read a small text document by filename",
inputSchema: { filename: z.string().min(1).max(120) },
},
async ({ filename }) => {
const candidate = path.resolve(root, filename);
if (!candidate.startsWith(root + path.sep)) {
return {
isError: true,
content: [{ type: "text", text: "Invalid document name" }],
};
}
try {
const resolved = await realpath(candidate);
if (!resolved.startsWith(root + path.sep)) {
throw new Error("Path escapes document root");
}
const data = await readFile(resolved);
if (data.byteLength > 64_000) {
return {
isError: true,
content: [{ type: "text", text: "Document exceeds size limit" }],
};
}
return {
content: [{ type: "text", text: data.toString("utf8") }],
};
} catch {
return {
isError: true,
content: [{ type: "text", text: "Document unavailable" }],
};
}
},
);
await server.connect(new StdioServerTransport());
Install the SDK and Zod, create a documents directory with a small text file, save as server.ts, and run with tsx.
What to notice: The handler checks the resolved path and caps output; production authorization still belongs in the request path.
Follow-up: Why check the real path after resolving the filename?
Hint: A path inside the directory may resolve through a symbolic link to a different location.
12. How would you observe an MCP server in production?
What the interviewer is testing: Whether you can make protocol operations diagnosable without logging sensitive payloads.
Model answer: Log lifecycle events and outcomes with stable, low-cardinality fields: server name, capability name, transport, operation, outcome, error category, and duration. Use a request or trace identifier to connect events across the host, MCP server, and downstream service. Do not log credentials, full prompts, or sensitive tool arguments by default.
For a service, track RED: request rate, errors, and duration. For resources such as CPU, memory, connection pools, and file descriptors, track USE: utilization, saturation, and errors. Break metrics down by operation where cardinality is bounded; never make user IDs or raw arguments metric labels.
Example structured log:
{
"event": "mcp_tool_call",
"server": "docs-server",
"tool": "read_document",
"transport": "stdio",
"outcome": "error",
"error_category": "not_found",
"duration_ms": 18,
"trace_id": "4bf92f3577b34da6a3ce929d0e0e4736"
}
Instrument application work with OpenTelemetry spans. This Node.js example records a tool operation; production deployments should also instrument the HTTP or stdio boundary and downstream calls. Verify context propagation across those boundaries rather than assuming it happens automatically.
import { trace, SpanStatusCode } from "@opentelemetry/api";
const tracer = trace.getTracer("mcp-server");
async function observedToolCall<T>(
tool: string,
operation: () => Promise<T>,
): Promise<T> {
return tracer.startActiveSpan(`mcp.tool.${tool}`, async (span) => {
span.setAttribute("mcp.tool.name", tool);
try {
return await operation();
} catch (error) {
span.recordException(error as Error);
span.setStatus({ code: SpanStatusCode.ERROR });
throw error;
} finally {
span.end();
}
});
}
| SLI | Example SLO | Measurement |
|---|---|---|
| Successful tool-call rate | At least 99.5% of eligible calls succeed over a rolling 30-day window | Successful calls divided by eligible calls |
| Tool-call latency | 95% complete within the operation-specific deadline | End-to-end duration by tool |
| Protocol availability | At least 99.9% of health checks succeed over a rolling 30-day window | Successful protocol-level checks divided by checks |
Page on sustained elevated error rate, exhausted worker or connection capacity, or a rapidly worsening latency breach that threatens the SLO. Alert on individual user errors at a lower severity unless they indicate a systemic fault. Define “eligible call” carefully; exclude caller validation errors only if that matches the user-facing reliability objective.
Follow-up: Why avoid putting document IDs in metric labels?
Hint: Consider unbounded cardinality and the risk of leaking sensitive identifiers.
13. How should an MCP client handle retries and partial failure?
What the interviewer is testing: Whether you understand that retry policy depends on operation semantics.
Model answer: First classify failures: transport failure, protocol error, server error, validation failure, timeout, or cancellation. Retry only when there is a reasonable chance of success and the operation is safe to repeat. A read-only request may often be retried with bounded backoff. A write may need an idempotency mechanism or an operation-status lookup before retrying.
Keep retry budgets bounded so a slow server does not create a retry storm. Respect the user’s deadline, add jitter where many clients may retry together, and preserve enough error context for diagnosis. Do not convert a failed call into an empty successful result; that makes downstream decisions harder to trust.
Follow-up: The server returned a timeout after a write request. What is the safest next step?
Hint: Determine whether the operation committed before sending it again.
14. How would you evolve a server’s capabilities without breaking clients?
What the interviewer is testing: Whether you can reason about compatibility at the protocol and application layers.
Model answer: Treat a change to tool names, input schemas, result shapes, or side effects as an API change. Prefer additive changes when they preserve existing behavior, document the semantics clients depend on, and test old clients against the new server. Do not infer that a client can handle a new capability simply because it can connect.
For breaking changes, consider versioned capability names or a deliberate migration path, then measure adoption before removing the old form. Keep protocol-version negotiation distinct from the versioning of your application’s tool contract. They solve different compatibility problems.
Follow-up: Why is changing a tool’s behavior risky even if its name and schema stay the same?
Hint: Existing clients may rely on semantics that the schema cannot express.
Common mistakes candidates make
- Describing MCP as an agent framework rather than a protocol for capability exchange.
- Treating the host, client, and server as interchangeable roles.
- Assuming a valid schema makes a tool safe or authorized.
- Choosing a transport before considering deployment, identity, and process ownership.
- Logging complete prompts and tool arguments “for debugging.”
- Retrying side-effecting calls without idempotency or status checks.
- Treating cancellation as proof that a downstream operation did not happen.
- Trusting tool output as instructions rather than untrusted data.
- Ignoring tenant isolation because a server runs locally or behind a private network.
- Treating protocol-version negotiation as a replacement for application API compatibility.
Quick-revision checklist
Before an interview, make sure you can:
- Explain the host-client-server roles and the initialization handshake.
- Distinguish tools, resources, and prompts.
- Compare stdio and Streamable HTTP using deployment constraints.
- Explain why input schemas are not authorization controls.
- Describe cancellation, retries, idempotency, and partial failure.
- Design a narrow capability with bounded input and output.
- Explain how to protect a remote server and isolate tenants.
- Describe safe handling of untrusted tool results.
- Propose structured logs, RED and USE metrics, traces, SLOs, and actionable alerts.
- Separate protocol compatibility from changes to your application’s tool contract.
This article was generated with AI. #AIGenerated