### Initialize and Use TeamsClient
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Provides an example of initializing the TeamsClient with necessary credentials and configurations, and then using it to start a new thread, optionally mentioning a user.
```python
from azure.identity.aio import ClientSecretCredential
from msgraph.graph_service_client import GraphServiceClient
from microsoft_agents.authentication.msal import MsalConnectionManager
from microsoft_agents.hosting.aiohttp import CloudAdapter
from mcp_teams_server.teams import TeamsClient, TeamsThread, TeamsMessage, TeamsMember
from mcp_teams_server.config import BotConfiguration
# Initialize the Teams client
bot_config = BotConfiguration()
connection_manager = MsalConnectionManager(**bot_config)
adapter = CloudAdapter(connection_manager=connection_manager)
credentials = ClientSecretCredential(
bot_config["APP_TENANT_ID"],
bot_config["APP_ID"],
bot_config["APP_PASSWORD"]
)
graph_client = GraphServiceClient(
credentials=credentials,
scopes=["https://graph.microsoft.com/.default"]
)
client = TeamsClient(
adapter=adapter,
graph_client=graph_client,
teams_app_id=bot_config["APP_ID"],
team_id=bot_config["TEAM_ID"],
teams_channel_id=bot_config["TEAMS_CHANNEL_ID"]
)
# Start a new thread
thread: TeamsThread = await client.start_thread(
title="Automated Report",
content="Daily metrics summary attached.",
member_name="John Smith" # Optional mention
)
print(f"Created thread: {thread.thread_id}")
```
--------------------------------
### Clone Repository and Install Dependencies
Source: https://github.com/inditextech/mcp-teams-server/blob/master/README.md
Clone the repository and install project dependencies using uv. Ensure Python 3.10 is installed.
```bash
git clone [repository-url]
cd mcp-teams-server
```
```bash
uv venv
uv sync --frozen --all-extras --dev
```
--------------------------------
### Start MCP Teams Server
Source: https://github.com/inditextech/mcp-teams-server/blob/master/README.md
Start the MCP Teams Server after setting up the required environment variables.
```bash
uv run mcp-teams-server
```
--------------------------------
### List Threads - First Page Example
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Shows how to call the list_threads tool to fetch the first page of threads. An optional limit can be specified.
```json
{
"name": "list_threads",
"arguments": {
"limit": 10
}
}
```
```json
{
"cursor": "https://graph.microsoft.com/v1.0/teams/.../messages?$skiptoken=abc123",
"limit": 10,
"total": 47,
"items": [
{
"thread_id": "1743086901347",
"message_id": "1743086901347",
"content": "
Build Status Report...
"
},
{
"thread_id": "1743085432100",
"message_id": "1743085432100",
"content": "Sprint Planning Notes...
"
}
]
}
```
--------------------------------
### Sample Local Development Setup for MCP Teams Server
Source: https://github.com/inditextech/mcp-teams-server/blob/master/llms-install.md
Configure your MCP settings for local development of the MCP Teams Server using the 'uv' package manager. This setup requires filling in specific environment variables.
```json
{
"mcpServers": {
"msteams": {
"command": "uv",
"args": [
"run",
"mcp-teams-server"
],
"env": {
"TEAMS_APP_ID": "",
"TEAMS_APP_PASSWORD": "",
"TEAMS_APP_TYPE": "",
"TEAMS_APP_TENANT_ID": "",
"TEAM_ID": "",
"TEAMS_CHANNEL_ID": ""
}
}
}
}
```
--------------------------------
### Sample Docker Setup for MCP Teams Server
Source: https://github.com/inditextech/mcp-teams-server/blob/master/llms-install.md
Configure your MCP settings with this JSON structure for a Docker-based setup of the MCP Teams Server. Ensure all environment variables are correctly filled.
```json
{
"mcpServers": {
"msteams": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"TEAMS_APP_ID",
"-e",
"TEAMS_APP_PASSWORD",
"-e",
"TEAMS_APP_TYPE",
"-e",
"TEAMS_APP_TENANT_ID",
"-e",
"TEAM_ID",
"-e",
"TEAMS_CHANNEL_ID",
"ghcr.io/inditextech/mcp-teams-server"
],
"env": {
"TEAMS_APP_ID": "",
"TEAMS_APP_PASSWORD": "",
"TEAMS_APP_TYPE": "",
"TEAMS_APP_TENANT_ID": "",
"TEAM_ID": "",
"TEAMS_CHANNEL_ID": "",
"DOCKER_HOST": "unix:///var/run/docker.sock"
}
}
}
}
```
--------------------------------
### Running MCP Teams Server Locally with uv
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Use the `uv` package manager for local development. Clone the repository, install dependencies, and run the server.
```bash
# Clone and install
git clone https://github.com/InditexTech/mcp-teams-server.git
cd mcp-teams-server
uv venv
uv sync --frozen --all-extras --dev
# Run the server
uv run mcp-teams-server
# Run with SSE transport
uv run mcp-teams-server --transport sse
```
--------------------------------
### MCP Client Configuration for Claude Desktop
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Configure the MCP server in your Claude Desktop settings file. This example shows how to set up the 'msteams' server configuration.
```json
{
"mcpServers": {
"msteams": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "TEAMS_APP_ID",
"-e", "TEAMS_APP_PASSWORD",
"-e", "TEAMS_APP_TYPE",
"-e", "TEAMS_APP_TENANT_ID",
"-e", "TEAM_ID",
"-e", "TEAMS_CHANNEL_ID",
"ghcr.io/inditextech/mcp-teams-server"
],
"env": {
"TEAMS_APP_ID": "12345678-1234-1234-1234-123456789abc",
"TEAMS_APP_PASSWORD": "your-client-secret-value",
"TEAMS_APP_TYPE": "SingleTenant",
"TEAMS_APP_TENANT_ID": "87654321-4321-4321-4321-cba987654321",
"TEAM_ID": "abcd1234-ef56-gh78-ij90-klmnopqrstuv",
"TEAMS_CHANNEL_ID": "19%3Ab1234567890abcdef%40thread.tacv2"
}
}
}
}
```
--------------------------------
### Get Member by Name Example
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Illustrates how to find a team member using their display name. Returns the member's name and email if found, otherwise null.
```json
{
"name": "get_member_by_name",
"arguments": {
"name": "John Smith"
}
}
```
```json
{
"name": "John Smith",
"email": "john.smith@company.com"
}
```
```json
null
```
--------------------------------
### List Threads - Next Page Example
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Demonstrates fetching subsequent pages of threads using the cursor provided in a previous response. Both limit and cursor are used.
```json
{
"name": "list_threads",
"arguments": {
"limit": 10,
"cursor": "https://graph.microsoft.com/v1.0/teams/.../messages?$skiptoken=abc123"
}
}
```
--------------------------------
### List Members Example
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Shows the call to list all members of a Teams team. This is useful for discovering users for mentions. No parameters are required.
```json
{
"name": "list_members",
"arguments": {}
}
```
```json
[
{
"name": "John Smith",
"email": "john.smith@company.com"
},
{
"name": "Jane Doe",
"email": "jane.doe@company.com"
},
{
"name": "MCP Bot",
"email": "mcp-bot@company.com"
}
]
```
--------------------------------
### Sample Cline Docker Setup via WSL
Source: https://github.com/inditextech/mcp-teams-server/blob/master/llms-install.md
This JSON configuration is for setting up the MCP Teams Server with Cline using Docker through WSL on Windows. It includes necessary environment variables and Docker commands.
```json
{
"mcpServers": {
"github.com/InditexTech/mcp-teams-server/tree/main": {
"command": "wsl",
"args": [
"TEAMS_APP_ID=",
"TEAMS_APP_PASSWORD=",
"TEAMS_APP_TYPE=",
"TEAMS_APP_TENANT_ID=",
"TEAM_ID=",
"TEAMS_CHANNEL_ID=",
"docker",
"run",
"-i",
"--rm",
"ghcr.io/inditextech/mcp-teams-server"
],
"env": {
"DOCKER_HOST": "unix:///var/run/docker.sock"
},
"disabled": false,
"autoApprove": [ ],
"timeout": 300
}
}
}
```
--------------------------------
### Read Thread Example
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Demonstrates how to call the read_thread tool to retrieve messages from a specific thread. Requires a valid thread_id.
```json
{
"thread_id": "1743086901347",
"message_id": "1743087234567",
"content": "Jane Doe Deployment to staging environment completed. Please verify the changes."
}
```
```json
{
"name": "read_thread",
"arguments": {
"thread_id": "1743086901347"
}
}
```
```json
{
"cursor": null,
"limit": 50,
"total": 3,
"items": [
{
"thread_id": "1743086901347",
"message_id": "1743087234567",
"content": "Jane Doe Deployment completed."
},
{
"thread_id": "1743086901347",
"message_id": "1743087345678",
"content": "Verified - all systems operational."
},
{
"thread_id": "1743086901347",
"message_id": "1743087456789",
"content": "Closing this thread. Thanks everyone!"
}
]
}
```
--------------------------------
### Environment Variables Setup for MCP Teams Server
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Configure these environment variables before running the server. Credentials are obtained from Azure Portal and Microsoft Teams.
```bash
# Required Environment Variables
export TEAMS_APP_ID="your-azure-bot-app-uuid"
export TEAMS_APP_PASSWORD="your-client-secret"
export TEAMS_APP_TYPE="SingleTenant" # or "MultiTenant"
export TEAMS_APP_TENANT_ID="your-tenant-uuid"
export TEAM_ID="your-ms-teams-group-id"
export TEAMS_CHANNEL_ID="19%3Axxx%40thread.tacv2" # URL-encoded channel ID
# Optional
export MCP_LOGLEVEL="DEBUG" # Default: ERROR
export MCP_TRANSPORT="stdio" # Default: stdio, options: stdio, sse
```
--------------------------------
### MCP Tool: start_thread Example
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Use the `start_thread` MCP tool to create a new thread in a Microsoft Teams channel. It requires a title and content, and optionally accepts a member name to mention.
```json
# MCP Tool: start_thread
# Parameters:
# title (required): The thread title
# content (required): The thread content
# member_name (optional): Member name to mention in the thread
# Example MCP tool call
{
"name": "start_thread",
"arguments": {
"title": "Build Status Report",
"content": "The nightly build completed successfully. All 847 tests passed.",
"member_name": "John Smith"
}
}
# Response
{
"thread_id": "1743086901347",
"title": "Build Status Report",
"content": "# **Build Status Report**\nJohn Smith The nightly build completed successfully. All 847 tests passed."
}
```
--------------------------------
### MCP Tool: update_thread Example
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Use the `update_thread` MCP tool to add a reply message to an existing thread. It requires the `thread_id` and `content`, and optionally accepts a `member_name` to mention.
```json
# MCP Tool: update_thread
# Parameters:
# thread_id (required): Thread ID string (format: '1743086901347')
# content (required): The content to add as a reply
# member_name (optional): Member name to mention
# Example MCP tool call
{
"name": "update_thread",
"arguments": {
"thread_id": "1743086901347",
"content": "Deployment to staging environment completed. Please verify the changes.",
"member_name": "Jane Doe"
}
}
```
--------------------------------
### Get Member by Name API
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Looks up a team member by their display name. Returns the member's name and email address for use in mentions.
```APIDOC
## GET /members
### Description
Looks up a team member by their display name. Returns the member's name and email address for use in mentions.
### Method
GET
### Endpoint
/members
### Parameters
#### Query Parameters
- **name** (string) - Required - Member's display name to search for.
### Response
#### Success Response (200)
- **name** (string) - The display name of the member.
- **email** (string) - The email address of the member.
#### Response Example (when found)
```json
{
"name": "John Smith",
"email": "john.smith@company.com"
}
```
#### Response Example (when not found)
```json
null
```
```
--------------------------------
### List Team Members in Python
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Get a list of all members in the team using `client.list_members`. The function returns a list of `TeamsMember` objects, each containing member details like name and email.
```python
members: list[TeamsMember] = await client.list_members()
for member in members:
print(f"{member.name} ({member.email})")
```
--------------------------------
### TeamsClient Class Usage
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Demonstrates how to initialize and use the TeamsClient for direct Microsoft Teams interactions.
```APIDOC
## TeamsClient
### Description
The core Python class that handles all Microsoft Teams interactions. Used internally by MCP tools but can also be used directly for custom integrations.
### Initialization
```python
from azure.identity.aio import ClientSecretCredential
from msgraph.graph_service_client import GraphServiceClient
from microsoft_agents.authentication.msal import MsalConnectionManager
from microsoft_agents.hosting.aiohttp import CloudAdapter
from mcp_teams_server.teams import TeamsClient, TeamsThread, TeamsMessage, TeamsMember
from mcp_teams_server.config import BotConfiguration
# Initialize the Teams client
bot_config = BotConfiguration()
connection_manager = MsalConnectionManager(**bot_config)
adapter = CloudAdapter(connection_manager=connection_manager)
credentials = ClientSecretCredential(
bot_config["APP_TENANT_ID"],
bot_config["APP_ID"],
bot_config["APP_PASSWORD"]
)
graph_client = GraphServiceClient(
credentials=credentials,
scopes=["https://graph.microsoft.com/.default"]
)
client = TeamsClient(
adapter=adapter,
graph_client=graph_client,
teams_app_id=bot_config["APP_ID"],
team_id=bot_config["TEAM_ID"],
teams_channel_id=bot_config["TEAMS_CHANNEL_ID"]
)
```
### Start Thread
```python
# Start a new thread
thread: TeamsThread = await client.start_thread(
title="Automated Report",
content="Daily metrics summary attached.",
member_name="John Smith" # Optional mention
)
print(f"Created thread: {thread.thread_id}")
```
```
--------------------------------
### Build Docker Image
Source: https://github.com/inditextech/mcp-teams-server/blob/master/README.md
Build a Docker image for the MCP Teams Server using the provided Dockerfile.
```bash
docker build . -t inditextech/mcp-teams-server
```
--------------------------------
### Running MCP Teams Server with Docker
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Deploy the server using the pre-built Docker image. You can pull the latest image and run it with an environment file or inline environment variables.
```bash
# Pull the latest image
docker pull ghcr.io/inditextech/mcp-teams-server:latest
# Run with environment file
docker run --env-file .env -it ghcr.io/inditextech/mcp-teams-server:latest
# Or run with inline environment variables
docker run -it \
-e TEAMS_APP_ID="your-app-id" \
-e TEAMS_APP_PASSWORD="your-password" \
-e TEAMS_APP_TYPE="SingleTenant" \
-e TEAMS_APP_TENANT_ID="your-tenant-id" \
-e TEAM_ID="your-team-id" \
-e TEAMS_CHANNEL_ID="your-channel-id" \
ghcr.io/inditextech/mcp-teams-server:latest
```
--------------------------------
### Run Ruff Linting and Formatting
Source: https://github.com/inditextech/mcp-teams-server/blob/master/CONTRIBUTING.md
Execute local linting and formatting checks using Ruff before committing changes. Ensure code adheres to project style guidelines.
```bash
uv run ruff check . --fix
uv run ruff format .
```
--------------------------------
### Pull Pre-built Docker Image
Source: https://github.com/inditextech/mcp-teams-server/blob/master/README.md
Download the latest pre-built Docker image for the MCP Teams Server from ghcr.io.
```commandline
docker pull ghcr.io/inditextech/mcp-teams-server:latest
```
--------------------------------
### Run Docker Image
Source: https://github.com/inditextech/mcp-teams-server/blob/master/README.md
Run the MCP Teams Server Docker container. Supports basic execution or loading environment variables from a .env file.
```bash
docker run -it inditextech/mcp-teams-server
```
```bash
docker run --env-file .env -it inditextech/mcp-teams-server
```
--------------------------------
### Run Integration Tests
Source: https://github.com/inditextech/mcp-teams-server/blob/master/README.md
Execute integration tests for the MCP Teams Server. Ensure necessary environment variables for testing are set.
```bash
uv run pytest -m integration
```
--------------------------------
### List All Threads in a Channel in Python
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Retrieve a list of all threads in a channel using `client.read_threads`. You can set a `limit` to control the number of threads returned. The results are paginated.
```python
threads: PagedTeamsMessages = await client.read_threads(limit=25)
for t in threads.items:
print(f"Thread {t.thread_id}: {t.content[:100]}...")
```
--------------------------------
### MCP Tool: start_thread
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Creates a new thread in the configured Microsoft Teams channel with a title, content, and optional user mention. Returns the created thread's ID for subsequent operations.
```APIDOC
## MCP Tool: start_thread
### Description
Creates a new thread in the configured Microsoft Teams channel with a title, content, and optional user mention. Returns the created thread's ID for subsequent operations.
### Parameters
#### Request Body
- **title** (string) - Required - The thread title
- **content** (string) - Required - The thread content
- **member_name** (string) - Optional - Member name to mention in the thread
### Request Example
```json
{
"name": "start_thread",
"arguments": {
"title": "Build Status Report",
"content": "The nightly build completed successfully. All 847 tests passed.",
"member_name": "John Smith"
}
}
```
### Response
#### Success Response (200)
- **thread_id** (string) - The ID of the created thread
- **title** (string) - The title of the thread
- **content** (string) - The content of the thread
#### Response Example
```json
{
"thread_id": "1743086901347",
"title": "Build Status Report",
"content": "# **Build Status Report**\nJohn Smith The nightly build completed successfully. All 847 tests passed."
}
```
```
--------------------------------
### Run Pyright Type Checker
Source: https://github.com/inditextech/mcp-teams-server/blob/master/CONTRIBUTING.md
Execute the Pyright type checker locally to verify type correctness in the Python codebase. This helps catch potential type-related errors.
```bash
uv run pyright
```
--------------------------------
### List Threads API
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Lists all threads in the configured Teams channel with pagination support. Use the returned cursor for fetching subsequent pages.
```APIDOC
## GET /threads
### Description
Lists all threads in the configured Teams channel with pagination support. Use the returned cursor for fetching subsequent pages.
### Method
GET
### Endpoint
/threads
### Parameters
#### Query Parameters
- **limit** (integer) - Optional - Maximum items per page (default: 50).
- **cursor** (string) - Optional - Pagination cursor from previous response.
### Response
#### Success Response (200)
- **cursor** (string) - A cursor for fetching the next page of results.
- **limit** (integer) - The maximum number of items returned per page.
- **total** (integer) - The total number of threads available.
- **items** (array) - A list of thread objects.
- **thread_id** (string) - The ID of the thread.
- **message_id** (string) - The ID of the first message in the thread.
- **content** (string) - The content of the first message in the thread.
#### Response Example
```json
{
"cursor": "https://graph.microsoft.com/v1.0/teams/.../messages?$skiptoken=abc123",
"limit": 10,
"total": 47,
"items": [
{
"thread_id": "1743086901347",
"message_id": "1743086901347",
"content": "Build Status Report...
"
},
{
"thread_id": "1743085432100",
"message_id": "1743085432100",
"content": "Sprint Planning Notes...
"
}
]
}
```
```
--------------------------------
### MCP Tool: update_thread
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Adds a reply message to an existing thread, with optional user mention. Use the thread_id returned from start_thread or list_threads.
```APIDOC
## MCP Tool: update_thread
### Description
Adds a reply message to an existing thread, with optional user mention. Use the thread_id returned from start_thread or list_threads.
### Parameters
#### Request Body
- **thread_id** (string) - Required - Thread ID string (format: '1743086901347')
- **content** (string) - Required - The content to add as a reply
- **member_name** (string) - Optional - Member name to mention
### Request Example
```json
{
"name": "update_thread",
"arguments": {
"thread_id": "1743086901347",
"content": "Deployment to staging environment completed. Please verify the changes.",
"member_name": "Jane Doe"
}
}
```
```
--------------------------------
### Reply to a Thread in Python
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Use `client.update_thread` to add a message to an existing thread. Ensure you have the `thread_id` and the message content.
```python
message: TeamsMessage = await client.update_thread(
thread_id=thread.thread_id,
content="Additional data has been added.",
member_name=None
)
print(f"Added reply: {message.message_id}")
```
--------------------------------
### List Members API
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Retrieves all members of the configured Teams team. Useful for discovering available users before creating mentions.
```APIDOC
## GET /members/all
### Description
Retrieves all members of the configured Teams team. Useful for discovering available users before creating mentions.
### Method
GET
### Endpoint
/members/all
### Parameters
None
### Response
#### Success Response (200)
- An array of member objects.
- **name** (string) - The display name of the member.
- **email** (string) - The email address of the member.
#### Response Example
```json
[
{
"name": "John Smith",
"email": "john.smith@company.com"
},
{
"name": "Jane Doe",
"email": "jane.doe@company.com"
},
{
"name": "MCP Bot",
"email": "mcp-bot@company.com"
}
]
```
```
--------------------------------
### Find Specific Member by Name in Python
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Search for a specific team member by their name using `client.get_member_by_name`. This method returns a `TeamsMember` object if found, otherwise `None`.
```python
member = await client.get_member_by_name("Jane Doe")
if member:
print(f"Found: {member.email}")
```
--------------------------------
### Read Thread API
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Retrieves all replies from a specific thread. Returns a paginated list of messages with their content and metadata.
```APIDOC
## GET /threads/{thread_id}
### Description
Retrieves all replies from a specific thread. Returns a paginated list of messages with their content and metadata.
### Method
GET
### Endpoint
/threads/{thread_id}
### Parameters
#### Path Parameters
- **thread_id** (string) - Required - The ID of the thread to retrieve messages from.
### Response
#### Success Response (200)
- **cursor** (string) - A cursor for fetching the next page of results.
- **limit** (integer) - The maximum number of items to return per page.
- **total** (integer) - The total number of messages in the thread.
- **items** (array) - A list of message objects.
- **thread_id** (string) - The ID of the thread.
- **message_id** (string) - The ID of the message.
- **content** (string) - The content of the message.
#### Response Example
```json
{
"cursor": null,
"limit": 50,
"total": 3,
"items": [
{
"thread_id": "1743086901347",
"message_id": "1743087234567",
"content": "Jane Doe Deployment completed."
},
{
"thread_id": "1743086901347",
"message_id": "1743087345678",
"content": "Verified - all systems operational."
},
{
"thread_id": "1743086901347",
"message_id": "1743087456789",
"content": "Closing this thread. Thanks everyone!"
}
]
}
```
```
--------------------------------
### Read Thread Replies in Python
Source: https://context7.com/inditextech/mcp-teams-server/llms.txt
Fetch replies from a specific thread using `client.read_thread_replies`. You can specify a `limit` for the number of replies to retrieve. The replies are returned as a `PagedTeamsMessages` object.
```python
from mcp_teams_server.teams import PagedTeamsMessages
replies: PagedTeamsMessages = await client.read_thread_replies(
thread_id=thread.thread_id,
limit=50,
cursor=None
)
for reply in replies.items:
print(f"Reply {reply.message_id}: {reply.content}")
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.