Teams安全服务器

一个使用官方Microsoft包的Teams MCP服务器,提供Teams聊天和频道消息管理功能,适用于需要安全通信的企业环境。

  • by imatiach-msft
  • JavaScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 imatiach-msft/teams-mcp

使用说明

Teams MCP服务器(安全)

使用的安全Microsoft Teams MCP服务器 仅限微软官方软件包.

安全

此服务器仅使用官方Microsoft软件包:

包 来源 目的
@azure/identity 微软Azure SDK 身份验证
@microsoft/microsoft-graph-client Microsoft Graph SDK Graph API调用
@modelcontextprotocol/sdk 人类MCP MCP协议

没有第三方身份验证或API包装。

先决条件

  • Node.js 18+
  • Azure命令行界面(az login)-身份验证所需

安装

npm install
npm run build

认证

服务器使用Azure CLI凭据(az login).对于具有阻止Graph API聊天权限的条件访问策略的企业租户,请使用 电力自动化集成 相反。

电力自动化集成(建议企业使用)

如果您的组织阻止Graph API直接访问Teams聊天,您可以使用Power Automate作为桥梁:

一次性设置

  1. 首选 电力自动化
  2. 创建新 即时云流量
  3. 添加触发器: “收到HTTP请求时”
  4. 点击“使用样本有效载荷”并输入: {"message": "Hello"}
  5. 添加操作: “在聊天室或频道中发布消息” (微软团队)
  6. 使用您的目标聊天/频道配置团队操作
  7. 对于“消息”,选择 消息 来自动态内容
  8. 保存并打开流
  9. 从触发器复制HTTP POST URL

用法

# Set your Power Automate flow URL
export POWER_AUTOMATE_URL="https://....powerplatform.com/.../invoke?api-version=1"

# Post a message (uses Azure AD auth automatically)
curl -X POST "$POWER_AUTOMATE_URL" \
  -H "Authorization: Bearer $(az account get-access-token --resource https://service.flow.microsoft.com/ --query accessToken -o tsv)" \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello from MCP!"}'

用法

添加到MCP配置

VS代码(.vscode/mcp.json):

{
  "servers": {
    "teams": {
      "type": "stdio",
      "command": "node",
      "args": ["C:/teams-mcp/dist/index.js"]
    }
  }
}

克劳德桌面(claude_desktop_config.json):

{
  "mcpServers": {
    "teams": {
      "command": "node",
      "args": ["C:/teams-mcp/dist/index.js"]
    }
  }
}

可用工具

工具 说明
get_current_user 获取经过身份验证的用户信息
list_chats 列出用户的团队聊天记录
list_teams 列出已加入的团队
list_channels 列出团队中的频道
send_chat_message 向聊天室发送消息(需要图形权限)
send_channel_message 向频道发送消息(需要图形权限)
get_chat_messages 从聊天中获取消息
get_channel_messages 从频道获取消息
send_via_power_automate 通过Power Automation发送消息 (绕过图形限制)

例子

通过Power Automation发送消息(推荐)

{
  "tool": "send_via_power_automate",
  "arguments": {
    "flowUrl": "https://....powerplatform.com/.../invoke?api-version=1",
    "message": "Hello from MCP!"
  }
}

向聊天室发送消息(需要图形权限)

{
  "tool": "send_chat_message",
  "arguments": {
    "chatId": "19:abc123@thread.v2",
    "message": "Hello from MCP!"
  }
}

许可证

麻省理工学院