IF-MCP-Server-for-Microsoft-Teams

microsoft/IF-MCP-Server-for-Microsoft-Teams

3.3

If you are the rightful owner of IF-MCP-Server-for-Microsoft-Teams and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Model Context Protocol (MCP) server is a demonstration project designed to provide legal research capabilities through the Court Listener API, integrated with Microsoft Teams using Azure technologies.

Tools
4
Resources
0
Prompts
0

Court Listener MCP Teams Bot

A demonstration project showing how to build a Microsoft Teams bot using the Model Context Protocol (MCP) to provide legal research capabilities through the Court Listener API.

Overview

This project demonstrates:

  • Building a custom MCP server as an Azure Function
  • Integrating the Court Listener REST API for case law research
  • Using Microsoft Dataverse for response caching
  • Creating a Teams bot with Bot Framework SDK
  • Leveraging Azure OpenAI for natural language understanding
  • Connecting MCP clients to standalone MCP servers

Important: This demo uses the Microsoft Bot Framework which is scheduled for end of support on December 31, 2025. You can use this demo beyond that date, but understand that this demo is not intended to be used in production for a long period of time. The demo exists to merely show the concepts of architecture and functionality. For production usage, the dependencies of the web application (Teams Bot) should be updated to use the Microsoft Agents SDK. Once the end-of-support date has been reached, we will update the repo with the necessary changes that leverage the Microsoft Agents SDK.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Microsoft Teams                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Teams Bot (Azure App Service)                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Bot Framework SDK                                         β”‚  β”‚
β”‚  β”‚  - Receives user messages                                  β”‚  β”‚
β”‚  β”‚  - Routes to Azure OpenAI for intent understanding         β”‚  β”‚
β”‚  β”‚  - Calls MCP server with determined tool & params          β”‚  β”‚
β”‚  β”‚  - Formats and returns results to Teams                    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Azure OpenAI    β”‚          β”‚    MCP Client                  β”‚ β”‚
β”‚  β”‚ (GPT-4.1)       β”‚          β”‚    - HTTP/JSON-RPC protocol    β”‚ β”‚
β”‚  β”‚                 β”‚          β”‚    - Tool invocation           β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                         β”‚ HTTP/JSON-RPC
                                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              MCP Server (Azure Functions)                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Microsoft MCP Extension                                   β”‚  β”‚
β”‚  β”‚  - Endpoint: /runtime/webhooks/mcp                         β”‚  β”‚
β”‚  β”‚  - Protocol: JSON-RPC 2.0 (JSON/SSE)                       β”‚  β”‚
β”‚  β”‚                                                            β”‚  β”‚
β”‚  β”‚  MCP Tools (via McpToolTrigger):                           β”‚  β”‚
β”‚  β”‚  β€’ search_opinions - Search court opinions                 β”‚  β”‚
β”‚  β”‚  β€’ get_opinion_details - Get specific opinion              β”‚  β”‚
β”‚  β”‚  β€’ search_dockets - Search dockets/cases                   β”‚  β”‚
β”‚  β”‚  β€’ get_court_info - Get court information                  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Dataverse Cache      β”‚      β”‚ Court Listener Client         β”‚ β”‚
β”‚  β”‚ - 30-day TTL         β”‚      β”‚ - REST API integration        β”‚ β”‚
β”‚  β”‚ - SHA-256 keys       β”‚      β”‚                               β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚                       β”‚
                         β–Ό                       β–Ό
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚ Microsoft Dataverseβ”‚   β”‚  Court Listener API      β”‚
             β”‚ (Cache Storage)    β”‚   β”‚  courtlistener.com       β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

1. MCP Server (/mcp-server)

  • Technology: C# Azure Functions (.NET 8) with Microsoft MCP Extension
  • Purpose: Standalone MCP server exposing Court Listener API as MCP tools
  • Features:
    • Official Microsoft MCP extension (Microsoft.Azure.Functions.Worker.Extensions.Mcp)
    • MCP protocol support (JSON-RPC 2.0 over JSON and SSE)
    • 4 MCP tools for legal research (attribute-based registration)
    • Dataverse integration for caching (30-day TTL)
    • Service Principal authentication
    • Health monitoring endpoint
    • Single endpoint /runtime/webhooks/mcp for all tools

2. Teams Bot (/teams-bot)

  • Technology: C# ASP.NET Core with Bot Framework SDK (.NET 8)
  • Purpose: Teams interface for legal research
  • Features:
    • Bot Framework integration
    • Azure OpenAI (GPT-4.1) for intent recognition
    • MCP client for calling the MCP server
    • Natural language query processing
    • Formatted response generation

3. Microsoft Dataverse

  • Purpose: Response caching layer
  • Features:
    • Custom table for cache entries
    • SHA-256 hashed cache keys
    • Automatic expiration (30 days)
    • Service Principal access

4. Azure OpenAI

  • Purpose: Natural language understanding
  • Features:
    • Intent detection from user queries
    • Tool and parameter extraction
    • Response formatting for Teams
    • GPT-4.1 deployment

Project Structure

mcp-teams/
β”œβ”€β”€ mcp-server/                 # MCP Server (Azure Functions)
β”‚   β”œβ”€β”€ Models/
β”‚   β”‚   β”œβ”€β”€ McpModels.cs            # MCP protocol models
β”‚   β”‚   └── CourtListenerModels.cs  # Court Listener API models
β”‚   β”œβ”€β”€ Services/
β”‚   β”‚   β”œβ”€β”€ ICourtListenerClient.cs # Court Listener client interface
β”‚   β”‚   β”œβ”€β”€ CourtListenerClient.cs  # Court Listener API client
β”‚   β”‚   β”œβ”€β”€ IDataverseCache.cs      # Dataverse cache interface
β”‚   β”‚   └── DataverseCache.cs       # Dataverse caching service
β”‚   β”œβ”€β”€ McpTools.cs                 # MCP tools (using MCP extension)
β”‚   β”œβ”€β”€ HealthFunction.cs           # Health check endpoint
β”‚   β”œβ”€β”€ Program.cs                  # Application entry point
β”‚   β”œβ”€β”€ host.json                   # Azure Functions host config
β”‚   β”œβ”€β”€ local.settings.json         # Local development settings
β”‚   └── CourtListenerMcpServer.csproj
β”‚
β”œβ”€β”€ teams-bot/                  # Teams Bot
β”‚   β”œβ”€β”€ Bots/
β”‚   β”‚   └── CourtListenerBot.cs     # Main bot logic
β”‚   β”œβ”€β”€ Services/
β”‚   β”‚   β”œβ”€β”€ IMcpClient.cs           # MCP client interface
β”‚   β”‚   β”œβ”€β”€ McpClient.cs            # MCP client implementation
β”‚   β”‚   β”œβ”€β”€ IAzureOpenAIService.cs  # OpenAI service interface
β”‚   β”‚   └── AzureOpenAIService.cs   # OpenAI integration
β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   └── BotController.cs        # Bot Framework endpoint
β”‚   β”œβ”€β”€ Models/
β”‚   β”‚   └── McpModels.cs            # MCP protocol models
β”‚   β”œβ”€β”€ TeamsAppManifest/
β”‚   β”‚   └── manifest.json           # Teams app package
β”‚   β”œβ”€β”€ AdapterWithErrorHandler.cs  # Bot Framework adapter
β”‚   β”œβ”€β”€ Program.cs                  # Application entry point
β”‚   β”œβ”€β”€ appsettings.json            # Application settings
β”‚   └── CourtListenerTeamsBot.csproj
β”‚
β”œβ”€β”€ docs/                       # Documentation
β”‚   β”œβ”€β”€ resource-identification.md  # Resource naming guide
β”‚   β”œβ”€β”€ azure-setup.md              # Azure resources setup
β”‚   β”œβ”€β”€ dataverse-setup.md          # Dataverse configuration
β”‚   β”œβ”€β”€ mcp-server-setup.md         # MCP server deployment
β”‚   β”œβ”€β”€ teams-bot-setup.md          # Teams bot deployment
β”‚   └── teams-app-registration.md   # Teams app installation
β”‚
β”œβ”€β”€ README.md                   # This file
β”œβ”€β”€ QUICKSTART.md               # Quick reference guide
β”œβ”€β”€ DEPLOYMENT-CHECKLIST.md     # Deployment checklist
β”œβ”€β”€ SECURITY.md                 # Security information
└── LICENSE                     # MIT License

Prerequisites

  • Azure subscription
  • .NET 8 SDK
  • Azure Functions Core Tools
  • Azure CLI
  • Power Platform environment (with associated Azure subscription)
  • Microsoft Teams admin access (or custom app upload permission)

Getting Started

Deploying the demo requires approximately 90 minutes.

You can view the for faster reference. However, for your first deployment, we encourage you to follow the setup guides in order:

  1. (10 Minutes)

    • Set all resource name variables
    • Verify name availability
    • Save variables for later use
  2. (30 Minutes)

    • Create Azure OpenAI resource
    • Create Bot Service registration
    • Create Function App for MCP server
    • Create App Service for Teams bot
  3. (15 Minutes)

    • Create Power Platform environment
    • Configure Service Principal access
    • Create custom cache table
  4. (15 Minutes)

    • Configure and test locally
    • Deploy to Azure Functions
    • Verify endpoints
  5. (15 Minutes)

    • Configure and test locally
    • Deploy to Azure App Service
    • Configure bot endpoint
  6. (10 Minutes)

    • Create Teams app package
    • Install in Microsoft Teams
    • Test the bot

MCP Tools

The MCP server exposes four tools:

1. search_opinions

Search for court opinions by keywords, court, date range.

Parameters:

  • q (string): Search query
  • court (string): Court ID (e.g., "scotus", "ca9")
  • filedAfter (string): Date filter (YYYY-MM-DD)
  • filedBefore (string): Date filter (YYYY-MM-DD)
  • orderBy (string): Sort field

Example:

{
  "name": "search_opinions",
  "arguments": {
    "q": "copyright",
    "court": "scotus"
  }
}

2. get_opinion_details

Get detailed information about a specific opinion.

Parameters:

  • opinion_id (integer): The opinion ID

3. search_dockets

Search for dockets/cases.

Parameters:

  • q (string): Search query
  • court (string): Court ID
  • docket_number (string): Docket number
  • case_name (string): Case name
  • filed_after (string): Date filter
  • filed_before (string): Date filter

4. get_court_info

Get information about courts.

Parameters:

  • court_id (string, optional): Specific court ID
  • jurisdiction (string, optional): Filter by jurisdiction
  • in_use (boolean, optional): Filter by active status

Usage Examples

In Microsoft Teams

User: "Find Supreme Court opinions about privacy from 2023"

Bot Response:

I found 5 Supreme Court opinions about privacy from 2023:

1. Smith v. United States (2023)
   Court: Supreme Court of the United States
   Filed: March 15, 2023
   View: [Link to opinion]

2. Johnson v. California (2023)
   Court: Supreme Court of the United States
   Filed: June 22, 2023
   View: [Link to opinion]

...

Common Court IDs

  • scotus - Supreme Court of the United States
  • ca1 through ca11 - Federal Circuit Courts (1st-11th)
  • cadc - D.C. Circuit
  • cafc - Federal Circuit
  • dcd - D.C. District Court
  • nysd - Southern District of New York
  • cand - Northern District of California

Development

Local Development - MCP Server

cd mcp-server
dotnet restore
dotnet build
func start

Test with:

curl -X POST http://localhost:7071/runtime/webhooks/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":"1","method":"tools/list"}'

Local Development - Teams Bot

cd teams-bot
dotnet restore
dotnet build
dotnet run

Test with Bot Framework Emulator at http://localhost:5000/api/messages

Deployment

Deploy MCP Server

cd mcp-server
func azure functionapp publish func-courtlistener-mcp

Deploy Teams Bot

cd teams-bot
dotnet publish -c Release
# Then deploy via Azure CLI or Visual Studio

Configuration

MCP Server (Azure Functions)

{
  "CourtListener__BaseUrl": "https://www.courtlistener.com/api/rest/v3/",
  "CourtListener__ApiKey": "",
  "Dataverse__Environment": "https://yourorg.crm.dynamics.com",
  "Dataverse__ClientId": "<app-id>",
  "Dataverse__ClientSecret": "<secret>",
  "Dataverse__TenantId": "<tenant-id>",
  "Dataverse__TableName": "<table-name-including-prefix>"
  "Cache__ExpirationDays": "30"
}

Teams Bot (App Service)

{
  "MicrosoftAppId": "<bot-app-id>",
  "MicrosoftAppPassword": "<bot-secret>",
  "MicrosoftAppTenantId": "<tenant-id>",
  "MicrosoftAppType": "SingleTenant",
  "AzureOpenAI__Endpoint": "https://yourservice.openai.azure.com/",
  "AzureOpenAI__ApiKey": "<openai-key>",
  "AzureOpenAI__DeploymentName": "gpt-4.1",
  "McpServer__BaseUrl": "https://func-courtlistener-mcp.azurewebsites.net",
  "McpServer__FunctionKey": "<mcp-extension-system-key>"
}

Note: The McpServer__FunctionKey must be the mcp_extension system key, NOT the default function key. The Teams bot calls /runtime/webhooks/mcp with the x-functions-key header.

Monitoring

Application Insights

  • MCP server logs and metrics
  • Teams bot logs and metrics
  • Performance tracking
  • Error monitoring

Logs

# MCP Server
az webapp log tail --name func-courtlistener-mcp --resource-group rg-courtlistener-demo

# Teams Bot
az webapp log tail --name app-courtlistener-bot --resource-group rg-courtlistener-demo

Security

  • Service Principal Authentication for Dataverse
  • Azure Key Vault for secrets (recommended for production)
  • HTTPS only enforcement
  • MCP Extension System Key (mcp_extension) for MCP server access
  • Bot Framework authentication for Teams
  • Header-based authentication (x-functions-key) for MCP endpoint

Why MCP?

This demo showcases MCP as a standalone service architecture:

  1. Reusability: The MCP server can be consumed by:

    • Teams bots
    • Copilot Studio
    • Desktop MCP clients
    • Other applications
  2. Separation of Concerns:

    • MCP server: API integration + caching
    • Teams bot: User interface + AI orchestration
  3. Scalability: Independent scaling of components

  4. Maintainability: Update API integration without touching the bot

Extending the Demo

Add More Tools

  1. Add new methods to McpTools.cs with [McpToolTrigger] and [McpToolProperty] attributes
  2. Implement the Court Listener API integration in CourtListenerClient.cs if needed
  3. Follow the pattern of existing tools (e.g., SearchOpinions, GetOpinionDetails)
  4. Redeploy the function app to register the new tools

Add More Clients

  1. Copilot Studio: Connect to MCP server via custom connector
  2. Power Apps: Call MCP server via Power Automate
  3. Desktop App: Use MCP client library

Enhance Caching

  • Add cache invalidation API
  • Implement cache warming
  • Add cache analytics

Improve AI

  • Fine-tune prompts for better intent detection
  • Add multi-turn conversations
  • Implement clarifying questions

Troubleshooting

See individual setup guides for detailed troubleshooting:

Resources

License

This project is licensed under the MIT License - see the file for details.

Contributing

This is a demonstration project. Feel free to fork and adapt for your own use cases.

Support

For issues or questions:

  • Review the documentation in /docs
  • Check Azure resource configurations
  • Review Application Insights logs
  • Test components independently

Acknowledgments