````prompt
mode: 'agent'
tools: ['changes', 'search/codebase', 'edit/editFiles', 'problems']
description: 'Create a declarative agent for Microsoft 365 Copilot by integrating an MCP server with authentication, tool selection, and configuration'
model: 'gpt-4.1'
tags: [mcp, m365-copilot, declarative-agent, model-context-protocol, api-plugin]
Create a complete declarative agent for Microsoft 365 Copilot that integrates with a Model Context Protocol (MCP) server to access external systems and data.
Generate the following project structure using Microsoft 365 Agents Toolkit:
appPackage/manifest.json - Teams app manifest with plugin reference:
{
"$schema": "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.schema.json",
"manifestVersion": "devPreview",
"version": "1.0.0",
"id": "...",
"developer": {
"name": "...",
"websiteUrl": "...",
"privacyUrl": "...",
"termsOfUseUrl": "..."
},
"name": {
"short": "Agent Name",
"full": "Full Agent Name"
},
"description": {
"short": "Short description",
"full": "Full description"
},
"copilotAgents": {
"declarativeAgents": [
{
"id": "declarativeAgent",
"file": "declarativeAgent.json"
}
]
}
}
appPackage/declarativeAgent.json - Agent definition:
{
"$schema": "https://aka.ms/json-schemas/copilot/declarative-agent/v1.0/schema.json",
"version": "v1.0",
"name": "Agent Name",
"description": "Agent description",
"instructions": "You are an assistant that helps with [specific domain]. Use the available tools to [capabilities].",
"capabilities": [
{
"name": "WebSearch",
"websites": [
{
"url": "https://learn.microsoft.com"
}
]
},
{
"name": "MCP",
"file": "ai-plugin.json"
}
]
}
appPackage/ai-plugin.json - MCP plugin manifest:
{
"schema_version": "v2.1",
"name_for_human": "Service Name",
"description_for_human": "Description for users",
"description_for_model": "Description for AI model",
"contact_email": "support@company.com",
"namespace": "serviceName",
"capabilities": {
"conversation_starters": [
{
"text": "Example query 1"
}
]
},
"functions": [
{
"name": "functionName",
"description": "Function description",
"capabilities": {
"response_semantics": {
"data_path": "$",
"properties": {
"title": "$.title",
"subtitle": "$.description"
}
}
}
}
],
"runtimes": [
{
"type": "MCP",
"spec": {
"url": "https://api.service.com/mcp/"
},
"run_for_functions": ["functionName"],
"auth": {
"type": "OAuthPluginVault",
"reference_id": "${{OAUTH_REFERENCE_ID}}"
}
}
]
}
/.vscode/mcp.json - MCP server configuration:
{
"serverUrl": "https://api.service.com/mcp/",
"pluginFilePath": "appPackage/ai-plugin.json"
}
The MCP server must provide:
When importing from MCP:
OAuth 2.0 (Static Registration)
"auth": {
"type": "OAuthPluginVault",
"reference_id": "${{OAUTH_REFERENCE_ID}}",
"authorization_url": "https://auth.service.com/authorize",
"client_id": "${{CLIENT_ID}}",
"client_secret": "${{CLIENT_SECRET}}",
"scope": "read write"
}
Single Sign-On (SSO)
"auth": {
"type": "SSO"
}
Use response_semantics to extract relevant fields from API responses:
"capabilities": {
"response_semantics": {
"data_path": "$.results",
"properties": {
"title": "$.name",
"subtitle": "$.description",
"url": "$.link"
}
}
}
See the mcp-create-adaptive-cards prompt for adding visual card templates.
Create .env.local or .env.dev for credentials:
OAUTH_REFERENCE_ID=your-oauth-reference-id
CLIENT_ID=your-client-id
CLIENT_SECRET=your-client-secret
URL: https://api.githubcopilot.com/mcp/
Tools: search_repositories, search_users, get_repository
Auth: OAuth 2.0
URL: https://your-domain.atlassian.net/mcp/
Tools: search_issues, create_issue, update_issue
Auth: OAuth 2.0
URL: https://api.your-service.com/mcp/
Tools: Custom tools exposed by your service
Auth: OAuth 2.0 or SSO
Ask the user:
Then generate:
````