|
36 | 36 | # Message functions |
37 | 37 | send_webex_message, send_webex_message_with_mentions, |
38 | 38 | list_webex_messages, delete_webex_message, |
| 39 | + update_webex_message, get_webex_attachment_action, |
39 | 40 | # Space message aliases |
40 | 41 | send_webex_space_message, list_webex_space_messages, |
41 | 42 | # Adaptive card tools |
@@ -105,6 +106,8 @@ async def dispatch(self, request, call_next): |
105 | 106 | mcp.tool()(send_webex_message_with_mentions) |
106 | 107 | mcp.tool()(list_webex_messages) |
107 | 108 | mcp.tool()(delete_webex_message) |
| 109 | +mcp.tool()(update_webex_message) |
| 110 | +mcp.tool()(get_webex_attachment_action) |
108 | 111 |
|
109 | 112 | # Space message aliases |
110 | 113 | mcp.tool()(send_webex_space_message) |
@@ -1117,6 +1120,124 @@ def webex_design_adaptive_card_prompt(): |
1117 | 1120 | } |
1118 | 1121 |
|
1119 | 1122 |
|
| 1123 | +@mcp.prompt("webex-handle-card-submission") |
| 1124 | +def webex_handle_card_submission_prompt(): |
| 1125 | + """Process an Adaptive Card form submission received by the bot application""" |
| 1126 | + return { |
| 1127 | + "name": "Handle Card Submission", |
| 1128 | + "description": ( |
| 1129 | + "Given an action_id from an attachmentActions webhook your bot application " |
| 1130 | + "already received, fetch the submitted form data and act on it — reply to " |
| 1131 | + "the room, update the original message, or route the inputs to a workflow." |
| 1132 | + ), |
| 1133 | + "arguments": [ |
| 1134 | + { |
| 1135 | + "name": "action_id", |
| 1136 | + "description": ( |
| 1137 | + "The attachment action ID from payload[\"data\"][\"id\"] in the " |
| 1138 | + "webhook POST your bot application received from Webex" |
| 1139 | + ), |
| 1140 | + "required": True |
| 1141 | + }, |
| 1142 | + { |
| 1143 | + "name": "intended_action", |
| 1144 | + "description": ( |
| 1145 | + "What to do with the submitted data, e.g. " |
| 1146 | + "\"approve the request and notify the room\", " |
| 1147 | + "\"store the feedback and confirm to the user\", " |
| 1148 | + "\"update the original card message with the outcome\"" |
| 1149 | + ), |
| 1150 | + "required": True |
| 1151 | + } |
| 1152 | + ], |
| 1153 | + "template": """Process an Adaptive Card form submission. |
| 1154 | +
|
| 1155 | +IMPORTANT — how action_id reaches you: |
| 1156 | +This MCP server cannot receive inbound webhook events. Your separate bot |
| 1157 | +application received a POST from Webex at its registered webhook endpoint and |
| 1158 | +extracted the action_id from payload["data"]["id"]. That ID is what you are |
| 1159 | +working with now. |
| 1160 | +
|
| 1161 | +Action ID: {action_id} |
| 1162 | +Intended action: {intended_action} |
| 1163 | +
|
| 1164 | +Steps: |
| 1165 | +
|
| 1166 | +1. Call get_webex_attachment_action(action_id="{action_id}") to retrieve the |
| 1167 | + full submission. The response data contains: |
| 1168 | + - inputs: dict of form field values the user submitted |
| 1169 | + - messageId: the card message that was interacted with |
| 1170 | + - roomId: the room where the interaction happened |
| 1171 | + - personId: the person who submitted the card |
| 1172 | +
|
| 1173 | +2. Inspect the inputs dict and summarise what the user submitted. |
| 1174 | +
|
| 1175 | +3. Carry out the intended action: {intended_action} |
| 1176 | + Common patterns: |
| 1177 | + - Send a confirmation: call send_webex_message(room_id=roomId, markdown="...") |
| 1178 | + - Update the original card message: call update_webex_message( |
| 1179 | + message_id=messageId, markdown="...outcome summary...") |
| 1180 | + - Both: update the card to show it is resolved, then send a threaded reply |
| 1181 | + with details using parent_id=messageId |
| 1182 | +
|
| 1183 | +4. Report what was done: the action_id, the inputs received, and the actions taken. |
| 1184 | +
|
| 1185 | +If get_webex_attachment_action returns a 404, the action_id may be wrong or |
| 1186 | +the bot token may not have access to that action. Confirm the ID came from a |
| 1187 | +webhook payload for the attachmentActions resource (event: created) and that |
| 1188 | +the webhook was registered via create_webex_webhook.""" |
| 1189 | + } |
| 1190 | + |
| 1191 | + |
| 1192 | +@mcp.prompt("webex-edit-message") |
| 1193 | +def webex_edit_message_prompt(): |
| 1194 | + """Correct or update an existing Webex message by its ID""" |
| 1195 | + return { |
| 1196 | + "name": "Edit Message", |
| 1197 | + "description": ( |
| 1198 | + "Update the content of an existing Webex message — fix a typo, " |
| 1199 | + "change a status, or replace stale information — using update_webex_message." |
| 1200 | + ), |
| 1201 | + "arguments": [ |
| 1202 | + { |
| 1203 | + "name": "message_id", |
| 1204 | + "description": "ID of the message to edit", |
| 1205 | + "required": True |
| 1206 | + }, |
| 1207 | + { |
| 1208 | + "name": "new_content", |
| 1209 | + "description": "The replacement text or markdown to put in the message", |
| 1210 | + "required": True |
| 1211 | + }, |
| 1212 | + { |
| 1213 | + "name": "reason", |
| 1214 | + "description": "Optional: why the message is being edited (for your own context)", |
| 1215 | + "required": False |
| 1216 | + } |
| 1217 | + ], |
| 1218 | + "template": """Edit an existing Webex message. |
| 1219 | +
|
| 1220 | +Message ID: {message_id} |
| 1221 | +New content: {new_content} |
| 1222 | +Reason: {reason or "not specified"} |
| 1223 | +
|
| 1224 | +Steps: |
| 1225 | +
|
| 1226 | +1. Call update_webex_message with: |
| 1227 | + - message_id: "{message_id}" |
| 1228 | + - markdown: the corrected content (preferred), or text if plain text is sufficient |
| 1229 | +
|
| 1230 | + Note: only the bot or user that sent the original message can edit it. |
| 1231 | + A 403 means the bot did not send that message; a 404 means the ID is wrong |
| 1232 | + or the message has been deleted. |
| 1233 | +
|
| 1234 | +2. Confirm the update succeeded and show the new content that was set. |
| 1235 | +
|
| 1236 | +If the new content contains formatting (bold, lists, links), pass it as |
| 1237 | +markdown. If it is plain text only, either parameter works.""" |
| 1238 | + } |
| 1239 | + |
| 1240 | + |
1120 | 1241 | @mcp.prompt("webex-setup-webhook") |
1121 | 1242 | def webex_setup_webhook_prompt(): |
1122 | 1243 | """Register a new Webex webhook for a specific resource and event""" |
@@ -1310,9 +1431,9 @@ def server_version(): |
1310 | 1431 | "streamable-http", "stdio", |
1311 | 1432 | "error-handling", "versioning" |
1312 | 1433 | ], |
1313 | | - "tools_count": 40, |
| 1434 | + "tools_count": 42, |
1314 | 1435 | "resources_count": 11, |
1315 | | - "prompts_count": 11, |
| 1436 | + "prompts_count": 13, |
1316 | 1437 | "breaking_changes": { |
1317 | 1438 | "1.0.0": [ |
1318 | 1439 | "Initial release with structured error handling", |
|
0 commit comments