Chapter 37: Quiz

Test your understanding of custom tools, MCP servers, and extending AI capabilities. Each question has one best answer unless otherwise noted.


Question 1

What are the three primary types of capabilities that an MCP server can expose?

  • A) Functions, classes, and modules
  • B) Tools, resources, and prompts
  • C) Endpoints, schemas, and handlers
  • D) Commands, queries, and events
Answer **B) Tools, resources, and prompts.** MCP servers expose three types of capabilities: **Tools** (functions the AI can invoke to perform actions), **Resources** (data sources the AI can read for context), and **Prompts** (pre-defined prompt templates that guide AI behavior for specific tasks). This three-part model covers the primary ways an AI assistant needs to interact with external systems. Reference: Section 37.2

Question 2

Which message format does MCP use for communication between clients and servers?

  • A) Protocol Buffers (protobuf)
  • B) GraphQL
  • C) JSON-RPC 2.0
  • D) XML-RPC
Answer **C) JSON-RPC 2.0.** MCP uses JSON-RPC 2.0 as its message format. Every message is a JSON object with a `jsonrpc` field set to `"2.0"`, a `method` field specifying the operation, and either `params` for requests or `result`/`error` for responses. Requests include an `id` field for matching responses to requests. Reference: Section 37.2

Question 3

What is the primary purpose of tool descriptions in MCP schemas?

  • A) To generate API documentation automatically
  • B) To help the AI decide when and how to use each tool
  • C) To validate user inputs at the client level
  • D) To provide error messages when tools fail
Answer **B) To help the AI decide when and how to use each tool.** Tool descriptions are essentially prompts for the AI. The quality of the description directly affects how well the AI understands when the tool should be used, what inputs it needs, and what kind of results to expect. Well-written descriptions should explain not just what the tool does but when it should be used. Reference: Section 37.2

Question 4

Which MCP transport mechanism is most appropriate for tools that access local files on the developer's machine?

  • A) SSE (Server-Sent Events)
  • B) Streamable HTTP
  • C) stdio (Standard I/O)
  • D) WebSocket
Answer **C) stdio (Standard I/O).** The stdio transport is the simplest and most appropriate for local tools. The client launches the server as a subprocess and communicates through stdin/stdout. This works well for tools that access local files, databases, or other resources on the developer's machine, without requiring network communication. Reference: Section 37.2

Question 5

What is the "god tool" anti-pattern in custom tool design?

  • A) A tool that requires administrator privileges to run
  • B) A tool that accepts a sub-command parameter to perform many different actions
  • C) A tool that calls other tools internally
  • D) A tool that returns too much data in its response
Answer **B) A tool that accepts a sub-command parameter to perform many different actions.** The "god tool" anti-pattern creates a single tool with a mode or sub-command parameter (e.g., a `database_operation` tool with actions for query, insert, update, and delete). This is harder for the AI to use correctly because it must reason about multiple responsibilities. The preferred approach is to create separate, focused tools with clear single responsibilities. Reference: Section 37.4

Question 6

Why should errors in MCP tool handlers be returned as structured JSON in the tool result rather than raised as exceptions?

  • A) Because Python does not support exceptions in async functions
  • B) Because JSON-RPC does not have an error mechanism
  • C) Because it allows the AI to understand the error and respond intelligently
  • D) Because exceptions would crash the MCP client
Answer **C) Because it allows the AI to understand the error and respond intelligently.** When errors are returned as structured JSON (with error type, details, and suggestions), the AI can understand what went wrong and potentially try a different approach or inform the user with helpful context. Raised exceptions may result in generic error messages that the AI cannot interpret meaningfully. Reference: Section 37.3

Question 7

What security measure is MOST critical when giving an AI assistant database access through a custom tool?

  • A) Using the latest database version
  • B) Enforcing read-only access and validating queries
  • C) Using a high-performance database driver
  • D) Caching all query results
Answer **B) Enforcing read-only access and validating queries.** When providing AI-accessible database queries, the most critical security measure is enforcing read-only access (only SELECT statements) and validating all queries against allowlists. This prevents accidental or malicious data modification. Additional measures include table allowlists, parameterized queries, and using database users with minimal privileges. Reference: Section 37.5

Question 8

In the context of MCP slash commands, what does $ARGUMENTS represent?

  • A) A list of all available command parameters
  • B) The text the user provides after the command name
  • C) Environment variables passed to the command
  • D) The AI model's response arguments
Answer **B) The text the user provides after the command name.** When a user invokes a slash command like `/debug TypeError in the payment processor`, the `$ARGUMENTS` placeholder in the command's Markdown file is replaced with "TypeError in the payment processor". This allows slash commands to be parameterized with user-provided context. Reference: Section 37.6

Question 9

What is the primary difference between MCP tools and MCP resources?

  • A) Tools are written in Python, resources are written in JSON
  • B) Tools perform actions and return results; resources provide readable data for context
  • C) Tools are synchronous, resources are asynchronous
  • D) Tools are available to all clients, resources are client-specific
Answer **B) Tools perform actions and return results; resources provide readable data for context.** Tools are functions that the AI invokes to perform actions (searching, creating, calculating), while resources are data sources that the AI reads for context (documentation, configuration, schemas). The key distinction is that tools execute operations, while resources provide information passively. Reference: Section 37.2

Question 10

Which of the following is the correct order for MCP initialization?

  • A) tools/list -> initialize -> initialized -> tools/call
  • B) initialize -> tools/list -> initialized -> tools/call
  • C) initialize -> initialized -> tools/list -> tools/call
  • D) initialized -> initialize -> tools/list -> tools/call
Answer **C) `initialize` -> `initialized` -> `tools/list` -> `tools/call`.** The MCP initialization sequence begins with the client sending an `initialize` request, the server responding with capabilities, the client sending an `initialized` notification to confirm, and then proceeding to discover tools via `tools/list` before invoking them with `tools/call`. Reference: Section 37.2

Question 11

What is the main advantage of the tool registry pattern?

  • A) It makes tools run faster
  • B) It provides a structured way to organize and manage multiple tool definitions
  • C) It automatically generates tool documentation
  • D) It enforces type safety at compile time
Answer **B) It provides a structured way to organize and manage multiple tool definitions.** As an MCP server grows to include many tools, the registry pattern keeps code organized by centralizing tool registration, lookup, and invocation. It separates tool metadata (name, description, schema) from the server's routing logic, making it easier to add, remove, and modify tools. Reference: Section 37.4

Question 12

Why is writing to stdout problematic in MCP servers that use the stdio transport?

  • A) It is slower than writing to stderr
  • B) It corrupts the JSON-RPC message stream
  • C) It is not supported on Windows
  • D) It bypasses the logging framework
Answer **B) It corrupts the JSON-RPC message stream.** The stdio transport uses stdout for protocol messages between the client and server. Any `print()` statement or other stdout output in the server code will be mixed into the JSON-RPC message stream, causing parsing errors and mysterious failures. Debug output should always use stderr or a logging framework configured for stderr. Reference: Section 37.8

Question 13

What is the purpose of middleware in the context of MCP tool calls?

  • A) To translate between different programming languages
  • B) To add cross-cutting concerns like logging, caching, and validation without modifying tool logic
  • C) To compress tool responses for faster transmission
  • D) To convert tools into resources
Answer **B) To add cross-cutting concerns like logging, caching, and validation without modifying tool logic.** Middleware sits between the AI's tool call and the tool's actual execution, intercepting requests and responses to add concerns like validation, logging, rate limiting, caching, and authentication. This pattern keeps tool handlers focused on their primary logic while cross-cutting concerns are handled separately. Reference: Section 37.7

Question 14

Which deployment model is most appropriate for an MCP server that multiple developers on a team need to share?

  • A) Local stdio deployment on each developer's machine
  • B) Remote deployment with SSE or Streamable HTTP transport
  • C) Running directly inside the AI model
  • D) Embedding the server code in the AI client
Answer **B) Remote deployment with SSE or Streamable HTTP transport.** When multiple developers need to share the same tool server (for consistent access to shared data, centralized configuration, or server-side resources), a remote deployment using SSE or Streamable HTTP transport is appropriate. Local stdio deployment would require each developer to run their own instance and maintain their own data. Reference: Section 37.9

Question 15

What makes slash commands particularly valuable for team onboarding?

  • A) They reduce the AI model's response latency
  • B) They encode tribal knowledge and unwritten processes into reusable templates
  • C) They eliminate the need for documentation
  • D) They allow new team members to bypass code review
Answer **B) They encode tribal knowledge and unwritten processes into reusable templates.** Slash commands capture the expertise, conventions, and processes that experienced team members know but new members must learn. By encoding this tribal knowledge into slash commands, teams make their expertise available through the AI assistant, which is especially valuable during onboarding. Reference: Section 37.6

Question 16

When building a caching middleware for MCP tools, what should the cache key be based on?

  • A) Only the tool name
  • B) The tool name and the arguments combined
  • C) The timestamp of the request
  • D) The AI model's conversation ID
Answer **B) The tool name and the arguments combined.** A cache key should be generated from both the tool name and the arguments (typically by hashing a combination of both). Using only the tool name would return the same cached result regardless of different arguments. The timestamp would never match a previous cache entry. The conversation ID is irrelevant to whether the same operation produces the same result. Reference: Section 37.7

Question 17

What is the recommended approach when an MCP tool needs to handle both read and write database operations?

  • A) Create one tool with a "mode" parameter for read vs. write
  • B) Create separate tools for read operations and write operations
  • C) Only support read operations and reject write requests
  • D) Use raw SQL passthrough for maximum flexibility
Answer **B) Create separate tools for read operations and write operations.** Following the single responsibility principle, separate tools (e.g., `query_database` for reads and `insert_record` for writes) are easier for the AI to use correctly. Each tool has a clear purpose, appropriate security constraints, and focused error handling. This also allows applying different security policies (e.g., stricter rate limiting on writes). Reference: Section 37.4

Question 18

What is the primary benefit of using JSON Schema for tool input validation?

  • A) JSON Schema runs faster than custom validation code
  • B) JSON Schema provides self-documenting, standardized validation that both AI and developers can understand
  • C) JSON Schema is required by the MCP specification
  • D) JSON Schema prevents all possible input errors
Answer **B) JSON Schema provides self-documenting, standardized validation that both AI and developers can understand.** JSON Schema serves dual purposes: it documents the expected inputs (which the AI reads to understand how to use the tool) and validates actual inputs at runtime (catching errors before they reach the handler). This standardized approach is understood by both AI models and human developers, making tools self-documenting. Reference: Section 37.4

Question 19

Which statement about MCP prompt templates is correct?

  • A) Prompts are executed automatically by the server without user interaction
  • B) Prompts define the AI model's system prompt and cannot be changed
  • C) Prompts are reusable templates that structure the AI's approach to specific tasks and can include parameters
  • D) Prompts replace all other tool capabilities when active
Answer **C) Prompts are reusable templates that structure the AI's approach to specific tasks and can include parameters.** MCP prompts are pre-defined templates that guide AI behavior for specific tasks. They can accept parameters (like a file path or focus area), and when selected, the server returns a series of messages that establish context and structure. They are selected by the user or AI as needed, not executed automatically. Reference: Section 37.2

Question 20

What is the recommended first step when building custom tools for a team?

  • A) Build the most complex tool first to prove the technology works
  • B) Start with a simple knowledge access tool for team documentation
  • C) Deploy a remote server with all planned tools before testing any
  • D) Write a comprehensive middleware pipeline before building any tools
Answer **B) Start with a simple knowledge access tool for team documentation.** Starting with a high-impact, low-complexity tool (typically knowledge access for documentation or coding standards) provides immediate productivity gains. This quick win builds organizational support for more ambitious tool development and helps the team learn MCP patterns before tackling complex integrations. Reference: Section 37.1

Question 21

When evaluating a third-party MCP server, which factor is LEAST important?

  • A) Whether it is actively maintained with recent commits
  • B) What programming language it is written in
  • C) Whether it follows security best practices
  • D) Whether it has automated tests
Answer **B) What programming language it is written in.** Since MCP servers communicate through a standardized protocol, the implementation language is largely irrelevant to the consumer. A well-built TypeScript server works just as well for a Python-using team. What matters more is maintenance status, security practices, documentation quality, and test coverage. Reference: Section 37.10

Question 22

What does the following MCP configuration specify?

{
  "mcpServers": {
    "my-tools": {
      "command": "uv",
      "args": ["run", "--directory", "/home/user/mcp-servers", "my_tools.py"]
    }
  }
}
  • A) A remote MCP server running on a separate machine
  • B) A local MCP server launched with uv for dependency management via stdio transport
  • C) A Docker container running an MCP server
  • D) A test configuration for the MCP Inspector
Answer **B) A local MCP server launched with `uv` for dependency management via stdio transport.** This configuration tells the MCP client to launch a local server using the `uv` command (a Python package manager) with the `run` subcommand, specifying the project directory and the server script. The absence of a URL or port indicates stdio transport, where the client communicates with the server through stdin/stdout of the subprocess. Reference: Section 37.9

Question 23

In the context of tool security, what does "principle of least privilege" mean?

  • A) Using the least expensive API tier available
  • B) Granting the tool only the minimum permissions needed to perform its function
  • C) Minimizing the number of tools exposed by each server
  • D) Using the simplest possible transport mechanism
Answer **B) Granting the tool only the minimum permissions needed to perform its function.** The principle of least privilege means that each tool should have only the access and permissions it strictly needs. A database query tool should use a read-only database user. An API integration should use tokens with minimal scopes. A file access tool should be restricted to specific directories. This minimizes the potential damage from bugs or misuse. Reference: Section 37.9

Question 24

How do custom tools connect to the agent workflows described in Chapter 36?

  • A) Custom tools replace agent workflows entirely
  • B) Agents can use custom tools to autonomously gather context, verify work, deploy changes, and access domain-specific capabilities
  • C) Custom tools and agents use different protocols and cannot interact
  • D) Agents can only use built-in tools, not custom ones
Answer **B) Agents can use custom tools to autonomously gather context, verify work, deploy changes, and access domain-specific capabilities.** Custom tools become especially powerful when combined with autonomous agent workflows from Chapter 36. An agent with access to custom tools can autonomously search knowledge bases for context, verify its work against team standards, deploy through specific pipelines, and use domain-specific capabilities — all by chaining tool calls during its execution loop. Reference: Section 37.10

Question 25

Which of the following best describes the competitive advantage of custom AI tooling?

  • A) Custom tools make the AI model itself smarter
  • B) Custom tools reduce the cost of AI API calls
  • C) Custom tools connect the AI to your specific domain, data, and workflows — creating capabilities others lack
  • D) Custom tools make AI assistants work offline
Answer **C) Custom tools connect the AI to your specific domain, data, and workflows — creating capabilities others lack.** The AI model is increasingly a commodity — everyone has access to the same foundation models. The differentiator is how well you connect that model to your specific systems, knowledge, and processes. Organizations that invest in custom tooling give their developers AI assistants that understand their unique domain, creating competitive advantage that generic tools cannot match. Reference: Section 37.10