Skip to main content
v2

MCP Deep Dive (v2.0.9)

This page shows the exact MCP execution order using the confirmation-first Loan Application flow.

Exact phase order in the confirmation-first loan flow

  1. SchemaExtractionStep completes field extraction.
  2. POST_SCHEMA_EXTRACTION rules can move the flow into CONFIRMATION.
  3. CorrectionStep can patch edits or set routing_decision=PROCEED_CONFIRMED.
  4. PRE_AGENT_MCP rules run inside McpToolStep before planner/tool execution and can move CONFIRMATION -> PROCESS_APPLICATION.
  5. POST_AGENT_MCP rules run after MCP work finishes.
  6. PRE_RESPONSE_RESOLUTION rules run next.
  7. ResponseResolutionStep runs after both rule passes.

So yes, MCP turns can now be shaped by both the new pre-MCP phase and the existing post-MCP / pre-response phases.

Prompt-template interaction semantics

ce_prompt_template now carries two fields that consumers should treat as the canonical turn contract:

  • interaction_mode: broad semantics for the turn (COLLECT, CONFIRM, PROCESSING, FINAL, and related modes)
  • interaction_contract: extensible JSON for concrete capabilities and expectations

Recommended interaction_mode values:

  • NORMAL: generic prompt with no special turn contract
  • IDLE: waiting for the user to begin or restate the task
  • COLLECT: gather missing required fields
  • CONFIRM: allow affirm/edit over already-collected values
  • PROCESSING: keep work in progress; retry can be enabled here
  • FINAL: terminal response branch
  • ERROR: failure branch
  • DISAMBIGUATE: ask the user to choose between options
  • FOLLOW_UP: follow-up question branch
  • PENDING_ACTION: approval/pending-action branch
  • REVIEW: evidence review branch

Recommended interaction_contract shape:

{"allows":["affirm","edit","retry","reset"],"expects":["structured_input"]}

Current conventions:

  • allows: turn capabilities such as affirm, edit, retry, reset
  • expects: input expectations such as structured_input

This is the preferred place to model confirmation and retry semantics. Do not rely on state name substrings such as CONFIRM.

Guardrail blocked path

For MCP_STATUS=GUARDRAIL_BLOCKED_NEXT_TOOL:

  1. McpToolStep writes McpConstants.FALLBACK_GUARDRAIL_BLOCKED to context.mcp.finalAnswer.
  2. POST_AGENT_MCP rules run.
  3. PRE_RESPONSE_RESOLUTION rules run.
  4. ce_response + ce_prompt_template still shape final user text.

Example 3: Confirmation-first Loan Application

Turn 1 - User
I need a loan for my customer. Customer id 1234, 35000, 24 months.
Turn 1 - Assistant
Please confirm: customerId 1234, requestedAmount 35000, tenureMonths 24. Proceed?
Turn 2 - User
Oh wait, change amount to 350000.
Turn 2 - Assistant
Updated. Please confirm: customerId 1234, requestedAmount 350000, tenureMonths 24. Proceed?
Turn 3 - User
Looks good, go ahead.
Turn 3 - Internal MCP Loop
PRE_AGENT_MCP moves state to PROCESS_APPLICATION. Planner executes rating -> fraud -> debt -> submit.
Turn 3 - Rules + Final
Loan application submitted for customer 1234. Amount 350000, tenure 24 months. Application ID LA-90311.

Rule-ready JSON_PATH recipes

$[?(@.context.mcp.lifecycle.finished == true && @.context.mcp.lifecycle.outcome == 'BLOCKED')]
$[?(@.context.mcp.lifecycle.error == true)]
$[?(@.context.mcp.toolExecution.phase == 'POST_TOOL_EXECUTION' && @.context.mcp.toolExecution.status == 'SUCCESS')]
$[?(@.context.mcp.toolExecution.scopeMismatch == true)]
Recommended production pattern

Use ce_rule for deterministic transitions and keep final wording in ce_response/ce_prompt_template. Use context.mcp.* as rule evidence, then let response resolution produce final output.