convez.ai
MCP ServerIntegração & APIsIntermediário
uet-minhtd

MCP Teams Server

uet-minhtd/mcp-teams-server

Integração completa do Teams ao Claude via MCP

Ver no GitHub
InicialPluginScore · de 0 a 100

Servidor MCP que integra Microsoft Teams ao Claude e outras aplicações via Microsoft Graph API. Permite leitura/envio de mensagens, gestão de canais, chats, reuniões e busca de usuários de forma nativa através de tools do protocolo MCP.

Instalação

$npx convez-ai uet-minhtd/mcp-teams-server

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
0
Forks
0
Acompanhando
0
Saúde
14%
Último commit
há 5 meses
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Automatizar envio de mensagens e notificações no Teams
  • Buscar informações de usuários e canais programaticamente
  • Construir assistentes IA que gerenciam Teams como parte de workflows
  • Integrar Teams com outras ferramentas via agents Claude

Veredito

MCP server robusto e bem arquitetado para quem precisa de integração bidirecional com Teams. Implementação completa do protocolo MCP com OAuth2 e suporte a múltiplos clientes, ideal para automações corporativas, mas requer conhecimento intermediário de Microsoft Entra e Graph API.

README

A tradução para o português deste README ainda está na fila.

MCP Teams Server

MCP server tích hợp Microsoft Teams qua Microsoft Graph API. Cho phép AI assistant (Claude Desktop, VS Code, Cursor) tương tác với Teams: đọc/gửi tin nhắn, quản lý kênh, chat, meeting, tìm kiếm người dùng.

Viết từ đầu với TypeScript, không phụ thuộc thư viện cá nhân bên ngoài.

Kiến trúc

MCP Client (Claude Desktop, VS Code, Cursor)
        │
        │  MCP OAuth 2.1 (Bearer token, xác thực qua Microsoft)
        ▼
  MCP Teams Server ──── Express + @modelcontextprotocol/sdk
        │
        │  ClientSecretCredential (Entra App registration)
        ▼
  Microsoft Graph API ──── @microsoft/microsoft-graph-client
        │
        ▼
  Microsoft Teams (users, teams, channels, chats, meetings, messages)

Yêu cầu

  • Node.js 20+
  • Entra App Registration với các quyền Microsoft Graph (xem bảng Tools bên dưới)
  • Microsoft 365 account có Teams

Cài đặt

git clone <repo-url>
cd mcp-teams-from-scratch
npm install
npm run build

Cấu hình

Copy .env.example thành .env và điền thông tin Entra App:

AZURE_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
AZURE_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
AZURE_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
TEAMS_MCP_PORT=8888
TEAMS_MCP_OAUTH=true

Lấy các giá trị này từ Azure Portal → Microsoft Entra ID → App registrations → app của bạn.

Quyền Microsoft Graph cần cấp (API Permissions)

PermissionTypeDùng cho
User.ReadDelegatedauth_status, get_current_user
User.ReadBasic.AllApplicationsearch_users
Team.ReadBasic.AllApplicationlist_teams
Channel.ReadBasic.AllApplicationlist_channels
ChannelMessage.Read.AllApplicationget_channel_messages, search_messages
ChannelMessage.SendApplicationsend_channel_message
Chat.ReadApplicationlist_chats, get_chat_messages, search_messages
Chat.ReadWriteApplicationsend_chat_message
OnlineMeetings.ReadApplicationlist_meetings, get_meeting
OnlineMeetingArtifact.Read.AllApplicationget_meeting_attendance, get_meeting_transcripts

Sau khi thêm permissions, nhấn Grant admin consent.

Chạy

Development (tsx hot-reload)

# STDIO mode (cho local MCP client như Claude Desktop)
npm run dev

# HTTP mode (không OAuth — dùng cho test nội bộ)
npm run dev -- --http

# HTTP mode + OAuth 2.1 (cho remote client như VS Code, Cursor)
npm run dev -- --http --oauth

Production

npm run build
npm start

Docker

docker compose up -d      # build + start
docker compose logs -f    # xem logs
docker compose down       # dừng

MCP endpoint: http://localhost:3000/mcp

Cấu hình MCP Client

Claude Desktop / Claude Code

{
  "mcpServers": {
    "teams-mcp": {
      "command": "npx",
      "args": ["tsx", "D:\\2026\\mcp-teams-from-scratch\\src\\index.ts"],
      "env": {
        "AZURE_CLIENT_ID": "xxx",
        "AZURE_CLIENT_SECRET": "xxx",
        "AZURE_TENANT_ID": "xxx"
      }
    }
  }
}

HTTP mode (VS Code, Cursor, remote clients)

{
  "mcpServers": {
    "teams-mcp": {
      "url": "http://localhost:3000/mcp"
    }
  }
}

MCP Tools (16)

Auth

ToolMô tả
auth_statusKiểm tra trạng thái xác thực với Microsoft Graph

Users

ToolMô tả
get_current_userLấy thông tin user đang đăng nhập
search_usersTìm kiếm user theo tên hoặc email

Teams & Channels

ToolMô tả
list_teamsLiệt kê tất cả teams user là thành viên
list_channelsLiệt kê channels trong một team
get_channel_messagesĐọc tin nhắn từ channel
send_channel_messageGửi tin nhắn vào channel

Chats

ToolMô tả
list_chatsLiệt kê tất cả chats (1:1 và nhóm)
get_chat_messagesĐọc tin nhắn từ chat
send_chat_messageGửi tin nhắn vào chat

Meetings

ToolMô tả
list_meetingsLiệt kê online meetings
get_meetingChi tiết meeting (link join, subject, organizer)
get_meeting_attendanceBáo cáo điểm danh + danh sách tham gia
get_meeting_transcriptsTranscript nội dung meeting (cần Teams Premium)

Search

ToolMô tả
search_messagesTìm kiếm toàn bộ tin nhắn Teams

Luồng xác thực

MCP OAuth 2.1 (Client → Server)

1. Client gửi request không token → 401 + WWW-Authenticate
2. Client lấy Protected Resource Metadata (RFC 9728)
3. Client lấy Authorization Server Metadata (RFC 8414)
4. Client mở browser → Microsoft login → redirect callback → authorization code
5. Client đổi code lấy access token tại /token
6. Client gửi Authorization: Bearer <token> trong mọi MCP request
7. Server validate token bằng cách gọi GET https://graph.microsoft.com/v1.0/me

Graph Auth (Server → Microsoft Graph)

Server dùng ClientSecretCredential (AZURE_CLIENT_ID + AZURE_CLIENT_SECRET + AZURE_TENANT_ID) để lấy access token gọi Graph API. Token được cache trong memory và tự động refresh.

Cấu trúc thư mục

src/
├── index.ts              # Entry point: CLI (--http, --oauth, --help)
├── server.ts             # McpServer factory + STDIO/HTTP transport
├── types.ts              # Zod schemas cho tool inputs
├── auth/
│   ├── middleware.ts     # requireBearerAuth middleware
│   └── endpoints.ts     # OAuth 2.1 endpoints
├── graph/
│   └── client.ts         # GraphService singleton (ClientSecretCredential)
└── tools/
    ├── auth.ts           # auth_status
    ├── users.ts          # get_current_user, search_users
    ├── teams.ts          # list_teams, list_channels, get/send_channel_message
    ├── chats.ts          # list_chats, get/send_chat_message
    ├── meetings.ts       # list_meetings, get_meeting, attendance, transcripts
    └── messages.ts       # search_messages

Tech Stack

PackagePurpose
@modelcontextprotocol/sdkMCP server, streamable HTTP transport
@microsoft/microsoft-graph-clientMicrosoft Graph API client
@azure/identityClientSecretCredential cho Graph auth
expressHTTP server
zodInput validation cho MCP tools
dotenvEnvironment variables
typescript + tsxBuild + dev

License

MIT

Ver o original no GitHub

Bom para

Relacionados