Skip to content

Commit 957f3ab

Browse files
Add MCP-based M365 Agents collection
- Create Declarative Agent prompt with MCP server integration - Create Adaptive Cards prompt for visual response templates - Deploy and Manage Agents prompt for admin workflows - Development guidelines instruction file - Collection manifest and reference documentation Based on: - https://devblogs.microsoft.com/microsoft365dev/build-declarative-agents-for-microsoft-365-copilot-with-mcp/ - https://learn.microsoft.com/en-us/microsoft-365-copilot/extensibility/build-mcp-plugins - https://learn.microsoft.com/en-us/microsoft-365-copilot/extensibility/api-plugin-adaptive-cards - https://learn.microsoft.com/en-us/microsoft-365/admin/manage/manage-copilot-agents-integrated-apps
1 parent d929b71 commit 957f3ab

File tree

6 files changed

+1873
-0
lines changed

6 files changed

+1873
-0
lines changed
Lines changed: 325 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,325 @@
1+
# MCP-based M365 Agents Collection
2+
3+
A comprehensive collection of prompts and instructions for building declarative agents with Model Context Protocol (MCP) integration for Microsoft 365 Copilot.
4+
5+
## Overview
6+
7+
The Model Context Protocol (MCP) is a universal standard that allows AI models to integrate with external systems through standardized server endpoints. This collection provides everything you need to build, deploy, and manage MCP-based declarative agents that extend Microsoft 365 Copilot with custom capabilities.
8+
9+
## What is Model Context Protocol?
10+
11+
MCP is an open protocol developed to streamline how AI models connect to external data sources and tools. Instead of custom integration code for each system, MCP provides a consistent interface for:
12+
13+
- **Server Metadata**: Discover available tools and capabilities
14+
- **Tools Listing**: Get function definitions and schemas
15+
- **Tool Execution**: Invoke tools with parameters and receive results
16+
17+
For Microsoft 365 Copilot, this means you can create agents that connect to any MCP-compatible server with point-and-click configuration instead of writing custom code.
18+
19+
## Collection Contents
20+
21+
### Prompts
22+
23+
1. **Create Declarative Agent** ([mcp-create-declarative-agent.prompt.md](prompts/mcp-create-declarative-agent.prompt.md))
24+
- Build declarative agents using Microsoft 365 Agents Toolkit
25+
- Configure MCP server integration with tool import
26+
- Set up OAuth 2.0 or SSO authentication
27+
- Configure response semantics for data extraction
28+
- Package and deploy agents for testing
29+
30+
2. **Create Adaptive Cards** ([mcp-create-adaptive-cards.prompt.md](prompts/mcp-create-adaptive-cards.prompt.md))
31+
- Design static and dynamic Adaptive Card templates
32+
- Configure response semantics (data_path, properties, template_selector)
33+
- Use template language for conditionals and data binding
34+
- Create responsive cards that work across Copilot surfaces
35+
- Implement card actions for user interactions
36+
37+
3. **Deploy and Manage Agents** ([mcp-deploy-manage-agents.prompt.md](prompts/mcp-deploy-manage-agents.prompt.md))
38+
- Deploy agents via Microsoft 365 admin center
39+
- Configure organizational or public store distribution
40+
- Manage agent lifecycle (publish, deploy, block, remove)
41+
- Set up governance and compliance controls
42+
- Monitor agent usage and performance
43+
44+
### Instructions
45+
46+
**MCP M365 Copilot Development Guidelines** ([mcp-m365-copilot.instructions.md](instructions/mcp-m365-copilot.instructions.md))
47+
- Best practices for MCP server design and tool selection
48+
- File organization and project structure
49+
- Response semantics configuration patterns
50+
- Adaptive Card design principles
51+
- Security, governance, and compliance requirements
52+
- Testing and deployment workflows
53+
54+
## Key Concepts
55+
56+
### Declarative Agents
57+
58+
Declarative agents are defined through configuration files rather than code:
59+
- **declarativeAgent.json**: Agent instructions, capabilities, conversation starters
60+
- **ai-plugin.json**: MCP server tools, response semantics, adaptive card templates
61+
- **mcp.json**: MCP server URL, authentication configuration
62+
- **manifest.json**: Teams app manifest for packaging
63+
64+
### MCP Server Integration
65+
66+
The Microsoft 365 Agents Toolkit provides a visual interface for:
67+
1. **Scaffold** a new agent project
68+
2. **Add MCP action** to connect to a server
69+
3. **Choose tools** from the server's available functions
70+
4. **Configure authentication** (OAuth 2.0, SSO)
71+
5. **Generate files** (agent config, plugin manifest)
72+
6. **Test** in m365.cloud.microsoft/chat
73+
74+
### Authentication Patterns
75+
76+
**OAuth 2.0 Static Registration:**
77+
- Pre-register OAuth app with service provider
78+
- Store credentials in .env.local (never commit)
79+
- Reference in ai-plugin.json authentication config
80+
- Users consent once, tokens stored in plugin vault
81+
82+
**Single Sign-On (SSO):**
83+
- Use Microsoft Entra ID for authentication
84+
- Seamless experience for M365 users
85+
- No separate login required
86+
- Ideal for internal organizational agents
87+
88+
### Response Semantics
89+
90+
Extract and format data from MCP server responses:
91+
92+
```json
93+
{
94+
"response_semantics": {
95+
"data_path": "$.items[*]",
96+
"properties": {
97+
"title": "$.name",
98+
"subtitle": "$.description",
99+
"url": "$.html_url"
100+
},
101+
"static_template": { ... }
102+
}
103+
}
104+
```
105+
106+
- **data_path**: JSONPath to extract array or object
107+
- **properties**: Map response fields to Copilot properties
108+
- **template_selector**: Choose dynamic template based on response
109+
- **static_template**: Adaptive Card for visual formatting
110+
111+
### Adaptive Cards
112+
113+
Rich visual responses for agent outputs:
114+
115+
**Static Templates:**
116+
- Defined once in ai-plugin.json
117+
- Used for all responses with same structure
118+
- Better performance and easier maintenance
119+
120+
**Dynamic Templates:**
121+
- Returned in API response body
122+
- Selected via template_selector JSONPath
123+
- Useful for varied response structures
124+
125+
**Template Language:**
126+
- `${property}`: Data binding
127+
- `${if(condition, true, false)}`: Conditionals
128+
- `${formatNumber(value, decimals)}`: Formatting
129+
- `$when`: Conditional element rendering
130+
131+
## Deployment Options
132+
133+
### Organization Deployment
134+
- IT admin deploys to all users or specific groups
135+
- Requires approval in Microsoft 365 admin center
136+
- Best for internal business agents
137+
- Full governance and compliance controls
138+
139+
### Agent Store
140+
- Submit to Partner Center for validation
141+
- Public availability to all Copilot users
142+
- Rigorous security and compliance review
143+
- Suitable for partner-built agents
144+
145+
## Partner Examples
146+
147+
### monday.com
148+
Task and project management integration:
149+
- Create tasks directly from Copilot
150+
- Query project status and updates
151+
- Assign work items to team members
152+
- View deadlines and milestones
153+
154+
### Canva
155+
Design automation capabilities:
156+
- Generate branded content
157+
- Create social media graphics
158+
- Access design templates
159+
- Export in multiple formats
160+
161+
### Sitecore
162+
Content management integration:
163+
- Search content repository
164+
- Create and update content items
165+
- Manage workflows and approvals
166+
- Preview content in context
167+
168+
## Getting Started
169+
170+
### Prerequisites
171+
- Visual Studio Code
172+
- Microsoft 365 Agents Toolkit extension (v6.3.x or later)
173+
- GitHub account (for OAuth examples)
174+
- Microsoft 365 Copilot license
175+
- Access to an MCP-compatible server
176+
177+
### Quick Start
178+
1. Install Microsoft 365 Agents Toolkit in VS Code
179+
2. Use **Create Declarative Agent** prompt to scaffold project
180+
3. Add MCP server URL and choose tools
181+
4. Configure authentication with OAuth or SSO
182+
5. Use **Create Adaptive Cards** prompt to design response templates
183+
6. Test agent at m365.cloud.microsoft/chat
184+
7. Use **Deploy and Manage Agents** prompt for distribution
185+
186+
### Development Workflow
187+
```
188+
1. Scaffold agent project
189+
190+
2. Connect MCP server
191+
192+
3. Import tools
193+
194+
4. Configure authentication
195+
196+
5. Design adaptive cards
197+
198+
6. Test locally
199+
200+
7. Deploy to organization
201+
202+
8. Monitor and iterate
203+
```
204+
205+
## Best Practices
206+
207+
### MCP Server Design
208+
- Import only necessary tools (avoid over-scoping)
209+
- Use secure authentication (OAuth 2.0, SSO)
210+
- Test each tool individually
211+
- Validate server endpoints are HTTPS
212+
- Consider token limits when selecting tools
213+
214+
### Agent Instructions
215+
- Be specific and clear about agent capabilities
216+
- Provide examples of how to interact
217+
- Set boundaries for what agent can/cannot do
218+
- Use conversation starters to guide users
219+
220+
### Response Formatting
221+
- Use JSONPath to extract relevant data
222+
- Map properties clearly (title, subtitle, url)
223+
- Design adaptive cards for readability
224+
- Test cards across Copilot surfaces (Chat, Teams, Outlook)
225+
226+
### Security and Governance
227+
- Never commit credentials to source control
228+
- Use environment variables for secrets
229+
- Follow principle of least privilege
230+
- Review compliance requirements
231+
- Monitor agent usage and performance
232+
233+
## Common Use Cases
234+
235+
### Data Retrieval
236+
- Search external systems
237+
- Fetch user-specific information
238+
- Query databases or APIs
239+
- Aggregate data from multiple sources
240+
241+
### Task Automation
242+
- Create tickets or tasks
243+
- Update records or statuses
244+
- Trigger workflows
245+
- Schedule actions
246+
247+
### Content Generation
248+
- Create documents or designs
249+
- Generate reports or summaries
250+
- Format data into templates
251+
- Export in various formats
252+
253+
### Integration Scenarios
254+
- Connect CRM systems
255+
- Integrate project management tools
256+
- Access knowledge bases
257+
- Connect to custom business apps
258+
259+
## Troubleshooting
260+
261+
### Agent Not Appearing in Copilot
262+
- Verify agent is deployed in admin center
263+
- Check user is in assigned group
264+
- Confirm agent is not blocked
265+
- Refresh Copilot interface
266+
267+
### Authentication Errors
268+
- Validate OAuth credentials in .env.local
269+
- Check scopes match required permissions
270+
- Test auth flow independently
271+
- Verify MCP server is accessible
272+
273+
### Response Formatting Issues
274+
- Test JSONPath expressions with sample data
275+
- Validate data_path extracts expected array/object
276+
- Check property mappings are correct
277+
- Test adaptive card with various response structures
278+
279+
### Performance Problems
280+
- Monitor MCP server response times
281+
- Reduce number of imported tools
282+
- Optimize response data size
283+
- Use caching where appropriate
284+
285+
## Resources
286+
287+
### Official Documentation
288+
- [Build Declarative Agents with MCP (DevBlogs)](https://devblogs.microsoft.com/microsoft365dev/build-declarative-agents-for-microsoft-365-copilot-with-mcp/)
289+
- [Build MCP Plugins (Microsoft Learn)](https://learn.microsoft.com/en-us/microsoft-365-copilot/extensibility/build-mcp-plugins)
290+
- [API Plugin Adaptive Cards (Microsoft Learn)](https://learn.microsoft.com/en-us/microsoft-365-copilot/extensibility/api-plugin-adaptive-cards)
291+
- [Manage Copilot Agents (Microsoft Learn)](https://learn.microsoft.com/en-us/microsoft-365/admin/manage/manage-copilot-agents-integrated-apps)
292+
293+
### Tools and Extensions
294+
- [Microsoft 365 Agents Toolkit](https://marketplace.visualstudio.com/items?itemName=TeamsDevApp.ms-teams-vscode-extension)
295+
- [Adaptive Cards Designer](https://adaptivecards.io/designer/)
296+
- [Teams Toolkit](https://learn.microsoft.com/en-us/microsoftteams/platform/toolkit/teams-toolkit-fundamentals)
297+
298+
### MCP Resources
299+
- [Model Context Protocol Specification](https://modelcontextprotocol.io/)
300+
- [MCP Server Directory](https://github.com/modelcontextprotocol/servers)
301+
- Community MCP servers and examples
302+
303+
### Admin and Governance
304+
- [Microsoft 365 Admin Center](https://admin.microsoft.com/)
305+
- [Power Platform Admin Center](https://admin.powerplatform.microsoft.com/)
306+
- [Partner Center](https://partner.microsoft.com/) for agent submissions
307+
308+
## Support and Community
309+
310+
- Join the [Microsoft 365 Developer Community](https://developer.microsoft.com/en-us/microsoft-365/community)
311+
- Ask questions on [Microsoft Q&A](https://learn.microsoft.com/en-us/answers/products/)
312+
- Share feedback in [Microsoft 365 Copilot GitHub discussions](https://github.com/microsoft/copilot-feedback)
313+
314+
## What's Next?
315+
316+
After mastering MCP-based agents, explore:
317+
- **Advanced tool composition**: Combine multiple MCP servers
318+
- **Custom authentication flows**: Implement custom OAuth providers
319+
- **Complex adaptive cards**: Multi-action cards with dynamic data
320+
- **Agent analytics**: Track usage patterns and optimize
321+
- **Multi-agent orchestration**: Build agents that work together
322+
323+
---
324+
325+
*This collection is maintained by the community and reflects current best practices for MCP-based M365 Copilot agent development. Contributions and feedback welcome!*
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
id: mcp-m365-copilot
2+
name: MCP-based M365 Agents
3+
description: Comprehensive collection for building declarative agents with Model Context Protocol integration for Microsoft 365 Copilot
4+
tags: [mcp, m365-copilot, declarative-agents, api-plugins, model-context-protocol, adaptive-cards]
5+
6+
display:
7+
order: manual
8+
show_badge: true
9+
10+
items:
11+
- kind: prompt
12+
path: prompts/mcp-create-declarative-agent.prompt.md
13+
- kind: prompt
14+
path: prompts/mcp-create-adaptive-cards.prompt.md
15+
- kind: prompt
16+
path: prompts/mcp-deploy-manage-agents.prompt.md
17+
- kind: instruction
18+
path: instructions/mcp-m365-copilot.instructions.md

0 commit comments

Comments
 (0)