The Azure Log Analytics MCP Server is a specialized implementation of the Model Context Protocol (MCP) designed to facilitate natural language queries against Azure Log Analytics. This server leverages Claude AI to convert natural language queries into Kusto Query Language (KQL) and executes them against Azure Log Analytics, making it easier for users to interact with their logs without needing to write complex queries.
# Clone the repository
git clone https://github.com/MananShahTR/azure-log-analytics-mcp.git
cd azure-log-analytics-mcp
# Install dependencies
npm install
# Build the project
npm run build
ANTHROPIC_API_KEY
: Your Anthropic API key for Claude AI.Ensure you are logged in using Azure CLI (az login
). Configure the following in azure-service.ts
:
- subscriptionId
: Your Azure subscription ID.
- resourceGroup
: The resource group containing your Application Insights resource.
- appInsightsId
: The name of your Application Insights resource.
# Run as a CLI tool
ANTHROPIC_API_KEY=your_key_here node build/index.js
# Run as an MCP server
ANTHROPIC_API_KEY=your_key_here node build/mcp-server.js
Add the following to your MCP settings configuration file:
{
"mcpServers": {
"azure-log-analytics": {
"command": "node",
"args": ["path/to/azure-log-analytics-mcp/build/mcp-server.js"],
"env": {
"ANTHROPIC_API_KEY": "your_key_here"
}
}
}
}
The MCP server provides the following tool:
- query_logs
: Query Azure Log Analytics using natural language.
- Parameters:
- query
: Natural language query about trace logs (required).
- timeRange
: Optional time range (e.g., "last 24 hours", "past week").
- limit
: Maximum number of results to return.
// Example MCP tool use
use_mcp_tool({
server_name: "azure-log-analytics",
tool_name: "query_logs",
arguments: {
query: "Show me all errors in the authentication service from the last hour",
timeRange: "last hour",
limit: 10
}
});
MIT
This project is designed to simplify querying Azure Log Analytics by enabling natural language interactions through the MCP protocol. It integrates Claude AI for query translation and provides both CLI and server modes for flexibility.