m365-helping-agent
Enables managing car repair records through MCP tools, with OAuth authentication via Microsoft Entra ID.
README
HelpingAgent
A learning project demonstrating how to connect a Microsoft 365 Declarative Agent to a remote Model Context Protocol (MCP) server secured with Microsoft Entra ID OAuth authentication.
Overview
HelpingAgent is a Microsoft 365 Copilot Declarative Agent that helps users manage car repair records. Instead of calling a traditional REST API directly, the agent communicates with a remote MCP server over Streamable HTTP. Every tool invocation is protected using OAuth 2.0 with Microsoft Entra ID, ensuring that only authenticated users can access repair data.
The project uses Azure Table Storage (emulated locally using Azurite) as the backend datastore and demonstrates an end-to-end implementation of:
- Microsoft 365 Declarative Agents
- Model Context Protocol (MCP)
- OAuth authentication with Microsoft Entra ID
- Azure Table Storage
- Microsoft 365 Agents Toolkit
Features
Declarative Agent
- List repair records
- View repair details
- Create new repairs
- Update existing repairs
- Filter repairs by assigned technician
Remote MCP Server
- Built using FastMCP
- Uses Streamable HTTP transport
- Exposes repair operations as MCP tools
- Communicates securely with Microsoft 365 Copilot
OAuth Authentication
- Microsoft Entra ID issued Bearer (JWT) tokens
- JWKS-based signature verification
- Validation of:
- Issuer
- Audience
- Required scopes
Data Storage
- Azure Table Storage
- Local development using Azurite
Architecture
Microsoft 365 Copilot
(Declarative Agent)
│
│
OAuth Protected MCP Tool Calls
(Bearer JWT Access Token)
│
▼
MCP Server (FastMCP)
Streamable HTTP Transport
src/mcp_server.py
• JWT Signature Validation
• Issuer Validation
• Audience Validation
• Scope Validation
│
▼
Azure Table Storage
Repairs Table
(Azurite for Local Development)
Repository Structure
| Path | Description |
|---|---|
src/mcp_server.py |
MCP server implementation containing repair tools and OAuth token validation. |
src/init_data.py |
Seeds Azure Table Storage with sample repair records. |
src/repairsData.json |
Sample repair data used during initialization. |
appPackage/repairDeclarativeAgent.json |
Declarative Agent definition. |
appPackage/ai-plugin.json |
Plugin configuration connecting the agent to the remote MCP server. |
appPackage/instruction.txt |
System instructions for the Declarative Agent. |
appPackage/adaptiveCards/ |
Adaptive Card templates used to display repair information. |
appPackage/manifest.json |
Microsoft Teams/Microsoft 365 app manifest. |
infra/azure.bicep |
Azure infrastructure definition. |
m365agents.yml |
Microsoft 365 Agents Toolkit provisioning and deployment pipeline. |
m365agents.local.yml |
Local development pipeline. |
env/ |
Environment configuration files. |
mcp-auth-todo.txt |
OAuth implementation checklist. |
docs/HelpingAgent-Learning-Guide.pdf |
Project learning guide. |
OAuth Authentication Flow
The MCP server is secured using Microsoft Entra ID OAuth.
-
A Microsoft Entra ID application exposes the custom scope:
access_as_user -
The MCP server is configured with:
OAUTH_ACCEPTED_ISSUERSOAUTH_ACCEPTED_AUDIENCESOAUTH_REQUIRED_SCOPESOAUTH_JWKS_URI
-
For every MCP tool call:
- Extract the Bearer token
- Verify the JWT signature using Microsoft's JWKS
- Validate the issuer
- Validate the audience
- Validate the required scope
- Reject unauthorized requests
-
The plugin (
ai-plugin.json) uses:"auth": { "type": "OAuthPluginVault" }Microsoft 365 Copilot handles user authentication, consent, token acquisition, and automatically includes the Bearer token with every MCP request.
-
During provisioning, the Microsoft 365 Agents Toolkit registers the OAuth configuration using the
oauth/registerstep and stores the generated reference ID in the environment configuration for use by the plugin.
Prerequisites
- Python 3.13
- Node.js
- Microsoft 365 Agents Toolkit
- Microsoft 365 Copilot enabled tenant
- Microsoft Entra ID App Registration
- Azure Table Storage (Azurite for local development)
Local Development
Install dependencies
pip install -r requirements.txt
npm install
Start Azurite
npm run start:azurite
Seed sample data
npm run init-data
Start the MCP Server
npm run start:mcp-http
The MCP server runs at:
http://127.0.0.1:3001
Inspect available MCP tools
npm run inspector
Run the legacy HTTP Azure Function (optional)
npm run dev
Run the complete solution
Press F5 in Visual Studio Code using the Microsoft 365 Agents Toolkit.
The toolkit will:
- Provision the application
- Start the MCP server
- Create a Development Tunnel
- Configure OAuth
- Sideload the Declarative Agent into Microsoft 365 Copilot
Environment Configuration
Environment variables are organized by deployment stage.
env/
├── .env.local
├── .env.local.user
├── .env.dev
└── .env.dev.user
.env.*files contain non-secret configuration..env.*.userfiles contain secrets and are excluded from source control.
Important Variables
| Variable | Description |
|---|---|
AZURE_STORAGE_CONNECTION_STRING |
Azure Table Storage connection string. |
OAUTH_ACCEPTED_ISSUERS |
Accepted Microsoft Entra ID issuer(s). |
OAUTH_ACCEPTED_AUDIENCES |
Accepted App ID URI(s). |
OAUTH_REQUIRED_SCOPES |
Required OAuth scope(s). |
OAUTH_JWKS_URI |
Microsoft Entra ID JWKS endpoint. |
MCP_SERVER_URL |
Public MCP server URL. |
Technologies Used
- Microsoft 365 Copilot
- Microsoft 365 Declarative Agents
- Model Context Protocol (MCP)
- FastMCP
- Streamable HTTP
- Microsoft Entra ID
- OAuth 2.0
- JSON Web Tokens (JWT)
- JSON Web Key Sets (JWKS)
- Azure Table Storage
- Azurite
- Microsoft 365 Agents Toolkit
- Python 3.13
Project Status
- ✅ Microsoft 365 Declarative Agent implemented
- ✅ Remote MCP Server implemented
- ✅ Azure Table Storage integration completed
- ✅ OAuth authentication with Microsoft Entra ID implemented
- ✅ JWT validation using JWKS implemented
- ✅ Streamable HTTP transport configured
- ✅ End-to-end communication between Microsoft 365 Copilot and the MCP server verified
Learning Objectives
This project was built as a hands-on learning exercise to understand:
- Building Microsoft 365 Declarative Agents
- Developing MCP servers using FastMCP
- Exposing functionality as MCP tools
- Securing MCP servers with Microsoft Entra ID OAuth
- Validating JWT access tokens using JWKS
- Connecting Microsoft 365 Copilot to remote MCP servers
- Using Azure Table Storage as the backend datastore
- Provisioning and deploying applications with the Microsoft 365 Agents Toolkit
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。