Teams MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Teams MCP Python
A Python implementation of Microsoft Teams MCP (Model Context Protocol) server with a reusable OAuth2 authentication library that can be used for building MCP servers for any OAuth2-based service.
Features
Reusable OAuth2 Library (mcp_oauth2)
Generic OAuth2 implementation that works with any OAuth2 provider
Built-in providers for Microsoft, Google, and generic OAuth2 services
Standardized MCP tools (
is_authenticatedandauthorize) for OAuth2 flowPKCE support for public clients (no client secret required)
Automatic token refresh handling
Easy to extend for new OAuth2 providers
Teams MCP Server
Full Microsoft Teams integration via Graph API
Chat management: List, create, and manage Teams chats
Messaging: Send and retrieve messages
Rate limiting with exponential backoff
Async/await throughout for performance
Related MCP server: Teams MCP
Installation
Using uvx (Recommended)
The easiest way to use this MCP server is with uvx, which allows you to run Python applications without manual installation:
# Run the Teams MCP server directly
uvx teams-mcp-python
# Or specify with full package name
uvx --from teams-mcp-python teams-mcpUsing pip
pip install teams-mcp-pythonQuick Start
1. Azure AD Setup
First, register an app in Azure Portal:
Go to Azure Portal > Azure Active Directory > App registrations
Click "New registration"
Set redirect URI to
http://localhost:3000/auth/callback(Web platform)Grant these API permissions (Delegated):
Chat.ReadWriteChatMessage.SendUser.Readoffline_access
2. Configuration
Create a .env file in your project:
AZURE_CLIENT_ID=your-client-id
AZURE_TENANT_ID=your-tenant-id
AZURE_CLIENT_SECRET=your-client-secret # Optional for public clients
AZURE_REDIRECT_URI=http://localhost:3000/auth/callback
DEBUG=true3. Using with Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Option 1: Using uvx (Recommended)
{
"mcpServers": {
"teams": {
"command": "uvx",
"args": ["teams-mcp-python"],
"env": {
"AZURE_CLIENT_ID": "your-client-id",
"AZURE_TENANT_ID": "your-tenant-id",
"AZURE_REDIRECT_URI": "http://localhost:3000/auth/callback"
}
}
}
}Option 2: Using Python
{
"mcpServers": {
"teams": {
"command": "python",
"args": ["-m", "teams_mcp"],
"env": {
"AZURE_CLIENT_ID": "your-client-id",
"AZURE_TENANT_ID": "your-tenant-id",
"AZURE_REDIRECT_URI": "http://localhost:3000/auth/callback"
}
}
}
}Option 3: If installed globally
{
"mcpServers": {
"teams": {
"command": "teams-mcp",
"env": {
"AZURE_CLIENT_ID": "your-client-id",
"AZURE_TENANT_ID": "your-tenant-id",
"AZURE_REDIRECT_URI": "http://localhost:3000/auth/callback"
}
}
}
}4. Authentication Flow
When using the Teams MCP server in Claude:
First use - Claude will provide an authentication URL
Open the URL in your browser and sign in with your Microsoft account
Copy the authorization code from the redirect URL
Provide the code to Claude to complete authentication
Example conversation:
You: List my Teams chats
Claude: I'll help you list your Teams chats. First, I need to check your authentication status.
[Calls teams_is_authenticated]
You need to authenticate. Please visit this URL:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?...
After signing in, you'll be redirected to a URL with a code parameter. Please provide that code.
You: The URL shows: http://localhost:3000/auth/callback?code=ABC123...
Claude: [Calls teams_authorize with the code]
Great! I've successfully authenticated. Now let me list your chats.
[Calls teams_list_chats]
Here are your Teams chats:
1. Project Team - Group chat with 5 members
2. John Doe - One-on-one chat
...Available Tools
The Teams MCP server provides these tools:
Authentication Tools
teams_is_authenticated- Check authentication status or get auth URLteams_authorize- Complete OAuth2 flow with authorization code
Teams Tools
teams_list_chats- List all chats with optional filteringteams_create_chat- Create new one-on-one or group chatsteams_send_message- Send messages to a chatteams_get_messages- Retrieve messages from a chat
Creating Your Own OAuth2 MCP Server
The mcp_oauth2 library makes it easy to create MCP servers for any OAuth2 service:
from mcp_oauth2 import OAuth2Config, GenericOAuth2Provider, create_oauth2_tools
from mcp.server import Server
# Configure your OAuth2 provider
oauth_config = OAuth2Config(
client_id="your-client-id",
client_secret="your-client-secret", # Optional for PKCE
redirect_uri="http://localhost:3000/auth/callback",
scopes=["scope1", "scope2"],
authorization_endpoint="https://provider.com/oauth/authorize",
token_endpoint="https://provider.com/oauth/token"
)
# Create provider instance
provider = GenericOAuth2Provider("myprovider", oauth_config)
# Get OAuth2 MCP tools
oauth_tools = create_oauth2_tools(provider) # Creates is_authenticated and authorize tools
# Add to your MCP server
server = Server("my-mcp-server")
@server.list_tools()
async def list_tools():
return oauth_tools + your_custom_toolsOAuth2 Authentication Flow
The library implements a standard OAuth2 flow with two MCP tools:
1. {provider}_is_authenticated
Check if tokens are valid or generate an auth URL:
// Request without tokens - generates auth URL
{
"callback_url": "http://localhost:3000/auth/callback",
"callback_state": { "custom": "data" }
}
// Response
{
"authenticated": false,
"auth_url": "https://provider.com/oauth/authorize?...",
"state": "random-state-string"
}
// Request with tokens - validates them
{
"tokens": {
"access_token": "...",
"refresh_token": "..."
}
}
// Response
{
"authenticated": true,
"tokens": { /* refreshed tokens if needed */ }
}2. {provider}_authorize
Exchange authorization code for tokens:
// Request
{
"code": "auth-code-from-callback",
"callback_url": "http://localhost:3000/auth/callback?code=...&state=...",
"callback_state": { "custom": "data" }
}
// Response
{
"success": true,
"tokens": {
"access_token": "...",
"refresh_token": "...",
"expires_in": 3600
}
}Built-in OAuth2 Providers
Microsoft Provider
from mcp_oauth2 import MicrosoftProvider, OAuth2Config
config = OAuth2Config(
client_id="your-client-id",
client_secret="your-secret", # Optional
scopes=["User.Read", "Mail.Read"]
)
provider = MicrosoftProvider(config, tenant_id="common")Google Provider
from mcp_oauth2 import GoogleProvider, OAuth2Config
config = OAuth2Config(
client_id="your-client-id",
client_secret="your-secret",
scopes=["https://www.googleapis.com/auth/drive.readonly"]
)
provider = GoogleProvider(config)Generic Provider
from mcp_oauth2 import GenericOAuth2Provider, OAuth2Config
config = OAuth2Config(
client_id="your-client-id",
client_secret="your-secret",
authorization_endpoint="https://example.com/oauth/authorize",
token_endpoint="https://example.com/oauth/token",
scopes=["read", "write"]
)
provider = GenericOAuth2Provider("custom", config)Creating a Custom OAuth2 Provider
Extend the base OAuth2Provider class:
from mcp_oauth2 import OAuth2Provider, OAuth2Config, TokenResponse
class MyCustomProvider(OAuth2Provider):
@property
def name(self) -> str:
return "mycustom"
async def exchange_code(self, code: str, code_verifier: Optional[str] = None) -> TokenResponse:
# Custom implementation
pass
async def refresh_token(self, refresh_token: str) -> TokenResponse:
# Custom implementation
passExamples
See the examples/ directory for complete implementations:
google_drive_mcp.py- Google Drive MCP servergithub_mcp.py- GitHub MCP server
Using Example Servers with Claude Desktop
You can run the example servers using uvx as well:
For the Google Drive example:
{
"mcpServers": {
"google-drive": {
"command": "uvx",
"args": ["--from", "teams-mcp-python", "python", "-m", "examples.google_drive_mcp"],
"env": {
"GOOGLE_CLIENT_ID": "your-client-id",
"GOOGLE_CLIENT_SECRET": "your-client-secret"
}
}
}
}Or with a local installation:
{
"mcpServers": {
"google-drive": {
"command": "python",
"args": ["/path/to/examples/google_drive_mcp.py"],
"env": {
"GOOGLE_CLIENT_ID": "your-client-id",
"GOOGLE_CLIENT_SECRET": "your-client-secret"
}
}
}
}For the GitHub example:
{
"mcpServers": {
"github": {
"command": "uvx",
"args": ["--from", "teams-mcp-python", "python", "-m", "examples.github_mcp"],
"env": {
"GITHUB_CLIENT_ID": "your-client-id",
"GITHUB_CLIENT_SECRET": "your-client-secret"
}
}
}
}Architecture
OAuth2 Library Structure
mcp_oauth2/
├── base.py # Base classes and interfaces
├── tools.py # MCP tool creation
└── providers/ # OAuth2 provider implementations
├── generic.py # Generic OAuth2 provider
├── microsoft.py # Microsoft-specific provider
└── google.py # Google-specific providerTeams MCP Structure
teams_mcp/
├── server.py # Main MCP server
├── config.py # Configuration
├── api/ # Teams API client
│ ├── client.py # Graph API wrapper
│ └── rate_limiter.py
└── tools/ # Teams-specific MCP tools
├── list_chats.py
├── create_chat.py
├── send_message.py
└── get_messages.pyDevelopment
Setup
# Clone the repository
git clone https://github.com/shmaxi/teams-mcp-python.git
cd teams-mcp-python
# Install in development mode
pip install -e ".[dev]"Testing
# Run tests
pytest
# With coverage
pytest --cov=src
# Type checking
mypy srcCode Quality
# Format code
black src tests
# Lint
ruff src testsPublishing
To publish a new version to PyPI:
# Build the package
python -m build
# Upload to PyPI (requires PyPI credentials)
python -m twine upload dist/*After publishing, the package will be available via:
pip install teams-mcp-pythonuvx teams-mcp-python(for direct execution without installation)
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Read email/chat conversations, messages, contacts and teams; draft, send and update threads.
Manage Microsoft 365 email, calendar, contacts and inbox rules via the Graph API with OAuth 2.0.
Permissioned access to Outlook, OneDrive and Teams via the user's own Microsoft account
Read chats, contacts, teams and broadcasts; send messages and notes, and manage labels in SleekFlow.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to read conversations, send messages, and manage members in Microsoft Teams via the Teams Chat Service REST API.202 npm9MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to read and act on Microsoft Teams data through Microsoft Graph, covering team and channel operations, 1:1 and group chat messaging with rich formatting, message editing, deletion and search, file and image upload or download, and user directory lookups. Supports OAuth device-code authentication with token caching plus a read-only mode for safer, permission-limited access.12 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to interact with Microsoft Teams and Microsoft Graph, covering chats and channel messaging, message search, user and team member lookups, and file upload or attachment downloads. Supports OAuth device-code authentication, rich Markdown formatting, and LLM-friendly conversion of Teams HTML into Markdown.12 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to interact with Microsoft Teams, users, chats, files, and organizational data through Microsoft Graph APIs, covering channel and chat messaging, message editing and search, file uploads and downloads, and user directory lookup. Supports OAuth 2.0 device-code authentication, a read-only scope mode, rich Markdown formatting, and LLM-friendly HTML-to-Markdown conversion of message content.12 npmMIT