logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

mcp-teams-gateway

A robust Model Context Protocol (MCP) adapter facilitating seamless bidirectional communication between Microsoft Teams infrastructure and external agentic systems. It leverages PostgreSQL for advanced indexing/retrieval operations and DuckDB for rapid local persistence, managing all interactions exclusively through defined MCP mechanisms (tools, resources, events). Includes a specialized Command Line Interface (CLI) utility for operational management and client simulation.

Author

mcp-teams-gateway logo

aech-ai

No License

Quick Info

GitHub GitHub Stars 0
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

mcptoolschatmicrosoft teamsteams chatmcp teams

Teams Communication Bridge via MCP

This implementation provides a dedicated MCP server component designed to interface Microsoft Teams capabilities with any compliant MCP client framework (e.g., LLM orchestration engines, autonomous agents). Interaction is strictly governed by the Model Context Protocol—no conventional REST endpoints are exposed.

Core Capabilities

  • Native integration of MS Teams messaging streams into the MCP ecosystem.
  • High-performance Information Retrieval (IR) subsystem powered by PostgreSQL (with vector indexing).
  • Durable, transactional storage for message provenance utilizing DuckDB.
  • Sophisticated querying mixing traditional lexical methods (BM25) and vector similarity (akin to FlockMTL techniques).
  • A dedicated utility for credential management and a full-featured local MCP client application accessible via CLI.
  • Event-driven architecture using a polling mechanism to capture new Teams activities.
  • Support for real-time event subscriptions and live data stream access for consuming agents.
  • Operates using a single service account identity (bot).

System Schematic

+-------------------+      +-------------------+      +-----------------------+
|   CLI Simulator   |<---->|    MCP Adapter    |<---->|  Microsoft Teams API  |
| (Terminal Client) |      | (FastMCP Core)    |      | (MS Graph Interface)  |
+-------------------+      +-------------------+      +-----------------------+
         |                        |                          
         |                        v                          
         |                +-------------------+      +-----------------------+
         |                |   Local Storage   |      |   Semantic Indexer    |
         |                |     (DuckDB)      |      | (PostgreSQL/pgvector) |
         |                +-------------------+      +-----------------------+
                                                              | 
                                                              v 
                                                     +-------------------+
                                                     | Persistent Index  |
                                                     +-------------------+
  • All application functions are exposed through standardized MCP verbs (tools, resources, events).
  • Message history and short-term state are managed within DuckDB.
  • The dedicated IR service handles complex indexing and retrieval logic using PostgreSQL.
  • The IR service communicates with the core adapter via its internal HTTP interface.

Deployment Guide

Prerequisites

  • Execution environment: Python version 3.9 or newer.
  • Package management: Standard pip utility.
  • Containerization: Availability of Docker and Docker Compose.

Method A: On-Premise Setup

1. Obtain Source Code

git clone <your-repo-url>
cd mcp-teams-gateway

2. Install Dependencies

pip install -r requirements.txt

3. Configuration

Duplicate the environment template and populate required Azure credentials:

cp .env.template .env
# Modify .env with necessary connection and authentication parameters

Refer to the configuration table below for variable definitions.

1. Obtain Source Code

git clone <your-repo-url>
cd mcp-teams-gateway

2. Configuration

Setup your secrets in the .env file:

cp .env.template .env
# Populate secrets in .env

3. Launch Services

docker-compose up -d

To monitor system operation:

docker-compose logs -f adapter_service  # Core MCP adapter logs
docker-compose logs -f indexing_engine  # IR engine logs

Demo Mode

Enable mock interactions by setting DEMO_MODE=true in the environment file, allowing testing without live Teams API interaction.

Configuration Parameters (.env)

Parameter Role Sample Value / Default
AZURE_CLIENT_ID Identifier for the registered Azure AD application xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
AZURE_CLIENT_SECRET Application secret key your-secret
AZURE_TENANT_ID Directory tenant identifier xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
AZURE_APP_OBJECT_ID Object ID corresponding to the application registration xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
DUCKDB_PATH File path for transient message database storage data/teams_mcp.duckdb
TOKEN_PATH Location to persist OAuth tokens data/token_cache.json
POLL_INTERVAL Frequency (seconds) for checking Teams for new activities 10
DEMO_MODE Activates simulation mode (disables Teams API interaction) false
OPENAI_API_KEY Key for generating semantic embeddings sk-...
POSTGRES_USER Database authentication user postgres
POSTGRES_PASSWORD Database access credential postgres
POSTGRES_DB Target database name for the IR service mcp_archive
IR_SERVER_HOST Network address for the indexing service indexing_service
IR_SERVER_PORT Network port for the indexing service 8090

Executing the MCP Adapter

Local Execution (Non-Containerized)

python core/adapter_main.py

Containerized Execution (Via Docker)

docker-compose up -d

Command Line Interface (CLI) Operations

Token Management

python cli/auth_util.py authenticate
python cli/auth_util.py show_status
python cli/auth_util.py revoke_session

Primary MCP Client Functions (Using stdio protocol)

Retrieve known conversation identifiers

python cli/mcp_client.py enumerate_chats

Fetch message history for a specific thread

python cli/mcp_client.py fetch_history <thread_id>

Transmit a message payload

python cli/mcp_client.py dispatch_message <thread_id> "Urgent data packet."

Initiate a new direct conversation

python cli/mcp_client.py initiate_chat <recipient_identifier>

Execute knowledge retrieval (hybrid, lexical, or vector)

python cli/mcp_client.py query_archive "system health status" --method combined --limit 5

Subscribe to real-time event feed

python cli/mcp_client.py subscribe_events

Indexing Service Interface (IR Server)

The IR service, running on PostgreSQL, exposes an external HTTP interface exclusively for the MCP adapter to manage and query indexed content.

Available HTTP Methods

1. Operational Status

GET http://localhost:8090/

2. Tool Directory

GET http://localhost:8090/api/tools_manifest

3. Content Search Operation

POST http://localhost:8090/api/tools/execute_search

Payload:

{
  "query_text": "retrieval target",
  "strategy": "combined",
  "count": 10
}

4. Content Ingestion (Indexing)

POST http://localhost:8090/api/tools/ingest

Payload:

{
  "payload": "Raw textual data to store",
  "context_tag": "teams_chat_log",
  "attributes": {
    "sender": "Agent_X",
    "timestamp": "2025-04-01T12:00:00Z"
  }
}

Consult indexer/API_SPEC.md for comprehensive IR server documentation.

Search Paradigm and Data Flow

  • Advanced Retrieval: Employs a fusion of BM25 ranking and vector similarity measurements, potentially enhanced by subsequent LLM evaluation.
  • Live Feeds: Real-time message ingress is managed via subscription to the messages/incoming event channel.

Development & Customization Points

  • Extend adapter functionality by defining new MCP verbs in core/adapter_main.py.
  • Modify Teams integration logic within the teams_connector/graph_api_handler.py module.
  • Enhance retrieval algorithms inside the IR service implementation.
  • Integrate auxiliary processing layers such as RAG pipelines or summarization routines utilizing DuckDB and PostgreSQL data stores.
  • Leverage the CLI utility as the primary regression testing harness for all protocol interactions.

Diagnostics and Common Issues

  • Authentication Failure: Validate Azure AD credentials and path settings in .env.
  • No Data Ingestion: Verify that the polling service is active and the service account is a member of the target Teams channels.
  • Storage Errors: Inspect file system permissions for the directory specified by DUCKDB_PATH.
  • Indexing Service Unreachable: Check container health via docker-compose logs for the indexing component.
  • Testing Locally: Use DEMO_MODE=true to isolate logic from external dependencies.

Referenced Materials


Detailed architectural blueprints are located in design/system_v2.md.

WIKIPEDIA: Business administrative solutions encompass the methodologies, software systems, controls, and analytical frameworks employed by organizations to navigate evolving commercial landscapes, maintain competitive advantage, and optimize operational efficacy. These tools address departmental necessities across planning, process orchestration, record keeping, human capital management, and strategic decision-making.

== Management Tool Categories == Business tools can be functionally categorized based on organizational aspects such as:

  • Data entry and integrity verification mechanisms.
  • Process monitoring and refinement frameworks.
  • Data aggregation and strategic assessment platforms.

Technological maturation over the last decade has drastically altered the landscape of available business software. The pressure to reduce expenditures, maximize sales conversion, deeply understand client requirements, and consistently deliver products matching those needs compels managers toward strategic selection and rigorous customization of tools, rather than passive adoption of novel systems. Ineffective tool adaptation often results in organizational fragility.

== 2013 Benchmarks == A 2013 analysis by Bain & Company highlighted global tool utilization patterns, reflecting regional market dynamics and economic conditions. Leading categories included:

  1. Strategic Planning Frameworks
  2. Customer Relationship Management (CRM)
  3. Workforce Sentiment Analysis
  4. Competitive Benchmarking
  5. Performance Measurement Systems (e.g., Balanced Scorecard)
  6. Core Capability Definition
  7. Outsourcing Strategy
  8. Organizational Change Management Programs
  9. Supply Chain Optimization
  10. Vision/Mission Articulation
  11. Market Segmentation Analysis
  12. Total Quality Management (TQM)

== Business Software Evolution == Commercial software evolved from foundational Management Information Systems (MIS) through integrated Enterprise Resource Planning (ERP) suites, later incorporating Customer Relationship Management (CRM), culminating in modern cloud-based management platforms. Sustained organizational value derives not just from IT investment, but critically from the efficacy of the implementation process and the precise alignment between selected tools and enterprise-specific requirements.

See Also

`