Microsoft Graph MCP
Enables AI assistants to interact with Microsoft 365 through the Microsoft Graph API, including searching Teams messages, managing chats, and sending messages.
README
Microsoft Graph MCP
A Model Context Protocol (MCP) server that connects AI assistants to Microsoft Graph API. Search Teams messages, manage chats, send messages, and interact with your Microsoft 365 environment through natural language in Claude and other AI assistants.
🚀 Quick Start
Configuration
Claude Code
Add the server using the Claude Code CLI:
claude mcp add -s user \
microsoft-graph \
npx mcp-microsoft-graph@latest \
-e "MS_GRAPH_CLIENT_ID=your_client_id" \
-e "MS_GRAPH_TENANT_ID=your_tenant_id"
Manual Configuration (Any MCP Client)
Alternatively, add this configuration to your MCP client's configuration file:
{
"mcpServers": {
"microsoft-graph": {
"command": "npx",
"args": ["mcp-microsoft-graph@latest"],
"type": "stdio",
"env": {
"MS_GRAPH_CLIENT_ID": "your_client_id",
"MS_GRAPH_TENANT_ID": "your_tenant_id"
}
}
}
}
Get Your Azure AD Credentials
To get your CLIENT_ID and TENANT_ID:
- Go to Azure Portal → Azure Active Directory → App registrations
- Click New registration
- Give it a name (e.g., "MCP Microsoft Graph")
- Set Supported account types to "Single tenant"
- Click Register
- Copy the Application (client) ID - this is your
MS_GRAPH_CLIENT_ID - Copy the Directory (tenant) ID - this is your
MS_GRAPH_TENANT_ID
Required Permissions
Configure these permissions in your Azure AD app:
- Go to API permissions → Add a permission → Microsoft Graph → Delegated permissions
- Add these permissions:
User.Read- Read user profileUser.ReadBasic.All- Read all users' basic profilesChat.ReadBasic- Read basic chat propertiesChat.ReadWrite- Read and write chatsChatMessage.Read- Read chat messagesChatMessage.Send- Send chat messages
- Click Grant admin consent (if you have admin rights)
Authenticate
Run the authentication command once to sign in:
npm run auth
This will open a browser window for you to sign in with your Microsoft account.
✨ Features
- 💬 Teams Chat Management - Search, create, and manage Teams chats
- 📨 Message Operations - Send messages, search conversations, get chat history
- 👥 User Discovery - Search users and get profile information
- 🔍 Powerful Search - Search across all Teams messages with KQL syntax
- 🎯 Smart Mentions - @mention users in messages
- 🔒 OAuth Authentication - Secure Azure AD authentication flow
- 🎨 Rich Formatting - Markdown support in messages
🛠️ Available Tools
The server provides 8 MCP tools for Microsoft Graph operations:
User Management
get_current_user- Get your own profile informationsearch_users- Search for users by name or emailget_user- Get detailed information about a specific user
Chat Operations
search_chats- Search chats by topic or member namecreate_chat- Create new 1:1 or group chats
Message Operations
get_chat_messages- Retrieve messages from a specific chatsend_chat_message- Send messages with Markdown and mentionssearch_messages- Search across all Teams messages using KQL
💡 Example Queries
- "Search for chats with John Smith"
- "Show me recent messages from the Engineering chat"
- "Send a message to the Dev Team chat saying the deployment is complete"
- "Search all Teams messages mentioning the Q4 roadmap"
- "Create a group chat with Alice, Bob, and Carol about the new project"
- "Find all urgent messages from last week"
- "Get my user profile information"
🏗️ Development
From Source
# Clone and setup
git clone https://github.com/evrimalacan/mcp-microsoft-graph.git
cd mcp-microsoft-graph
npm install
# Set up credentials
cp .env.example .env.local
# Edit .env.local with your CLIENT_ID and TENANT_ID
# Build
npm run build
# Authenticate
npm run auth
# Development mode
npm run dev
# Run tests
npm test
Adding New Tools
- Create a new tool file in the appropriate domain folder under
src/tools/ - Export it from the domain's
index.ts - Register it in
src/tools/index.ts
See the existing tools for examples and patterns.
🐛 Troubleshooting
Common Issues
"Authentication failed"
- Run
npm run authto authenticate again - Verify your CLIENT_ID and TENANT_ID are correct
- Check that your Azure AD app has the required permissions
"Access forbidden"
- Ensure your Azure AD app has the necessary permissions granted
- Check if admin consent is required and has been granted
- Verify you're signed in with the correct account
"Token expired"
- Run
npm run authto refresh your authentication - Check that the token file path is accessible
"Chat not found"
- Verify the chat ID is correct
- Ensure you have access to the chat
- Check that the chat still exists
📚 Documentation
- Microsoft Graph Explorer - Interactive API testing
- Microsoft Graph Documentation - Official API reference
- Model Context Protocol - MCP specification
🤝 Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Add tests for your changes
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
MIT License - see LICENSE file for details.
🌟 Support
- 🐛 Bug Reports: GitHub Issues
- 💡 Feature Requests: GitHub Discussions
Built for seamless Microsoft Teams integration with AI assistants
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。