Supports containerized deployment of the MCP server and its components, allowing for easier setup and deployment of the complete system.
Used for persistent storage of Teams chat and message history, enabling search and retrieval of past communications.
Provides environment variable management for configuring the MCP server with Azure AD and Teams credentials, database paths, and other settings.
Integrates with Microsoft Teams messaging, enabling sending/receiving messages, creating chats, and streaming new messages through MCP tools and events.
Used for generating embeddings for the hybrid search functionality, powering semantic search capabilities for Teams messages.
Powers the Information Retrieval server for advanced search capabilities, providing both lexical and vector search with pgvector extension.
Core implementation language for the MCP server, using FastMCP to enable communication between LLMs and Microsoft Teams.
Provides terminal UI capabilities for the CLI MCP client, enabling local testing and interaction with Teams via a command-line interface.
Teams Messenger MCP App
This project implements a pure Model Context Protocol (MCP) server that bridges Microsoft Teams and MCP-compatible clients (LLMs, agentic frameworks, and a rich CLI MCP client). All features are exposed via MCP tools, resources, and events—no REST API endpoints.
Features
- Microsoft Teams chat/message integration via MCP
- PostgreSQL-based Information Retrieval (IR) server for advanced search capabilities
- Persistent storage in DuckDB for chat/message history
- Hybrid semantic and lexical search (BM25 + vector, FlockMTL-style)
- CLI for login/token management and a rich MCP client for local testing
- Polling-based event emission for new messages
- Live event streaming and search for LLMs and CLI
- Single-agent (bot) account, not multi-user
Architecture
- All chat/message/search logic is via MCP tools/resources/events
- Teams MCP server uses DuckDB for message storage
- IR server provides advanced search capabilities with PostgreSQL and pgvector
- IR server exposes an HTTP API for MCP server communication
Installation
Requirements
- Python 3.9+
- pip
- Docker and Docker Compose (for containerized deployment)
Option 1: Local Installation
1. Clone the repository
2. Install dependencies
3. Configure environment variables
Copy the template and fill in your Azure AD/Teams credentials:
See the table below for variable descriptions.
Option 2: Docker Deployment (Recommended)
1. Clone the repository
2. Configure environment variables
Copy the template and fill in your credentials:
3. Build and start services
Environment Variables (.env)
Variable | Description | Example / Default |
---|---|---|
AZURE_CLIENT_ID | Azure AD Application (client) ID | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
AZURE_CLIENT_SECRET | Azure AD Application secret | your-secret |
AZURE_TENANT_ID | Azure AD Tenant ID | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
AZURE_APP_OBJECT_ID | Azure AD Application object ID | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
DUCKDB_PATH | Path to DuckDB database file | db/teams_mcp.duckdb |
TOKEN_PATH | Path to store persistent token cache | db/token_cache.json |
POLL_INTERVAL | Polling interval (seconds) for new messages | 10 |
DEMO_MODE | Set to true for mock/demo mode (no real Teams API calls) | false |
OPENAI_API_KEY | OpenAI API key for embedding generation | sk-... |
POSTGRES_USER | PostgreSQL username | postgres |
POSTGRES_PASSWORD | PostgreSQL password | postgres |
POSTGRES_DB | PostgreSQL database name | mcp_ir |
IR_SERVER_HOST | IR server hostname | ir_server |
IR_SERVER_PORT | IR server port | 8090 |
Running the MCP Server
Local Mode (without Docker)
Docker Mode (All Services)
To check logs:
Demo Mode (no real Teams API calls)
Set DEMO_MODE=true
in your .env
and run as above.
CLI Usage
1. Login and Token Management
2. Rich CLI MCP Client
All commands below use the MCP stdio protocol to talk to the server.
List chats
Get messages from a chat
Send a message
Create a new 1:1 chat
Search messages (hybrid, BM25, or vector)
Stream new incoming messages (live event subscription)
IR Server Usage
The IR server provides advanced search capabilities with PostgreSQL and pgvector. It exposes an HTTP API for MCP server communication.
IR Server API Endpoints
1. Health Check
2. List Available Tools
3. Search Content
Body:
4. Index Content
Body:
For more detailed IR server documentation, see ir/README.md.
Search and Event Streaming
- Hybrid search: Combines BM25 and vector search with LLM reranking
- Live streaming: Subscribe to
messages/incoming
for real-time updates
Development & Extension
- Add new MCP tools/resources in
mcp_server/server.py
- Extend Teams integration in
teams/graph.py
- Modify IR capabilities in the IR server
- Add analytics, summarization, or RAG features using DuckDB, PostgreSQL, and LLMs
- Use the CLI as a test harness for all MCP features
Troubleshooting & FAQ
- Login fails: Check your Azure AD credentials and
.env
values - No messages appear: Ensure polling is running and your bot account is in the Teams chat
- DuckDB errors: Check file permissions and paths in
.env
- IR server not responding: Check Docker logs and ensure the container is running
- Demo mode: Set
DEMO_MODE=true
for local testing without real Teams
References
- Beyond Quacking: Deep Integration of Language Models and RAG into DuckDB (FlockMTL)
- Model Context Protocol documentation
- Microsoft Graph API docs
- PostgreSQL with pgvector extension
For full product details, see specs/app-spec.md
.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A Model Context Protocol server that bridges Microsoft Teams with MCP-compatible clients (LLMs, agentic frameworks, CLI), enabling chat integration, message search, and event streaming without traditional REST API endpoints.
Related MCP Servers
- AsecurityAlicenseAqualityAn educational implementation of a Model Context Protocol server that demonstrates how to build a functional MCP server for integrating with various LLM clients like Claude Desktop.Last updated -188PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables interaction with Microsoft Dynamics 365 CRM from Claude Desktop, allowing users to retrieve, create, and update CRM data through natural language.Last updated -54TypeScriptMIT License
- -securityAlicense-qualityA demonstration server that implements the Model Context Protocol (MCP) SDK, providing tools and endpoints for server-sent events and message handling.Last updated -27TypeScriptMIT License
- -security-license-qualityA Model Context Protocol server that bridges Microsoft Teams and MCP-compatible clients, enabling chat integration, message handling, and advanced search capabilities without REST API endpoints.Last updated -Python