microsoft/IF-MCP-Server-for-Microsoft-Teams
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.
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/mcpfor all tools
- Official Microsoft MCP extension (
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:
-
(10 Minutes)
- Set all resource name variables
- Verify name availability
- Save variables for later use
-
(30 Minutes)
- Create Azure OpenAI resource
- Create Bot Service registration
- Create Function App for MCP server
- Create App Service for Teams bot
-
(15 Minutes)
- Create Power Platform environment
- Configure Service Principal access
- Create custom cache table
-
(15 Minutes)
- Configure and test locally
- Deploy to Azure Functions
- Verify endpoints
-
(15 Minutes)
- Configure and test locally
- Deploy to Azure App Service
- Configure bot endpoint
-
(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 querycourt(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 querycourt(string): Court IDdocket_number(string): Docket numbercase_name(string): Case namefiled_after(string): Date filterfiled_before(string): Date filter
4. get_court_info
Get information about courts.
Parameters:
court_id(string, optional): Specific court IDjurisdiction(string, optional): Filter by jurisdictionin_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 Statesca1throughca11- Federal Circuit Courts (1st-11th)cadc- D.C. Circuitcafc- Federal Circuitdcd- D.C. District Courtnysd- Southern District of New Yorkcand- 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__FunctionKeymust be themcp_extensionsystem key, NOT the default function key. The Teams bot calls/runtime/webhooks/mcpwith thex-functions-keyheader.
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:
-
Reusability: The MCP server can be consumed by:
- Teams bots
- Copilot Studio
- Desktop MCP clients
- Other applications
-
Separation of Concerns:
- MCP server: API integration + caching
- Teams bot: User interface + AI orchestration
-
Scalability: Independent scaling of components
-
Maintainability: Update API integration without touching the bot
Extending the Demo
Add More Tools
- Add new methods to
McpTools.cswith[McpToolTrigger]and[McpToolProperty]attributes - Implement the Court Listener API integration in
CourtListenerClient.csif needed - Follow the pattern of existing tools (e.g.,
SearchOpinions,GetOpinionDetails) - Redeploy the function app to register the new tools
Add More Clients
- Copilot Studio: Connect to MCP server via custom connector
- Power Apps: Call MCP server via Power Automate
- 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
- Court Listener API Documentation
- MCP Protocol Specification
- Bot Framework Documentation
- Azure OpenAI Documentation
- Microsoft Dataverse Documentation
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
- Court Listener for providing the free legal research API
- Model Context Protocol for the protocol specification
- Microsoft for Azure, Teams, and Bot Framework platforms