Перейти к содержимому

MCP #30 | AI Follows Your Business Rules - Check Policy Before Cancellation

LZX - QuickFlow

0:00 / 0:00

MCP #30 | AI Follows Your Business Rules - Check Policy Before Cancellation

8 просмотров · 12 дн. назад
LZX - QuickFlow
1 подписчик
8 просмотров · 12 дн. назад
Let AI handle transaction changes while your backend checks business policies and requires confirmation before cancellation. In this QuickFlow, ChatGPT retrieves an existing transaction, changes its dates, recalculates pricing, and checks cancellation terms. The backend returns CONFIRMATION_REQUIRED before a separate confirmed request can apply the cancellation. We inspect the tools and verify the saved changes on the application's web confirmation page. This is episode #30 of QuickFlow’s MCP Series, continuing the transaction created in #29. The demo uses reservations, but the pattern applies to business workflows involving changes, policies, and approval. ━━━━━━━━━━━━━━━━━━━━ 📚 EXPLORE THE MCP SERIES Full series — watch the episodes in order:    • MCP Series | From Zero to Real-World AI Wo...   Previous: MCP #29 — Let AI Complete Transactions Through Chat AI client connection guides:    • MCP Series | Connect AI Clients to Your Se...   ━━━━━━━━━━━━━━━━━━━━ ⏱️ CHAPTERS 00:00 The Danger of Unguarded AI Database Mutations 00:30 Policy-Guarded AI Agent Lifecycle Architecture 00:53 Live Demo: Lookup, Reschedule & Policy-Guarded Cancellation 05:20 Code Mechanism: 4-Tier Lifecycle & Guard Pipeline 06:40 Implementation Checklist & AI Prompt Template 06:58 Outro & Summary ━━━━━━━━━━━━━━━━━━━━ 🚀 THE LIVE WORKFLOW 1. LOOK UP THE TRANSACTION Retrieve the confirmed reservation from episode #29. 2. APPLY A CHANGE Reschedule the dates and update the duration and total amount inside a database transaction. 3. CHECK BUSINESS POLICY Evaluate the demonstrated 48-hour cancellation rule and present the applicable terms. 4. REQUEST CONFIRMATION Return CONFIRMATION_REQUIRED without applying cancellation. 5. CANCEL AND VERIFY Process the confirmed request, release the associated inventory, and inspect the result on the web page. ━━━━━━━━━━━━━━━━━━━━ 💡 WHAT YOU WILL LEARN • How AI tools manage changes to existing transactions. • How backend rules determine cancellation terms. • How to separate an initial request from confirmed execution. • How transactions coordinate date and pricing updates. • How cancellation and inventory release work together. • How to verify persisted changes against the application. ━━━━━━━━━━━━━━━━━━━━ ⚙️ BACKEND TOOLS • reservations_get — retrieve a reservation and evaluate cancellation terms. • reservations_modify — update dates, duration, and amount inside DB::transaction. • reservations_cancel — require confirmation before updating status and releasing inventory. ChatGPT interprets the request. The backend validates and executes the operation. Cancellation changes the reservation's status; it does not permanently purge the record. ━━━━━━━━━━━━━━━━━━━━ 🛠️ AI PROMPT — CURSOR / CLAUDE CODE Extend my Laravel 11 MCP server with booking lifecycle tools, following existing ToolInterface conventions. 1. Implement reservations_get with authorized lookup and the existing 48-hour cancellation policy. 2. Implement reservations_modify to validate dates and update dates, nights, and total amount inside DB::transaction. 3. Implement reservations_cancel as a two-step operation. 4. Without required confirmation, return CONFIRMATION_REQUIRED with the target details and policy warning. Do not change data. 5. Before execution, validate authorization, tenant scope, current state, applicable terms, and required approval. 6. Atomically mark the reservation cancelled and release associated inventory. 7. Return the persisted result and existing web confirmation URL. 8. Roll back related writes if an operation fails. Use existing pricing and inventory rules. Do not treat an AI-supplied confirmation flag as independent proof of human authorization. ━━━━━━━━━━━━━━━━━━━━ 🛠️ TECH STACK & SOURCE CODE ChatGPT • MCP • Laravel 11 / PHP • MySQL https://github.com/lzxuniverse/quickflow ━━━━━━━━━━━━━━━━━━━━ 🔔 ABOUT QUICKFLOW See how AI and software turn everyday business tasks into working workflows. Real problems. Real execution. Verified results. Quick Starter, Master Flow. #MCP #ModelContextProtocol #AIAgents #BusinessRules #HumanInTheLoop #ChatGPT #BusinessAutomation #QuickFlow