Deterministically Force MCP Tool Invocation in Microsoft Foundry

AI-103 By islever Editorial Last updated

Short answer

D Add tool_choice={"type":"mcp"} to the code snippet to deterministically force the agent to invoke the MCP tool on each run.

Question

You have a Microsoft Foundry project that contains an agent. The agent has a Model Context Protocol (MCP) tool that queries a knowledge base stored in Azure AI Search.
Some agent runs return answers from the base model without invoking the knowledge base, which results in responses without grounded citations.
You are provided with the following code snippet that runs the agent.
Exhibit: Deterministically Force MCP Tool Invocation in Microsoft Foundry
You need to add the correct tool _choice parameter to the code to deterministically force the agent to invoke the MCP tool on each run.
What should you add?
  1. tool_choice={“required”}
  2. tool_choice={“auto”}
  3. tool_choice={“type”:“knowledge_base”}
  4. tool_choice ={“type”:“mcp”} Correct Answer

Key Takeaways

The exam tests the distinction between forcing any tool usage versus forcing a specific tool type, with the common trap being the selection of 'required' which does not guarantee the correct tool is used if multiple tools are present.

This question examines how to configure the tool_choice parameter in Microsoft Foundry agents to ensure deterministic invocation of a specific Model Context Protocol (MCP) tool. It clarifies that specifying the tool type is required to prevent the base model from answering without grounding.

Common mistake: Many learners choose 'required' because it forces tool usage, but they fail to realize that 'required' allows the agent to pick any available tool, whereas the question demands the specific MCP tool be invoked.

Expert Analysis

Why the Answer Is Correct

The correct option is D: tool_choice={"type":"mcp"}. The question explicitly asks to "deterministically force the agent to invoke the MCP tool." In the Azure OpenAI API and Microsoft Foundry context, setting tool_choice to an object with a type property binds the call to tools of that specific type. Since the MCP tool is defined by its type, this ensures the agent calls the knowledge base retrieval tool rather than relying on internal knowledge.

Why the Other Options Are Wrong

Option A ({"required"} or similar syntax) forces the model to call a tool, but if multiple tools were registered, the agent might choose one other than the MCP tool. Option B ({"auto"}) allows the model to decide whether to use a tool, which leads to the problem described (skipping the KB). Option C uses a non-standard value knowledge_base which is not a valid tool type identifier in the underlying API schema.

Community Comment Notes

Several users correctly identified that 'required' is insufficient for deterministic targeting of a specific tool. As user Sky_Akash noted, "{\"required\"} only ensures some tool is used, not specifically the MCP tool." User Mattt also highlighted that D is more precise because it explicitly targets the MCP type, whereas A is generic. Some users pointed out syntax nuances, but the semantic requirement of 'deterministic' invocation points to D.

Exam Strategy

Always read the keyword 'deterministically' or 'specifically' in agent configuration questions. If the goal is to target a specific capability (like search or code execution), look for options that specify the tool type or name, not just 'required'.

Frequently Asked Questions

Why isn't tool_choice="required" sufficient?

Because 'required' only forces the use of any tool. If multiple tools exist, the agent could pick the wrong one. The question requires the specific MCP tool.

What does deterministically mean here?

It means the outcome is predictable and fixed. Using the tool type ensures the exact same tool is called every time, preventing the base model from skipping it.

More AI-103 FAQ →

Discussion 21 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 21

  1. Mattt 👍 6 Answered D
    D is more precise. required only forces the use of some tool, while {"type":"mcp"} explicitly forces the MCP tool. Also, option A uses incorrect Python syntax.
  2. cloudera 👍 3 Answered A
    Syntax error but I will still go with A: tool_choice="required" The issue is that the agent sometimes answers from the base model without calling the knowledge base tool. tool_choice="required" forces the agent to call a tool on each run, which prevents it from skipping retrieval and helps ensure grounded citations. D is tempting because MCP is the tool type, but the question is about forcing tool use at runtime, not defining the MCP tool itself. For more - https://learn.microsoft.com/en-us/azure/search/agentic-retrieval-how-to-create-pipeline
  3. 3f9a492 👍 3 Answered A
    Must use a tool every run → required The option displays tool_choice={"required"}, but proper Python SDK syntax is normally tool_choice="required"
  4. RPC112 👍 2 Answered A
    Its not D. Its A. The question says:"force the agent to invoke the MCP tool on each run" The documented behavior of tool_choice="required" is: Force the model to call a tool instead of answering directly. That directly addresses the problem statement: Some runs return answers from the base model without invoking the knowledge base. D. tool_choice={"type":"mcp"} MCP is the tool protocol, not the standard tool_choice value used to force invocation. Simply specifying "mcp" does not represent the documented way to require tool use.
  5. Sky_Akash 👍 2 Answered D
    Why not A ({"required"})? {"required"} only ensures some tool is used, not specifically the MCP tool. If multiple tools exist, the agent could pick another one. The question explicitly says “deterministically force the agent to invoke the MCP tool”, so you must specify its type. So even though A is “most voted,” D is the technically correct and exam-accurate choice.
Show 16 more comments
  1. AzureGeek79 👍 1 Answered D
    The correct answer is D. tool_choice ={"type":"mcp"}. In the Microsoft Foundry Agent Service, the tool_choice parameter controls whether and how the agent uses its attached tools during a run. • {"type":"mcp"} (Choice D): When you want to target a specific tool type and force the agent to use it deterministically for the processing turn, you must pass an object specifying that particular type. Since the agent is querying the Azure AI Search knowledge base explicitly via a Model Context Protocol (MCP) tool, specifying {"type":"mcp"} forces the model to invoke the protocol handler right away rather than attempting to answer directly from its internal pre-trained weights. • {"required"} (Choice A): While "required" forces the model to choose at least one tool from its toolbox, it does not explicitly guarantee which tool it will pick if multiple are defined. Furthermore, passing it as a Python set literal like {"required"} is a syntax misfit for the parameter expectations. • {"auto"} (Choice B): This is the default runtime behavior. It keeps tool selection non-deterministic, allowing the base model to skip the knowledge base if it feels confident enough to respond on its own—which is the exact behavior causing the ungrounded citations issue. • {"type":"knowledge_base"} (Choice C): "knowledge_base" is not a valid tool type identifier for an MCP-connected architecture in Foundry's Agent execution framework.
  2. ArindamPal 👍 1 Answered A
    The correct answer is A the agent is required to invoke a tool before generating a response. This ensures the agent doesn't answer directly from the base model and instead uses the configured tool, such as the MCP tool connected to the Azure AI Search knowledge base. This helps guarantee grounded responses with citations. Why the others are incorrect: B. tool_choice={"auto"} Lets the model decide whether to call a tool or answer directly. This is the behavior causing the problem. ❌ C. tool_choice={"type":"knowledge_base"} Not a valid tool-choice value for forcing an MCP tool invocation. ❌ D. tool_choice={"type":"mcp"} Specifies a tool type but does not deterministically force a tool call on every run. ❌
  3. tibarihbib 👍 1 Answered A
    A is correct. required forces the model to call a tool on every run instead of answering from its own knowledge. Since the MCP knowledge base tool is the agent’s tool, every run is grounded and returns citations. This matches Microsoft’s Foundry IQ guidance for knowledge base agents. B is wrong. auto is the default: the model decides whether to call a tool. That’s exactly what causes the current problem. C is wrong. knowledge_base isn’t a valid tool_choice type. The knowledge base is reached through the MCP tool. D is wrong. {"type": "mcp"} alone is incomplete. Targeting a specific MCP tool also needs its server_label (and tool name), so this form isn’t the expected answer.
  4. RICHARDALEX007 👍 1 Answered D
    To deterministically force a SPECIFIC tool, tool_choice must name the tool by type, so {"type":"mcp"} (D) is the intent. 'auto' (B) lets the model decide (the current bug), and {"required"} (A) is malformed set syntax; 'required' as a value forces some tool but not specifically the MCP one. The exact accepted schema for MCP tool_choice should be confirmed against the current Agents SDK
  5. ChrisJ99 👍 1 Answered D
    Option A ("required") forces the agent to call a tool. But, it does not specify which tool. If the agent has more than one tool, it can select a different tool. Thus, this option is not deterministic for the MCP tool. Also, the syntax {"required"} is not correct. The correct form is a string: tool_choice="required".
  6. fresco 👍 1 Answered D
    The answer is D. Per this link: https://ai.azure.com/api-reference/responses/, you can call a parameter for mcp and it states that doing so will "Use this option to force the model to call a specific tool on a remote MCP server." Note that it will FORCE the model hence it will be required.
  7. NielsLOL 👍 1 Answered A
    The most logic answer in my opinion is answer A, because the question states ´The agent has a Model Context Protocol (MCP) tool that queries a knowledge base stored in Azure AI Search.' So it already has a tool configured, and tool_choice={"required"} enforces that tool.
  8. a5f05ea 👍 1 Answered A
    For those answering D, understand question, it says deterministically force the agent to invoke the MCP tool. Now with option D it just tell agent you've a tool but it doesn't force the agent to use that tool. But option A forces agent to use the tool, which is the ask.
  9. Srini7 👍 1 Answered D
    Its D. Question Clearly state " add the correct tool _choice parameter to the code to deterministically force the agent to invoke the MCP tool on each run" in that case, we can't say "required" , becuase if you have more than one tool , its not valid. So answer is D
  10. shank23 👍 1 Answered A
    "required" explicitly forces the model to select and execute at least one tool before returning a text response. This overrides the base model's default behavior, ensuring it cannot answer directly using only its pre-trained internal weights
  11. 3d259eb 👍 1 Answered D
    mcp: OpenAI.ToolChoiceMCP Use this option to force the model to call a specific tool on a remote MCP server. - type: enum - required: For MCP tools, the type is always mcp. - server_label: string required The label of the MCP server to use.
  12. CharlieMike 👍 1 Answered A
    tool_choice("required") forces the agent to invoke a tool every time. Since the MCP tool is the only applicable tool, the agent will use it on every run, ensuring grounded responses with citations instead of answering from the base model.
  13. rqFamily 👍 1 Answered A
    Force-by-type works only when the type uniquely identifies one tool, so you do tool_choice={"type":"file_search"}, otherwise you do {"type":"mcp","name":"mcptoolname"}, so our only option is A
  14. Srikantha 👍 1 Answered A
    Why Option D is Incorrect Option D (tool_choice={"type":"mcp"}) is incorrect because it violates the expected schema for the Azure OpenAI API, which powers Microsoft Foundry agents.
  15. Jerry_Mouse 👍 1 Answered D
    Option A allows for the use of any available tool, not necessarily one specified in the requirements. Furthermore, the text of Option A contains grammatical errors.
  16. Danielly 👍 1 Answered D
    Its D because tool_choice="required" only forces it to use a tool its not speficifed if the agent has other tools . Then you have to force that SPECIFIC tool

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All AI-103 Questions

Access 88 questions with complete answers and detailed explanations.

View Full AI-103 Practice Test →

← Back to AI-103 Study Guide