Create MCP Declarative Agent for M365 Copilot

Create MCP Declarative Agent for M365 Copilot

Walks a coding agent through scaffolding a Microsoft 365 Copilot declarative agent that connects to an MCP server, including tool selection, authentication and manifests.

Skill files1 file
SKILL.md316 lines
1
---
2
name: mcp-create-declarative-agent
3
description: 'Skill converted from mcp-create-declarative-agent.prompt.md'
4
---
5
6
````prompt
7
---
8
mode: 'agent'
9
tools: ['changes', 'search/codebase', 'edit/editFiles', 'problems']
10
description: 'Create a declarative agent for Microsoft 365 Copilot by integrating an MCP server with authentication, tool selection, and configuration'
11
model: 'gpt-4.1'
12
tags: [mcp, m365-copilot, declarative-agent, model-context-protocol, api-plugin]
13
---
14
15
# Create MCP-based Declarative Agent for Microsoft 365 Copilot
16
17
Create a complete declarative agent for Microsoft 365 Copilot that integrates with a Model Context Protocol (MCP) server to access external systems and data.
18
19
## Requirements
20
21
Generate the following project structure using Microsoft 365 Agents Toolkit:
22
23
### Project Setup
24
1. **Scaffold declarative agent** via Agents Toolkit
25
2. **Add MCP action** pointing to MCP server
26
3. **Select tools** to import from MCP server
27
4. **Configure authentication** (OAuth 2.0 or SSO)
28
5. **Review generated files** (manifest.json, ai-plugin.json, declarativeAgent.json)
29
30
### Key Files Generated
31
32
**appPackage/manifest.json** - Teams app manifest with plugin reference:
33
```json
34
{
35
"$schema": "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.schema.json",
36
"manifestVersion": "devPreview",
37
"version": "1.0.0",
38
"id": "...",
39
"developer": {
40
"name": "...",
41
"websiteUrl": "...",
42
"privacyUrl": "...",
43
"termsOfUseUrl": "..."
44
},
45
"name": {
46
"short": "Agent Name",
47
"full": "Full Agent Name"
48
},
49
"description": {
50
"short": "Short description",
51
"full": "Full description"
52
},
53
"copilotAgents": {
54
"declarativeAgents": [
55
{
56
"id": "declarativeAgent",
57
"file": "declarativeAgent.json"
58
}
59
]
60
}
61
}
62
```
63
64
**appPackage/declarativeAgent.json** - Agent definition:
65
```json
66
{
67
"$schema": "https://aka.ms/json-schemas/copilot/declarative-agent/v1.0/schema.json",
68
"version": "v1.0",
69
"name": "Agent Name",
70
"description": "Agent description",
71
"instructions": "You are an assistant that helps with [specific domain]. Use the available tools to [capabilities].",
72
"capabilities": [
73
{
74
"name": "WebSearch",
75
"websites": [
76
{
77
"url": "https://learn.microsoft.com"
78
}
79
]
80
},
81
{
82
"name": "MCP",
83
"file": "ai-plugin.json"
84
}
85
]
86
}
87
```
88
89
**appPackage/ai-plugin.json** - MCP plugin manifest:
90
```json
91
{
92
"schema_version": "v2.1",
93
"name_for_human": "Service Name",
94
"description_for_human": "Description for users",
95
"description_for_model": "Description for AI model",
96
"contact_email": "support@company.com",
97
"namespace": "serviceName",
98
"capabilities": {
99
"conversation_starters": [
100
{
101
"text": "Example query 1"
102
}
103
]
104
},
105
"functions": [
106
{
107
"name": "functionName",
108
"description": "Function description",
109
"capabilities": {
110
"response_semantics": {
111
"data_path": "$",
112
"properties": {
113
"title": "$.title",
114
"subtitle": "$.description"
115
}
116
}
117
}
118
}
119
],
120
"runtimes": [
121
{
122
"type": "MCP",
123
"spec": {
124
"url": "https://api.service.com/mcp/"
125
},
126
"run_for_functions": ["functionName"],
127
"auth": {
128
"type": "OAuthPluginVault",
129
"reference_id": "${{OAUTH_REFERENCE_ID}}"
130
}
131
}
132
]
133
}
134
```
135
136
**/.vscode/mcp.json** - MCP server configuration:
137
```json
138
{
139
"serverUrl": "https://api.service.com/mcp/",
140
"pluginFilePath": "appPackage/ai-plugin.json"
141
}
142
```
143
144
## MCP Server Integration
145
146
### Supported MCP Endpoints
147
The MCP server must provide:
148
- **Server metadata** endpoint
149
- **Tools listing** endpoint (exposes available functions)
150
- **Tool execution** endpoint (handles function calls)
151
152
### Tool Selection
153
When importing from MCP:
154
1. Fetch available tools from server
155
2. Select specific tools to include (for security/simplicity)
156
3. Tool definitions are auto-generated in ai-plugin.json
157
158
### Authentication Types
159
160
**OAuth 2.0 (Static Registration)**
161
```json
162
"auth": {
163
"type": "OAuthPluginVault",
164
"reference_id": "${{OAUTH_REFERENCE_ID}}",
165
"authorization_url": "https://auth.service.com/authorize",
166
"client_id": "${{CLIENT_ID}}",
167
"client_secret": "${{CLIENT_SECRET}}",
168
"scope": "read write"
169
}
170
```
171
172
**Single Sign-On (SSO)**
173
```json
174
"auth": {
175
"type": "SSO"
176
}
177
```
178
179
## Response Semantics
180
181
### Define Data Mapping
182
Use `response_semantics` to extract relevant fields from API responses:
183
184
```json
185
"capabilities": {
186
"response_semantics": {
187
"data_path": "$.results",
188
"properties": {
189
"title": "$.name",
190
"subtitle": "$.description",
191
"url": "$.link"
192
}
193
}
194
}
195
```
196
197
### Add Adaptive Cards (Optional)
198
See the `mcp-create-adaptive-cards` prompt for adding visual card templates.
199
200
## Environment Configuration
201
202
Create `.env.local` or `.env.dev` for credentials:
203
204
```env
205
OAUTH_REFERENCE_ID=your-oauth-reference-id
206
CLIENT_ID=your-client-id
207
CLIENT_SECRET=your-client-secret
208
```
209
210
## Testing & Deployment
211
212
### Local Testing
213
1. **Provision** agent in Agents Toolkit
214
2. **Start debugging** to sideload in Teams
215
3. Test in Microsoft 365 Copilot at https://m365.cloud.microsoft/chat
216
4. Authenticate when prompted
217
5. Query the agent using natural language
218
219
### Validation
220
- Verify tool imports in ai-plugin.json
221
- Check authentication configuration
222
- Test each exposed function
223
- Validate response data mapping
224
225
## Best Practices
226
227
### Tool Design
228
- **Focused functions**: Each tool should do one thing well
229
- **Clear descriptions**: Help the model understand when to use each tool
230
- **Minimal scoping**: Only import tools the agent needs
231
- **Descriptive names**: Use action-oriented function names
232
233
### Security
234
- **Use OAuth 2.0** for production scenarios
235
- **Store secrets** in environment variables
236
- **Validate inputs** on the MCP server side
237
- **Limit scopes** to minimum required permissions
238
- **Use reference IDs** for OAuth registration
239
240
### Instructions
241
- **Be specific** about the agent's purpose and capabilities
242
- **Define behavior** for both successful and error scenarios
243
- **Reference tools** explicitly in instructions when applicable
244
- **Set expectations** for users about what the agent can/cannot do
245
246
### Performance
247
- **Cache responses** when appropriate on MCP server
248
- **Batch operations** where possible
249
- **Set timeouts** for long-running operations
250
- **Paginate results** for large datasets
251
252
## Common MCP Server Examples
253
254
### GitHub MCP Server
255
```
256
URL: https://api.githubcopilot.com/mcp/
257
Tools: search_repositories, search_users, get_repository
258
Auth: OAuth 2.0
259
```
260
261
### Jira MCP Server
262
```
263
URL: https://your-domain.atlassian.net/mcp/
264
Tools: search_issues, create_issue, update_issue
265
Auth: OAuth 2.0
266
```
267
268
### Custom Service
269
```
270
URL: https://api.your-service.com/mcp/
271
Tools: Custom tools exposed by your service
272
Auth: OAuth 2.0 or SSO
273
```
274
275
## Workflow
276
277
Ask the user:
278
1. What MCP server are you integrating with (URL)?
279
2. What tools should be exposed to Copilot?
280
3. What authentication method does the server support?
281
4. What should the agent's primary purpose be?
282
5. Do you need response semantics or Adaptive Cards?
283
284
Then generate:
285
- Complete appPackage/ structure (manifest.json, declarativeAgent.json, ai-plugin.json)
286
- mcp.json configuration
287
- .env.local template
288
- Provisioning and testing instructions
289
290
## Troubleshooting
291
292
### MCP Server Not Responding
293
- Verify server URL is correct
294
- Check network connectivity
295
- Validate MCP server implements required endpoints
296
297
### Authentication Fails
298
- Verify OAuth credentials are correct
299
- Check reference ID matches registration
300
- Confirm scopes are requested properly
301
- Test OAuth flow independently
302
303
### Tools Not Appearing
304
- Ensure mcp.json points to correct server
305
- Verify tools were selected during import
306
- Check ai-plugin.json has correct function definitions
307
- Re-fetch actions from MCP if server changed
308
309
### Agent Not Understanding Queries
310
- Review instructions in declarativeAgent.json
311
- Check function descriptions are clear
312
- Verify response_semantics extract correct data
313
- Test with more specific queries
314
315
````
316

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

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…