MCP Create Adaptive Cards

MCP Create Adaptive Cards

Adds Adaptive Card response templates to MCP-based API plugins so data displays visually in Microsoft 365 Copilot.

Skill files1 file
SKILL.md533 lines
1
---
2
name: mcp-create-adaptive-cards
3
description: 'Skill converted from mcp-create-adaptive-cards.prompt.md'
4
---
5
6
````prompt
7
---
8
mode: 'agent'
9
tools: ['changes', 'search/codebase', 'edit/editFiles', 'problems']
10
description: 'Add Adaptive Card response templates to MCP-based API plugins for visual data presentation in Microsoft 365 Copilot'
11
model: 'gpt-4.1'
12
tags: [mcp, adaptive-cards, m365-copilot, api-plugin, response-templates]
13
---
14
15
# Create Adaptive Cards for MCP Plugins
16
17
Add Adaptive Card response templates to MCP-based API plugins to enhance how data is presented visually in Microsoft 365 Copilot.
18
19
## Adaptive Card Types
20
21
### Static Response Templates
22
Use when API always returns items of the same type and format doesn't change often.
23
24
Define in `response_semantics.static_template` in ai-plugin.json:
25
26
```json
27
{
28
"functions": [
29
{
30
"name": "GetBudgets",
31
"description": "Returns budget details including name and available funds",
32
"capabilities": {
33
"response_semantics": {
34
"data_path": "$",
35
"properties": {
36
"title": "$.name",
37
"subtitle": "$.availableFunds"
38
},
39
"static_template": {
40
"type": "AdaptiveCard",
41
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
42
"version": "1.5",
43
"body": [
44
{
45
"type": "Container",
46
"$data": "${$root}",
47
"items": [
48
{
49
"type": "TextBlock",
50
"text": "Name: ${if(name, name, 'N/A')}",
51
"wrap": true
52
},
53
{
54
"type": "TextBlock",
55
"text": "Available funds: ${if(availableFunds, formatNumber(availableFunds, 2), 'N/A')}",
56
"wrap": true
57
}
58
]
59
}
60
]
61
}
62
}
63
}
64
}
65
]
66
}
67
```
68
69
### Dynamic Response Templates
70
Use when API returns multiple types and each item needs a different template.
71
72
**ai-plugin.json configuration:**
73
```json
74
{
75
"name": "GetTransactions",
76
"description": "Returns transaction details with dynamic templates",
77
"capabilities": {
78
"response_semantics": {
79
"data_path": "$.transactions",
80
"properties": {
81
"template_selector": "$.displayTemplate"
82
}
83
}
84
}
85
}
86
```
87
88
**API Response with Embedded Templates:**
89
```json
90
{
91
"transactions": [
92
{
93
"budgetName": "Fourth Coffee lobby renovation",
94
"amount": -2000,
95
"description": "Property survey for permit application",
96
"expenseCategory": "permits",
97
"displayTemplate": "$.templates.debit"
98
},
99
{
100
"budgetName": "Fourth Coffee lobby renovation",
101
"amount": 5000,
102
"description": "Additional funds to cover cost overruns",
103
"expenseCategory": null,
104
"displayTemplate": "$.templates.credit"
105
}
106
],
107
"templates": {
108
"debit": {
109
"type": "AdaptiveCard",
110
"version": "1.5",
111
"body": [
112
{
113
"type": "TextBlock",
114
"size": "medium",
115
"weight": "bolder",
116
"color": "attention",
117
"text": "Debit"
118
},
119
{
120
"type": "FactSet",
121
"facts": [
122
{
123
"title": "Budget",
124
"value": "${budgetName}"
125
},
126
{
127
"title": "Amount",
128
"value": "${formatNumber(amount, 2)}"
129
},
130
{
131
"title": "Category",
132
"value": "${if(expenseCategory, expenseCategory, 'N/A')}"
133
},
134
{
135
"title": "Description",
136
"value": "${if(description, description, 'N/A')}"
137
}
138
]
139
}
140
],
141
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
142
},
143
"credit": {
144
"type": "AdaptiveCard",
145
"version": "1.5",
146
"body": [
147
{
148
"type": "TextBlock",
149
"size": "medium",
150
"weight": "bolder",
151
"color": "good",
152
"text": "Credit"
153
},
154
{
155
"type": "FactSet",
156
"facts": [
157
{
158
"title": "Budget",
159
"value": "${budgetName}"
160
},
161
{
162
"title": "Amount",
163
"value": "${formatNumber(amount, 2)}"
164
},
165
{
166
"title": "Description",
167
"value": "${if(description, description, 'N/A')}"
168
}
169
]
170
}
171
],
172
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
173
}
174
}
175
}
176
```
177
178
### Combined Static and Dynamic Templates
179
Use static template as default when item doesn't have template_selector or when value doesn't resolve.
180
181
```json
182
{
183
"capabilities": {
184
"response_semantics": {
185
"data_path": "$.items",
186
"properties": {
187
"title": "$.name",
188
"template_selector": "$.templateId"
189
},
190
"static_template": {
191
"type": "AdaptiveCard",
192
"version": "1.5",
193
"body": [
194
{
195
"type": "TextBlock",
196
"text": "Default: ${name}",
197
"wrap": true
198
}
199
]
200
}
201
}
202
}
203
}
204
```
205
206
## Response Semantics Properties
207
208
### data_path
209
JSONPath query indicating where data resides in API response:
210
```json
211
"data_path": "$" // Root of response
212
"data_path": "$.results" // In results property
213
"data_path": "$.data.items"// Nested path
214
```
215
216
### properties
217
Map response fields for Copilot citations:
218
```json
219
"properties": {
220
"title": "$.name", // Citation title
221
"subtitle": "$.description", // Citation subtitle
222
"url": "$.link" // Citation link
223
}
224
```
225
226
### template_selector
227
Property on each item indicating which template to use:
228
```json
229
"template_selector": "$.displayTemplate"
230
```
231
232
## Adaptive Card Template Language
233
234
### Conditional Rendering
235
```json
236
{
237
"type": "TextBlock",
238
"text": "${if(field, field, 'N/A')}" // Show field or 'N/A'
239
}
240
```
241
242
### Number Formatting
243
```json
244
{
245
"type": "TextBlock",
246
"text": "${formatNumber(amount, 2)}" // Two decimal places
247
}
248
```
249
250
### Data Binding
251
```json
252
{
253
"type": "Container",
254
"$data": "${$root}", // Break to root context
255
"items": [ ... ]
256
}
257
```
258
259
### Conditional Display
260
```json
261
{
262
"type": "Image",
263
"url": "${imageUrl}",
264
"$when": "${imageUrl != null}" // Only show if imageUrl exists
265
}
266
```
267
268
## Card Elements
269
270
### TextBlock
271
```json
272
{
273
"type": "TextBlock",
274
"text": "Text content",
275
"size": "medium", // small, default, medium, large, extraLarge
276
"weight": "bolder", // lighter, default, bolder
277
"color": "attention", // default, dark, light, accent, good, warning, attention
278
"wrap": true
279
}
280
```
281
282
### FactSet
283
```json
284
{
285
"type": "FactSet",
286
"facts": [
287
{
288
"title": "Label",
289
"value": "Value"
290
}
291
]
292
}
293
```
294
295
### Image
296
```json
297
{
298
"type": "Image",
299
"url": "https://example.com/image.png",
300
"size": "medium", // auto, stretch, small, medium, large
301
"style": "default" // default, person
302
}
303
```
304
305
### Container
306
```json
307
{
308
"type": "Container",
309
"$data": "${items}", // Iterate over array
310
"items": [
311
{
312
"type": "TextBlock",
313
"text": "${name}"
314
}
315
]
316
}
317
```
318
319
### ColumnSet
320
```json
321
{
322
"type": "ColumnSet",
323
"columns": [
324
{
325
"type": "Column",
326
"width": "auto",
327
"items": [ ... ]
328
},
329
{
330
"type": "Column",
331
"width": "stretch",
332
"items": [ ... ]
333
}
334
]
335
}
336
```
337
338
### Actions
339
```json
340
{
341
"type": "Action.OpenUrl",
342
"title": "View Details",
343
"url": "https://example.com/item/${id}"
344
}
345
```
346
347
## Responsive Design Best Practices
348
349
### Single-Column Layouts
350
- Use single columns for narrow viewports
351
- Avoid multi-column layouts when possible
352
- Ensure cards work at minimum viewport width
353
354
### Flexible Widths
355
- Don't assign fixed widths to elements
356
- Use "auto" or "stretch" for width properties
357
- Allow elements to resize with viewport
358
- Fixed widths OK for icons/avatars only
359
360
### Text and Images
361
- Avoid placing text and images in same row
362
- Exception: Small icons or avatars
363
- Use "wrap": true for text content
364
- Test at various viewport widths
365
366
### Test Across Hubs
367
Validate cards in:
368
- Teams (desktop and mobile)
369
- Word
370
- PowerPoint
371
- Various viewport widths (contract/expand UI)
372
373
## Complete Example
374
375
**ai-plugin.json:**
376
```json
377
{
378
"functions": [
379
{
380
"name": "SearchProjects",
381
"description": "Search for projects with status and details",
382
"capabilities": {
383
"response_semantics": {
384
"data_path": "$.projects",
385
"properties": {
386
"title": "$.name",
387
"subtitle": "$.status",
388
"url": "$.projectUrl"
389
},
390
"static_template": {
391
"type": "AdaptiveCard",
392
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
393
"version": "1.5",
394
"body": [
395
{
396
"type": "Container",
397
"$data": "${$root}",
398
"items": [
399
{
400
"type": "TextBlock",
401
"size": "medium",
402
"weight": "bolder",
403
"text": "${if(name, name, 'Untitled Project')}",
404
"wrap": true
405
},
406
{
407
"type": "FactSet",
408
"facts": [
409
{
410
"title": "Status",
411
"value": "${status}"
412
},
413
{
414
"title": "Owner",
415
"value": "${if(owner, owner, 'Unassigned')}"
416
},
417
{
418
"title": "Due Date",
419
"value": "${if(dueDate, dueDate, 'Not set')}"
420
},
421
{
422
"title": "Budget",
423
"value": "${if(budget, formatNumber(budget, 2), 'N/A')}"
424
}
425
]
426
},
427
{
428
"type": "TextBlock",
429
"text": "${if(description, description, 'No description')}",
430
"wrap": true,
431
"separator": true
432
}
433
]
434
}
435
],
436
"actions": [
437
{
438
"type": "Action.OpenUrl",
439
"title": "View Project",
440
"url": "${projectUrl}"
441
}
442
]
443
}
444
}
445
}
446
}
447
]
448
}
449
```
450
451
## Workflow
452
453
Ask the user:
454
1. What type of data does the API return?
455
2. Are all items the same type (static) or different types (dynamic)?
456
3. What fields should appear in the card?
457
4. Should there be actions (e.g., "View Details")?
458
5. Are there multiple states or categories requiring different templates?
459
460
Then generate:
461
- Appropriate response_semantics configuration
462
- Static template, dynamic templates, or both
463
- Proper data binding with conditional rendering
464
- Responsive single-column layout
465
- Test scenarios for validation
466
467
## Resources
468
469
- [Adaptive Card Designer](https://adaptivecards.microsoft.com/designer) - Visual design tool
470
- [Adaptive Card Schema](https://adaptivecards.io/schemas/adaptive-card.json) - Full schema reference
471
- [Template Language](https://learn.microsoft.com/en-us/adaptive-cards/templating/language) - Binding syntax guide
472
- [JSONPath](https://www.rfc-editor.org/rfc/rfc9535) - Path query syntax
473
474
## Common Patterns
475
476
### List with Images
477
```json
478
{
479
"type": "Container",
480
"$data": "${items}",
481
"items": [
482
{
483
"type": "ColumnSet",
484
"columns": [
485
{
486
"type": "Column",
487
"width": "auto",
488
"items": [
489
{
490
"type": "Image",
491
"url": "${thumbnailUrl}",
492
"size": "small",
493
"$when": "${thumbnailUrl != null}"
494
}
495
]
496
},
497
{
498
"type": "Column",
499
"width": "stretch",
500
"items": [
501
{
502
"type": "TextBlock",
503
"text": "${title}",
504
"weight": "bolder",
505
"wrap": true
506
}
507
]
508
}
509
]
510
}
511
]
512
}
513
```
514
515
### Status Indicators
516
```json
517
{
518
"type": "TextBlock",
519
"text": "${status}",
520
"color": "${if(status == 'Completed', 'good', if(status == 'In Progress', 'attention', 'default'))}"
521
}
522
```
523
524
### Currency Formatting
525
```json
526
{
527
"type": "TextBlock",
528
"text": "$${formatNumber(amount, 2)}"
529
}
530
```
531
532
````
533

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 13,384 prompts

More by @OpenSourceBuffGuy

See all
Oreo cookie twist with cream and crumbs prompt image

Oreo cookie twist with cream and crumbs

Generates a 15-second vertical macro commercial of a sandwich cookie being twisted open, with named beats, a rewind effect and slow-motion cream stretches.

video-prompt, video-ad, product-video, food-photography, macro, slow-motion, camera-movement, timed-beats, multi-shot, vertical-format, photorealistic, studio-lighting, dramatic-lighting, visual-effects, scene-transitions, text-rendering, packaging-design, for-marketers, for-filmmakers, long-form, cinematic, sound-effects

Living room FPV dives into TV toast scene prompt image

Living room FPV dives into TV toast scene

Directs a 15-second one-take FPV flight through a living room into a TV screen that becomes a champagne toast scene, matched to two reference images.

video-prompt, cinematic, single-take, image-to-video, timed-beats, camera-movement, scene-transitions, visual-effects, tracking-shot, long-form, man, photorealistic, soft-lighting, character-consistency, reference-image, negative-prompt, shallow-depth-of-field

Close up beauty portrait with damp hair prompt image

Close up beauty portrait with damp hair

Draws a close-up luxury beauty portrait of a woman with green eyes and damp black hair in golden-hour window light, with an 85mm lens look.

image-prompt, gpt-image, portrait, woman, close-up, beauty, reference-image, face-reference, photorealistic, golden-hour, soft-lighting, natural-light, bokeh, luxury, editorial, hairstyles, headshot, cinematic, for-photographers, long-form, muted-colors

Reviews

Loading reviews…

Discussion

Loading comments…