mcp-teams-server

repository·master·Indexed 18 days ago

https://github.com/inditextech/mcp-teams-server

An MCP (Model Context Protocol) server implementation for Microsoft Teams integration, version 1.0.10. It enables LLMs to interact with Teams by reading messages, creating and updating threads, listing members, and mentioning users. The server supports stdio and SSE transport modes and can be deployed via uv or Docker.

Tokens
5.5K
Snippets
18
Records
24
Agent score
63%

What's inside mcp-teams-server

  1. Install MCP Teams Server via uv

    master

    To install the server locally, ensure you have uv and Python 3.10 installed. Clone the repository, create a virtual environment, and sync dependencies using the following commands:

    git clone [repository-url]
    cd mcp-teams-server
    
    uv venv
    uv sync --frozen --all-extras --dev
  2. Register a Microsoft Entra ID application

    master

    To use the MCP Teams Server, you must first register a Microsoft Entra ID application. This provides the necessary credentials for the Microsoft Bot Framework to authenticate via REST.

    Required environment variables:

    • TEAMS_APP_ID: The application UUID from your Entra ID registration.
    • TEAMS_APP_PASSWORD: The client secret retrieved after adding credentials to your application.
    • TEAMS_APP_TYPE: Set to SingleTenant if using a Single Tenant schema.
    • TEAMS_APP_TENANT_ID: The tenant UUID (required for Single Tenant schemes).

    Additionally, you must configure the Microsoft Graph API permission ChannelMessage.Read.All. This is a 'Resource Specific Consent' (RSC) permission that can be scoped to the specific team or group where the application is installed.

    export TEAMS_APP_ID="your-app-uuid"
    export TEAMS_APP_PASSWORD="your-client-secret"
    export TEAMS_APP_TYPE="SingleTenant"
    export TEAMS_APP_TENANT_ID="your-tenant-uuid"
  3. Install MCP Teams Server via Docker

    master

    You can run the MCP Teams Server using a pre-built Docker image from ghcr.io. First, pull the latest image:

    docker pull ghcr.io/inditextech/mcp-teams-server:latest

    Then, add the following configuration to your MCP settings file (e.g., for Claude Desktop or Cursor). You must provide your Microsoft Teams credentials and IDs in the env section.

    {
      "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": "<fill_me_with_proper_uuid>",
            "TEAMS_APP_PASSWORD": "<fill_me_with_proper_uuid>",
            "TEAMS_APP_TYPE": "<fill_me_with_proper_uuid>",
            "TEAMS_APP_TENANT_ID": "<fill_me_with_proper_uuid>",
            "TEAM_ID": "<fill_me_with_proper_uuid>",
            "TEAMS_CHANNEL_ID": "<fill_me_with_proper_channel_id>",
            "DOCKER_HOST": "unix:///var/run/docker.sock"
          }
        }
      }
    }
  4. Register an Azure Bot

    master

    After Entra ID registration, register an Azure Bot. Use your existing TEAMS_APP_ID during this registration process.

    Note: You do not need to deploy a web app to Azure or the internet. The MCP server acts as a client to the Azure Bot Framework REST API. However, you must connect the bot to the Teams channel within the Azure Bot configuration to enable communication.

  5. Run integration tests

    master

    To run integration tests, you must set up specific test environment variables to provide context for the test execution:

    • TEST_THREAD_ID: timestamp of the thread id
    • TEST_MESSAGE_ID: timestamp of the message id
    • TEST_USER_NAME: test user name

    Then execute the following command:

    uv run pytest -m integration
  6. Publish a Microsoft Teams Application

    master

    To make the bot available in Teams, you must publish a Teams Application. You have two options:

    Option 1: Use the provided skeleton

    Use the files in the /app directory of this repository.

    1. Replace all instances of {{MICROSOFT_APP_ID}} with your TEAMS_APP_ID.
    2. Replace the default icons with your own.
    3. Zip the directory and upload it to Microsoft Teams.

    Option 2: Use the Teams Developer Portal

    Create the application via the Teams developer portal. If using this method, you must manually configure the 'bot feature' and add the following required permissions:

    • TeamMember.Read.Group
    • ChannelMessage.Read.Group
    • ChannelMessage.Send.Group
    • ChannelSettings.Read.Group
    • ChannelMember.Read.Group
    • Member.Read.Group
    • Owner.Read.Group

    Finally, the application must be installed into a specific Teams Group.

  7. Install MCP Teams Server via uv (Local Development)

    master

    For local development, you can use the uv package manager to run the server directly. Ensure you have uv and Python 3.10 installed. Add this configuration to your MCP settings file, providing the required Teams environment variables.

    {
      "mcpServers": {
        "msteams": {
          "command": "uv",
          "args": [
            "run",
            "mcp-teams-server"
          ],
          "env": {
            "TEAMS_APP_ID": "<fill_me_with_proper_uuid>",
            "TEAMS_APP_PASSWORD": "<fill_me_with_proper_uuid>",
            "TEAMS_APP_TYPE": "<fill_me_with_proper_uuid>",
            "TEAMS_APP_TENANT_ID": "<fill_me_with_proper_uuid>",
            "TEAM_ID": "<fill_me_with_proper_uuid>",
            "TEAMS_CHANNEL_ID": "<fill_me_with_proper_channel_id>"
          }
        }
      }
    }
  8. Configure TEAM_ID and TEAMS_CHANNEL_ID from a Teams URL

    master

    To restrict the MCP server to specific channels, you must extract the groupId and channelId from your Microsoft Teams URL.

    Example URL format: https://teams.microsoft.com/l/channel/[TEAMS_CHANNEL_ID]/McpBot?groupId=[TEAM_ID]&tenantId=[TEAMS_APP_TENANT_ID]

    Required environment variables:

    • TEAM_ID: Extracted from the groupId parameter.
    • TEAMS_CHANNEL_ID: Extracted from the channel segment of the URL.

    The MCP server will read and post only within the specified TEAM_ID and will use TEAMS_CHANNEL_ID as the default channel.

    https://teams.microsoft.com/l/channel/[TEAMS_CHANNEL_ID]/McpBot?groupId=[TEAM_ID]&tenantId=[TEAMS_APP_TENANT_ID]
  9. Install MCP Teams Server on Windows via WSL and Docker

    master

    If you are using Cline on Windows, you can configure the server to run through WSL using Docker. Add this to your MCP settings file, ensuring you replace the placeholders with your actual Microsoft Teams credentials.

    {
      "mcpServers": {
        "github.com/InditexTech/mcp-teams-server/tree/main": {
          "command": "wsl",
          "args": [
            "TEAMS_APP_ID=<fill_me_with_proper_uuid>",
            "TEAMS_APP_PASSWORD=<fill_me_with_proper_uuid>",
            "TEAMS_APP_TYPE=<fill_me_with_proper_uuid>",
            "TEAMS_APP_TENANT_ID=<fill_me_with_proper_uuid>",
            "TEAM_ID=<fill_me_with_proper_uuid>",
            "TEAMS_CHANNEL_ID=<fill_me_with_proper_uuid>",
            "docker",
            "run",
            "-i",
            "--rm",
            "ghcr.io/inditextech/mcp-teams-server"
          ],
          "env": {
            "DOCKER_HOST": "unix:///var/run/docker.sock"
          },
          "disabled": false,
          "autoApprove": [ ],
          "timeout": 300
        }
      }
    }
  10. Use MCP Teams Server via Docker

    master

    You can use pre-built Docker images or build your own to run the MCP server.

    ### Pull pre-built image
    ```bash
    docker pull ghcr.io/inditextech/mcp-teams-server:latest

    Build your own image

    docker build . -t inditextech/mcp-teams-server

    Run the image

    Basic run:

    docker run -it inditextech/mcp-teams-server

    Run with environment variables from an .env file:

    docker run --env-file .env -it inditextech/mcp-teams-server
  11. Configure Microsoft Teams environment variables

    master

    The MCP Teams Server requires specific environment variables to authenticate with Microsoft Teams and identify the target workspace. You can set these in your shell or an .env file. Use the sample.env file provided in the repository as a template.

    TEAMS_APP_ID        # UUID for your MS Entra ID application ID
    TEAMS_APP_PASSWORD  # Client secret
    TEAMS_APP_TYPE      # SingleTenant or MultiTenant
    TEAMS_APP_TENANT_ID # Tenant uuid in case of SingleTenant
    TEAM_ID              # MS Teams Group Id or Team Id
    TEAMS_CHANNEL_ID     # MS Teams Channel ID with url escaped chars
  12. Example Prompts for MCP Teams Server

    master

    You can use the following natural language prompts to trigger the MCP Teams Server tools:

    • "Please start a thread in teams with the following content..."
    • "Please list members in team"
    • "Please perform this task... and send results to a new thread in teams. Remember to mention '[User Name]'"
    • "Please read latest team threads and reply to threads that mention '[Your bot name]'"