Teams消息协议服务器

一个提供读取和发送Microsoft Teams消息工具的模型上下文协议服务器,适用于需要集成Teams聊天功能的各种客户端。

  • by arozumenko
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 elitea-ai/teams-mcp

使用说明

mcp-server-teams

A Model Context Protocol server providing tools to read and send Microsoft Teams messages.

Authenticate with your Microsoft account using device-code flow and give any MCP-compatible client — Claude Desktop, Cursor, VS Code, or your own agent — read/write access to Teams chats, teams, and channels.

Features

Tool Description
login Start device-code authentication (returns code + URL)
login-complete Complete authentication after entering the code
logout Clear cached tokens
list-chats List recent chats with pagination
list-chats-next Fetch next page of chats
list-chat-messages Read messages from a chat
list-chat-members List members of a chat
find-chat Search chats by person name or topic
send-chat-message Send a message to a chat
list-joined-teams List teams you belong to
list-team-channels List channels in a team

Quick Start

# Run directly with uvx (no install needed)
uvx mcp-server-teams

Then call login from your MCP client. You'll receive a code — enter it at the URL in your browser. After that, call login-complete to finish authentication.

CLI Options

mcp-server-teams --client-id YOUR_APP_ID --tenant-id YOUR_TENANT_ID

MCP Client Configuration

Claude Desktop / Cursor

Add to your MCP config:

{
  "mcpServers": {
    "teams": {
      "command": "uvx",
      "args": ["mcp-server-teams"]
    }
  }
}

With custom Azure AD app

{
  "mcpServers": {
    "teams": {
      "command": "uvx",
      "args": ["mcp-server-teams"],
      "env": {
        "TEAMS_CLIENT_ID": "your-app-client-id",
        "TEAMS_TENANT_ID": "your-tenant-id"
      }
    }
  }
}

With CLI arguments

{
  "mcpServers": {
    "teams": {
      "command": "uvx",
      "args": ["mcp-server-teams", "--client-id", "your-app-id", "--tenant-id", "your-tenant-id"]
    }
  }
}

Configuration

Environment Variable Default Description
TEAMS_CLIENT_ID Pre-registered public client Azure AD application (client) ID
TEAMS_TENANT_ID common Azure AD directory (tenant) ID
TEAMS_TOKEN_CACHE ~/.teams-mcp/token_cache.json Path to token cache file
TEAMS_CACHE_DIR ~/.teams-mcp/ Directory for contacts cache

Authentication

The server uses device code flow — a two-step process designed for headless environments:

  1. Call login → receive a code and URL
  2. Open the URL in any browser, enter the code, sign in
  3. Call login-complete → server exchanges the code for tokens

Tokens are cached locally and refreshed automatically. Call logout to clear them.

Required Scopes

  • User.Read — read your profile
  • Chat.Read — read chat messages
  • ChatMessage.Send — send chat messages
  • Team.ReadBasic.All — list teams
  • Channel.ReadBasic.All — list channels

All scopes use delegated (user-consent) permissions — no admin approval needed.

Development

git clone https://github.com/elitea-ai/teams-mcp.git
cd teams-mcp
uv sync --dev
uv run pytest

License

MIT