liliankasem/azfunc-insights-mcp-server
If you are the rightful owner of azfunc-insights-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
Azure Functions Insights MCP Server provides comprehensive monitoring and insights tools for Azure Functions resources, leveraging the Model Context Protocol.
Azure Functions Insights MCP Server
An Azure Functions MCP (Model Context Protocol) server that provides comprehensive monitoring and insights tools for your Azure Functions resources. Built with .NET 10 isolated worker and the Azure Functions MCP extension.
Prerequisites
- .NET 10 SDK
- Azure Functions Core Tools
- Azure CLI (for authentication)
- Azure Developer CLI (azd) (for deployment)
- Bicep CLI (for infrastructure)
- An Azure subscription with Azure Functions resources
🚀 Quick Start
Simple 3-Step Setup:
-
Add your Azure Subscription ID to
src/local.settings.json:{ "Values": { "AZURE_SUBSCRIPTION_ID": "your-subscription-id-here" } }Remember to remove
.samplefromsrc/local.settings.sample.json -
Start the MCP server:
cd src func start -
Connect in VS Code:
- Open
.vscode/mcp.json - Click "Start" for the
local-azure-function-insightsserver - Start using MCP tools in GitHub Copilot Chat!
- Open
Example tool invocations in chat:
#mcp_local-azure-f_ListFunctionsList all my Azure Function Apps#mcp_local-azure-f_GetFunctionStatusWhat's the status of my-function-app?#mcp_local-azure-f_GetFailedExecutionsShow me failed executions for payment-processor#mcp_local-azure-f_ListFailingFunctionsWhich of my functions are failing?#mcp_local-azure-f_GetTraceLogsShow me trace logs for broken-app
Features
🔍 Seven Powerful MCP Tools
-
ListFunctions - List all Azure Function Apps in your subscription
- Filter by resource group
- Paginated results (default 50 per page)
- Returns: name, location, state, runtime version, tags
-
GetFunctionStatus - Get detailed status of a specific Function App
- Current state (Running, Stopped, etc.)
- List of all functions in the app
- Runtime version and host information
- Host health checks (checks
/admin/host/statusand/admin/host/ping) - Detects runtime errors (InternalServerError, host failures)
-
GetFunctionMetrics - Retrieve execution metrics and analytics
- Total, successful, and failed execution counts
- Average, min, and max duration statistics
- Success rate percentage
- Configurable time range (1-720 hours)
-
GetFailedExecutions - Analyze recent failures with full details
- Error messages and exception types
- Complete stack traces for debugging
- Invocation IDs for correlation
- Execution duration
- Includes errors from requests, exceptions, AND trace logs
- Configurable count (1-100) and time range
-
GetTraceLogs - Get recent trace logs from Application Insights
- Useful for debugging broken Function Apps
- Works even when requests/exceptions tables are empty
- Configurable severity level filtering (Verbose, Info, Warning, Error, Critical)
- Configurable count and time range
-
ListFailingFunctions - Overview of all failing Function Apps
- Shows which apps have recent failures
- Error rates and failure counts for each app
- Sorted by worst performers first
- Quick health dashboard for entire subscription
-
QueryApplicationInsights - Execute custom KQL queries
- Run any Kusto Query Language query
- Access full Application Insights telemetry
- Queries Log Analytics workspaces (AppRequests, AppExceptions, AppTraces tables)
- Custom analytics and reporting
- Configurable time range
Setup
1. Clone and Restore
git clone https://github.com/liliankasem/azfunc-insights-mcp-server.git
cd /path/to/azfunc-insights-mcp
dotnet restore
2. Configure Authentication
Option A: Azure CLI (Recommended for Local Development)
az login
az account set --subscription "YOUR_SUBSCRIPTION_ID"
Option B: Service Principal (Production/CI/CD)
Set environment variables:
export AZURE_TENANT_ID="your-tenant-id"
export AZURE_CLIENT_ID="your-client-id"
export AZURE_CLIENT_SECRET="your-client-secret"
3. Configure Application Settings
Edit local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"AZURE_SUBSCRIPTION_ID": "your-subscription-id-here"
}
}
Required:
AZURE_SUBSCRIPTION_ID- Your Azure subscription ID
4. Grant Required Azure Permissions
Your Azure identity (user or service principal) needs:
- Reader role on the subscription or resource groups containing Function Apps
# Grant Reader access to subscription
az role assignment create \
--assignee "user@example.com" \
--role "Reader" \
--scope "/subscriptions/YOUR_SUBSCRIPTION_ID"
Running Locally
Start Azurite (Azure Storage Emulator)
If you don't have Azure Storage configured:
# Install Azurite
npm install -g azurite
# Start Azurite
azurite --silent --location ./azurite --debug ./azurite/debug.log
Run the Function App
cd src
func start
Deployment
Deploy to Azure with Azure Developer CLI
The easiest way to deploy is using azd:
# Login to Azure
az login
# Deploy everything (infrastructure + app)
azd up
# You'll be prompted for:
# - Environment name (e.g., "dev", "prod")
# - Azure location (e.g., "eastus", "westus2")
# - Azure subscription (if you have multiple)
What gets deployed:
- Resource Group
- Storage Account
- Application Insights
- App Service Plan (Flex Consumption - FC1 SKU)
- Function App with:
- System-assigned managed identity
- Flex Consumption configuration (2048 MB memory, up to 100 instances)
- Required app settings (subscription ID, defaults to the one this app is being deployed to)
- Automatic RBAC role assignments (Reader on subscription, Log Analytics Reader)
Update app code:
azd deploy
Clean up all resources:
azd down
Usage Examples
Connect an MCP Client
Configure your MCP client (e.g., Claude Desktop, VS Code extension) to connect to:
http://localhost:7071/runtime/webhooks/mcp
Example Tool Invocations
List all Function Apps
{
"tool": "ListFunctions",
"arguments": {}
}
List Function Apps in a specific resource group
{
"tool": "ListFunctions",
"arguments": {
"resourceGroupName": "my-functions-rg",
"pageSize": 25
}
}
Get Function App status
{
"tool": "GetFunctionStatus",
"arguments": {
"appName": "my-function-app"
}
}
Get metrics for the last 48 hours
{
"tool": "GetFunctionMetrics",
"arguments": {
"appName": "my-function-app",
"hoursBack": 48
}
}
Get last 20 failed executions
{
"tool": "GetFailedExecutions",
"arguments": {
"appName": "my-function-app",
"count": 20,
"hoursBack": 24
}
}
Query Application Insights (using Log Analytics tables)
{
"tool": "QueryApplicationInsights",
"arguments": {
"appName": "my-function-app",
"query": "AppRequests | where Success == false | summarize count() by ResultCode",
"hoursBack": 24
}
}
Get trace logs for debugging
{
"tool": "GetTraceLogs",
"arguments": {
"appName": "my-function-app",
"count": 50,
"minSeverityLevel": 3,
"hoursBack": 24
}
}
List all failing Function Apps
{
"tool": "ListFailingFunctions",
"arguments": {
"hoursBack": 24
}
}
Troubleshooting
"AZURE_SUBSCRIPTION_ID is not configured"
Ensure AZURE_SUBSCRIPTION_ID is set in local.settings.json or environment variables.
"Application Insights is not configured"
This means the Function App doesn't have Application Insights linked or the service couldn't discover it. The MCP server automatically discovers each Function App's Application Insights workspace by:
- Reading the
hidden-link: /app-insights-resource-idtag from the Function App - Following the resource chain to find the Log Analytics workspace
- Extracting the workspace customer ID for querying
If telemetry features don't work, ensure:
- The Function App has Application Insights enabled
- The
hidden-link: /app-insights-resource-idtag is present on the Function App - Your managed identity has Reader permissions on the Application Insights resource
Note: Application Insights workspace discovery works via ARM tags, independent of the Function App's environment variables. This means it works even if the Function App host is broken.
"No telemetry data available"
This message appears when the Log Analytics workspace exists but has no data. Common causes:
- The Function App hasn't been invoked yet
- Application Insights data hasn't been ingested (can take a few minutes)
- The workspace is newly created and empty
- The Function App is broken and unable to send telemetry
Try using GetTraceLogs to check if any trace data is available, or GetFunctionStatus to verify the host health.
Authentication Failures
# Verify Azure CLI login
az account show
# Test Azure access
az functionapp list --query "[].{Name:name, State:state}" -o table
Rate Limiting
The service limits concurrent Azure API requests to 5. If you experience throttling, this is working as designed to prevent overwhelming Azure APIs.
License
MIT License - see LICENSE file for details