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
SchemaExtractionStepcompletes field extraction.POST_SCHEMA_EXTRACTIONrules can move the flow intoCONFIRMATION.CorrectionStepcan patch edits or setrouting_decision=PROCEED_CONFIRMED.PRE_AGENT_MCPrules run insideMcpToolStepbefore planner/tool execution and can moveCONFIRMATION -> PROCESS_APPLICATION.POST_AGENT_MCPrules run after MCP work finishes.PRE_RESPONSE_RESOLUTIONrules run next.ResponseResolutionStepruns 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 contractIDLE: waiting for the user to begin or restate the taskCOLLECT: gather missing required fieldsCONFIRM: allow affirm/edit over already-collected valuesPROCESSING: keep work in progress; retry can be enabled hereFINAL: terminal response branchERROR: failure branchDISAMBIGUATE: ask the user to choose between optionsFOLLOW_UP: follow-up question branchPENDING_ACTION: approval/pending-action branchREVIEW: evidence review branch
Recommended interaction_contract shape:
{"allows":["affirm","edit","retry","reset"],"expects":["structured_input"]}
Current conventions:
allows: turn capabilities such asaffirm,edit,retry,resetexpects: input expectations such asstructured_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:
McpToolStepwritesMcpConstants.FALLBACK_GUARDRAIL_BLOCKEDtocontext.mcp.finalAnswer.POST_AGENT_MCPrules run.PRE_RESPONSE_RESOLUTIONrules run.ce_response+ce_prompt_templatestill shape final user text.
Example 3: Confirmation-first Loan Application
- Chat + Internal Trace
- Step Graph
- Turn Table
- Direct Tool Mode
Loan MCP flow
Schema -> CONFIRMATION -> PRE_AGENT_MCP -> planner/tool loop -> POST_AGENT_MCP -> PRE_RESPONSE_RESOLUTION -> response
Table impact by stage
| Stage | Reads | Writes | Context impact |
|---|---|---|---|
| Intent/State | ce_intent, ce_intent_classifier, ce_rule | ce_audit | session.intent/session.state |
| Schema + confirm gate | ce_output_schema, ce_prompt_template, ce_rule | ce_audit | state=CONFIRMATION, routing_decision |
| PRE_AGENT_MCP | ce_rule | ce_audit | CONFIRMATION -> PROCESS_APPLICATION |
| MCP planner | ce_mcp_tool, ce_mcp_planner | ce_audit | mcp_action/mcp_tool_code |
| Tool execution | (tool-specific) | ce_audit | context.mcp.observations[] |
| Planner ANSWER | ce_mcp_planner | ce_audit | context.mcp.finalAnswer + lifecycle |
| POST_AGENT_MCP | ce_rule | ce_audit | MCP-driven transition |
| PRE_RESPONSE_RESOLUTION | ce_rule | ce_audit | Final pre-response transition |
| Response resolution | ce_response, ce_prompt_template | ce_audit, ce_conversation | assistant payload |
{
"tool_request": {
"tool_code": "loan.credit.rating.check",
"tool_group": "HTTP_API",
"args": {
"customerId": "CUST-1001"
}
}
}
`POST_TOOL_EXECUTION` sequence
| Step | What happens |
|---|---|
| ToolOrchestrationStep | Executes exactly one tool and writes inputParams.tool_result. |
| Context metadata | Writes context.mcp.toolExecution with status/outcome/meta/result. |
| Rules | Runs `POST_TOOL_EXECUTION` rules for direct-tool mode. |
| RulesStep | Runs `PRE_RESPONSE_RESOLUTION` rules before response resolution. |
| Response | ResponseResolutionStep uses final state/context. |
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)]
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.