From 07eb4def8d4780561b327418945088b02220e0a0 Mon Sep 17 00:00:00 2001 From: james-prodopen Date: Mon, 29 Sep 2025 13:52:59 -0400 Subject: [PATCH] Add MCP prompt audit_and_remind_missing_receipts --- .../modelcontextprotocol/server.py | 18 ++++++++- extend_ai_toolkit/shared/prompts.py | 38 +++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/extend_ai_toolkit/modelcontextprotocol/server.py b/extend_ai_toolkit/modelcontextprotocol/server.py index 578e4e9..664522f 100644 --- a/extend_ai_toolkit/modelcontextprotocol/server.py +++ b/extend_ai_toolkit/modelcontextprotocol/server.py @@ -19,8 +19,7 @@ class ExtendMCPServer(FastMCP): def __init__(self, extend_api: ExtendAPI, configuration: Configuration): super().__init__( - name="Extend MCP Server", - version=_version + name="Extend MCP Server" ) self._extend = extend_api @@ -80,6 +79,21 @@ def __init__(self, extend_api: ExtendAPI, configuration: Configuration): tool.name, tool.description ) + + # Add MCP prompt if required tools are available + allowed_tool_methods = [tool.method.value for tool in configuration.allowed_tools(tools)] + + # Add missing receipt compliance report prompt if both required tools are available + if (ExtendAPITools.GET_TRANSACTIONS.value in allowed_tool_methods and + ExtendAPITools.SEND_RECEIPT_REMINDER.value in allowed_tool_methods): + from extend_ai_toolkit.shared.prompts import audit_and_remind_missing_receipts_prompt + + @self.prompt() + def audit_and_remind_missing_receipts(): + """ + This prompt reports on transactions with missing receipts and sends automated reminders for them. + """ + return audit_and_remind_missing_receipts_prompt @classmethod def default_instance(cls, api_key: str, api_secret: str, configuration: Configuration): diff --git a/extend_ai_toolkit/shared/prompts.py b/extend_ai_toolkit/shared/prompts.py index 4aa1b0e..f064ed4 100644 --- a/extend_ai_toolkit/shared/prompts.py +++ b/extend_ai_toolkit/shared/prompts.py @@ -283,3 +283,41 @@ If you receive a 429 response, it indicates that the user has already received a reminder for this transaction and only one can be sent out every 24 hours. This is useful for following up on missing receipts or encouraging users to submit receipts for transactions that require them. """ + +audit_and_remind_missing_receipts_prompt = """ +This prompt generates an audit of transactions missing receipts and sends automated reminders. + +Follow these steps: +1. Identify all transactions that are missing receipts +2. Generate a comprehensive report of missing receipts +3. Send automated reminder emails to users for all missing receipts + +Follow this exact workflow: + +STEP 1: Retrieve ALL transactions missing receipts using pagination: +a) Start with page 1, call get_transactions with these parameters: + - receipt_missing: true (required - only get transactions missing receipts) + - per_page: 100 + - sort_field: "-date" (get most recent first) + - page: 1 +b) Check the response's "numberOfPages" value +c) If numberOfPages > 1, repeat the call for pages 2, 3, etc. until all pages are retrieved +d) Combine all transactions from all pages into a single list + +STEP 2: Analyze the complete results and create a summary report including: +- Total number of transactions missing receipts (across all pages) +- Total amount in dollars of transactions missing receipts (across all pages) +- Summary of transactions (already sorted by most recent first) + +STEP 3: For each transaction found across ALL pages in Step 1: +- Call send_receipt_reminder with transaction_id parameter +- Track successful reminders sent vs failed attempts +- Note any 429 responses (reminder already sent in last 24 hours) + +STEP 4: Provide a final summary including: +- Missing receipt statistics from Step 2 +- Reminder sending results from Step 3 (total sent, total failed, total already sent recently) +- Compliance recommendations + +Present all information in a clear, professional format suitable for compliance reporting. +"""