Courseiva

CCAR-F Tool Design and MCP Integration Practice Question

An architect is preparing an MCP server for a code review tool. The tool 'review_code' takes a 'language' parameter and a 'code_snippet' parameter. The architect wants to ensure the model provides valid language values and that the snippet is not excessively large. Which combination of JSON Schema constraints should be applied to the tool definition?

⚠ Common exam trap

A common mix-up: candidates confuse validation mechanisms, such as using a regex or minLength when an enum and maxLength are the precise tools for the stated constraints.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Use an enum for 'language' and a maxLength constraint for 'code_snippet'.

Using an enum for 'language' restricts the model to supported values, and a maxLength constraint on 'code_snippet' bounds the input size. These are standard JSON Schema keywords that directly address the requirements. They are simple, declarative, and enforced by the MCP server, making them the most appropriate choice.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Use a numeric type for 'language' and a maximum value for 'code_snippet'.

    Why it's wrong here

    Changing 'language' to a numeric type would break the tool's expected input and force the model to send numbers instead of language names. Applying a maximum to 'code_snippet' is nonsensical because it is a string, not a number. This option misapplies schema types and constraints, failing to achieve valid language values or size limits.

  • ✓

    Use an enum for 'language' and a maxLength constraint for 'code_snippet'.

    Why this is correct

    An enum restricts 'language' to a predefined set of valid values, ensuring the model cannot send unsupported languages. A maxLength constraint on 'code_snippet' prevents excessively large inputs that could exceed token or processing limits. Together, these schema constraints enforce valid and bounded input at the protocol level.

  • ✗

    Use an array of strings for 'language' and an object type for 'code_snippet'.

    Why it's wrong here

    An array of strings would allow multiple languages, which may be unintended, and an object type for 'code_snippet' would require structured data instead of a plain string. This complicates the tool interface without solving the size or validity issues. The model would still be able to send large or invalid inputs, and the tool's implementation would need to change.

  • ✗

    Use a regex pattern for 'language' and a minLength constraint for 'code_snippet'.

    Why it's wrong here

    A regex pattern can validate format but is less precise than an enum for a fixed set of languages, and it may allow unexpected values if not carefully written. A minLength constraint sets a lower bound, which does not address the problem of excessively large snippets. This combination fails to enforce the desired upper bound and clarity.

About these practice questions

This CCAR-F question is part of Courseiva's 271-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Anthropic exam blueprint

This CCAR-F practice question is part of Courseiva's free Anthropic certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CCAR-F exam.