kql-search-mcp
v1.0.5
Published
MCP server for searching GitHub for KQL (Kusto Query Language) queries with natural language support, schema intelligence, and smart caching
Maintainers
Readme
KQL MCP Server
A Model Context Protocol (MCP) server that searches all of GitHub for KQL (Kusto Query Language) queries using natural language, with built-in schema intelligence for 331+ KQL tables from Microsoft Defender XDR, Microsoft Sentinel, and Azure Monitor.
Features
ASIM Schema Validation & Normalization
- Advanced Security Information Model (ASIM) Support: Work with 11 GA ASIM schemas for normalized security event queries
- Comprehensive Field Validation: 230+ fields across all ASIM schemas with detailed metadata
- Schema Information: Get detailed information about ASIM schemas including:
- Key fields and entities for each schema
- Field classifications (Mandatory, Recommended, Optional, Conditional)
- Field descriptions, types, and examples
- Entity relationships between schemas
- Query Templates: Generate ready-to-use KQL query templates for any ASIM schema
- Parser Recommendations: Get naming conventions and best practices for ASIM parsers
- Supported Schemas: Alert Event, Authentication Event, Network Session, Process Event, File Activity, DNS Activity, Audit Event, Registry Event, DHCP Activity, User Management, and Web Session
GitHub Search & Query Discovery
- Universal GitHub Search: Search across ALL public GitHub repositories for KQL queries
- Natural Language Interface: Use plain English to describe
what you're looking for
- "Find security threat hunting queries"
- "Show me Microsoft Sentinel detection rules for failed logins"
- "Get queries for monitoring Kubernetes events"
- Intelligent Parsing: Automatically extracts and parses KQL queries from source files
- Smart Ranking: Results ranked by relevance, repository popularity, and query quality
- Context Aware: Includes surrounding documentation and comments for better understanding
- Flexible Search: Search by file, repository, or natural language query
- Pagination Support: Fetch up to 1000 results with automatic pagination
KQL Table Schema Intelligence & Query Generation
- Comprehensive Schema Index: 331+ tables from Microsoft Defender XDR, Microsoft Sentinel, and Azure Monitor Logs
- Validated Query Generation: Generate KQL queries with full schema validation
- Table names verified against schema index
- Column names and data types validated
- Syntax correctness guaranteed
- Returns validation results with errors/warnings
- Query Validation: Validate existing queries for correctness before execution
- Natural Language Table Search: Find tables by describing what data you need - "authentication events", "email security", "vulnerability data"
- Detailed Schema Information: Complete column definitions with data types, descriptions, and usage examples
- Smart Query Templates: Generate KQL query templates automatically from table schemas
- Documentation Links: Automatic Microsoft Learn documentation links for tables and operators
- Column Discovery: Find which tables contain specific columns
- Join Suggestions: Discover common join patterns between related tables
- Browse by Category: Explore tables organized by function (57 categories)
- GitHub Examples Fallback: Search GitHub for examples when tables aren't in schema index
Performance & Management
- Smart Caching: LRU cache reduces API calls and improves performance
- Rate Limit Management: Built-in GitHub API rate limit tracking and warnings
Installation
Prerequisites
- A GitHub Classic Personal Access Token with
public_reposcope - An MCP-compatible client (see supported clients below)
Supported MCP Clients
This server works with any MCP-compatible client, including:
- Claude Desktop - Anthropic's official desktop app
- ChatGPT - OpenAI's ChatGPT with MCP support (Pro, Plus, Team, Business, Enterprise, Education accounts)
- GitHub Copilot - VS Code, JetBrains, Eclipse, and Xcode (requires GitHub Copilot subscription)
- Google Gemini CLI - Google's open-source AI agent with native MCP support
- Zed Editor - High-performance code editor with built-in MCP support
- Cody - Sourcegraph's AI coding assistant
- Replit - Cloud-based development environment
Setup for Claude Desktop
No installation required! Use npx to run the package
directly from NPM.
Configure Claude Desktop:
Edit your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add the following configuration:
{
"mcpServers": {
"kql-search": {
"command": "npx",
"args": ["-y", "kql-search-mcp"],
"env": {
"GITHUB_TOKEN": "your_github_token_here",
"FAVORITE_REPOS":
"Azure/Azure-Sentinel,microsoft/Microsoft-365-Defender-Hunting-Queries"
}
}
}
}Optional: Add
FAVORITE_REPOSto quickly search your most-used repositories (comma-separated list of owner/repo)
Get a GitHub Token:
- Go to https://github.com/settings/tokens/new
- Give it a descriptive name: "KQL MCP Server"
- Under "Select scopes", check
public_repo - Click "Generate token" and copy it immediately
- Replace
your_github_token_herewith your token
Restart Claude Desktop and you're ready to go!
Note: The
-yflag tells npx to automatically use the package without prompting. This ensures the MCP server starts correctly.
Setup for ChatGPT
Requirements: ChatGPT Pro, Plus, Team, Business, Enterprise, or Education account
- Open ChatGPT and go to Settings
- Navigate to Connectors → Advanced → Developer Mode
- Add a new MCP server with:
- Name: KQL Search
- Command:
npx - Args:
-y kql-search-mcp - Environment Variables:
GITHUB_TOKEN: your_github_token_hereFAVORITE_REPOS: Azure/Azure-Sentinel,microsoft/Microsoft-365-Defender- Hunting-Queries (optional)
Note: MCP support in ChatGPT is available via Developer Mode and requires a paid subscription.
Setup for VS Code Extension (GitHub Copilot)
Requirements: VS Code 1.107+ with GitHub Copilot (any model)
⚠️ IMPORTANT: The VS Code extension does NOT require Node.js or npx. It comes bundled with the MCP server.
Installation:
Install the extension from VS Code Marketplace:
- Search for "KQL Search MCP" in the Extensions panel
- Or install directly:
kql-search-mcp
Set your GitHub token using Command Palette:
KQL Search MCP: Set GitHub Token(Optional) Configure favorite repositories:
KQL Search MCP: Set Favorite Repositories
Works with any GitHub Copilot model, including:
- Claude Opus 4.5 Preview
- GPT-4o
- o1-preview
- o1-mini
- Any other GitHub Copilot supported model
Verification:
- Run
KQL Search MCP: Check Extension Statusfrom Command Palette - The extension should show as active with your token set
Setup for GitHub Copilot (MCP Configuration File)
Requirements: GitHub Copilot subscription and VS Code 1.102+
⚠️ NOTE: This is an alternative setup using .vscode/mcp.json configuration. The VS Code extension above is easier and doesn't require npx.
- Ensure MCP support is enabled in your organization (Enterprise/Team admins must enable the "MCP servers in Copilot" policy)
- Create or edit
.vscode/mcp.jsonin your project root:
{
"inputs": [
{
"type": "promptString",
"id": "github-token",
"description": "GitHub Personal Access Token",
"password": true
}
],
"servers": {
"kql-search": {
"command": "npx",
"args": ["-y", "kql-search-mcp"],
"env": {
"GITHUB_TOKEN": "${input:github-token}",
"FAVORITE_REPOS":
"Azure/Azure-Sentinel,microsoft/Microsoft-365-Defender-Hunting-Queries"
}
}
}
}- VS Code will prompt you for your GitHub token when the server starts
- Click "Start" in the MCP configuration file to initialize the server
Note: For JetBrains, Eclipse, or Xcode, consult the GitHub Copilot MCP documentation.
Setup for Google Gemini CLI
Requirements: Gemini CLI installed
Install Gemini CLI:
npm install -g @google/gemini-cliConfigure the MCP server:
export GITHUB_TOKEN="your_github_token_here" export FAVORITE_REPOS="Azure/Azure-Sentinel,microsoft/Microsoft-365-Defender-Hunting-Queries" gemini-cli --mcp-server "npx -y kql-search-mcp"
Note: Gemini CLI has native MCP support and can connect to any MCP server using the
--mcp-serverflag.
Setup for Other MCP Clients
For Zed, Cody, Replit, or other MCP-compatible clients, refer to their specific MCP configuration documentation. The general configuration pattern is:
- Command:
npx - Args:
-y kql-search-mcp - Environment Variables:
GITHUB_TOKEN: your GitHub personal access tokenFAVORITE_REPOS: comma-separated list of repositories (optional)
Enhanced Documentation with Microsoft Docs MCP (Recommended)
For the best experience generating and validating KQL queries, we strongly recommend installing the Microsoft Docs MCP server alongside this KQL MCP server.
Recommended Configuration
✅ KQL-Search-MCP: Install via NPX (no installation needed, runs directly from npm) ✅ Microsoft Docs MCP: Install via Docker MCP Gateway (requires Docker Desktop)
This combination gives you:
- 100% validated KQL queries with our schema intelligence
- Real-time access to official Microsoft Learn documentation
- Best of both worlds: local schema validation + cloud-hosted docs
What is Microsoft Docs MCP?
The Microsoft Docs MCP is an official , open-source, cloud-hosted service from Microsoft that provides real-time access to Microsoft Learn documentation through the Model Context Protocol.
Benefits of Using Both Servers Together
| Feature | KQL MCP Server (This Server) | Microsoft Docs MCP | Combined | |---------|------------------------------|-------------------|----------| | Query Generation | ✅ 100% validated against 331+ table schemas | ❌ No schema knowledge | ✅ Validated queries + official docs | | Schema Information | ✅ Structured table/column data | ❌ No structured schemas | ✅ Best of both | | Latest Documentation | ✅ Automated weekly schema checks | ✅ Always current from MS Learn | ✅ Verified with latest docs | | Query Examples | ✅ GitHub search across all repos | ✅ Official Microsoft examples | ✅ Maximum coverage | | Operator Documentation | ✅ Documentation links | ✅ Full operator details | ✅ Complete reference |
How to Install Microsoft Docs MCP
The Microsoft Docs MCP is a cloud-hosted service that requires Docker MCP Gateway to access. Add it to your existing configuration:
Prerequisites:
- Docker Desktop installed and running
- MCP Gateway (included with Docker Desktop)
For Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"kql-search": {
"command": "npx",
"args": ["-y", "kql-search-mcp"],
"env": {
"GITHUB_TOKEN": "your_github_token_here",
"FAVORITE_REPOS": "Azure/Azure-Sentinel,microsoft/Microsoft-365-Defender-Hunting-Queries"
}
},
"MCP_DOCKER": {
"command": "docker",
"args": ["mcp", "gateway", "run"]
}
}
}For GitHub Copilot (.vscode/mcp.json):
{
"inputs": [
{
"type": "promptString",
"id": "github-token",
"description": "GitHub Personal Access Token",
"password": true
}
],
"servers": {
"kql-search": {
"command": "npx",
"args": ["-y", "kql-search-mcp"],
"env": {
"GITHUB_TOKEN": "${input:github-token}",
"FAVORITE_REPOS": "Azure/Azure-Sentinel,microsoft/Microsoft-365-Defender-Hunting-Queries"
}
},
"MCP_DOCKER": {
"command": "docker",
"args": ["mcp", "gateway", "run"]
}
}
}Microsoft Docs MCP Tools
When installed, you'll have access to these additional tools:
microsoft_docs_search- Semantic search across Microsoft Learn documentationmicrosoft_docs_fetch- Retrieve specific documentation pages in markdown formatmicrosoft_code_sample_search- Find official Microsoft/Azure code samples
How They Work Together
User: "Generate a query for risky sign-ins"
↓
KQL MCP: Generates validated query using IdentityProtection schema
↓
Microsoft Docs MCP: Provides latest Identity Protection documentation
↓
Result: Validated query + official documentation + best practicesCheck Installation Status
Use the check_microsoft_docs_mcp tool to get detailed installation
instructions and verify your setup.
More Information
- Repository: https://github.com/MicrosoftDocs/mcp
- Microsoft MCP Catalog: https://github.com/microsoft/mcp
- No API Key Required: Free and maintained by Microsoft
- Cloud-Hosted: No local installation needed
Usage
Once configured, the KQL MCP server provides 34 tools in your MCP client:
ASIM Schema Tools (13 tools)
Work with ASIM (Advanced Security Information Model) schemas for normalized security events:
- search_asim_schemas - Search for ASIM schemas by keyword
- get_asim_schema_info - Get detailed information about a specific ASIM schema
- get_asim_field_info - Get information about a specific ASIM field
- generate_asim_query_template - Generate KQL query templates for ASIM schemas
- get_asim_parser_recommendations - Get parser naming conventions and best practices
- list_asim_schemas - List all available ASIM schemas
- search_asim_fields - Search for fields across ASIM schemas
- validate_asim_parser - Validate parser implementation against schema requirements
- get_asim_parser_requirements - Get mandatory and recommended fields for a schema
- compare_parser_to_schema - Compare parser fields against schema requirements
- get_asim_logical_types - Get ASIM logical types reference
- get_asim_schema_relationships - Get relationships between ASIM schemas
- list_available_asim_schemas - List all ASIM schemas for validation
ASIM Schema Tools Details
1. Search ASIM Schemas (search_asim_schemas)
Search for ASIM (Advanced Security Information Model) schemas by keyword:
Examples:
Find ASIM schemas for authenticationSearch for network ASIM schemaShow me file activity ASIM schemaFind DNS event schemaParameters:
query(required): Keyword to search (e.g., "authentication", "network", "file", "process", "dns")
Returns:
- Schema names and versions
- Status (GA, Preview)
- Descriptions and key fields
- List of entities in each schema
2. Get ASIM Schema Info (get_asim_schema_info)
Get comprehensive information about a specific ASIM schema:
Examples:
Get information about the authentication event schemaShow me details for network session schemaWhat fields are in the alert event schema?Get schema information for DNS activityParameters:
schemaName(required): ASIM schema name (e.g., "authentication_event", "network_session")
Returns:
- All fields in the schema with classifications
- Field types and logical types
- Entity information
- Key fields required for the schema
- Field relationships and dependencies
- Common use cases
3. Get ASIM Field Info (get_asim_field_info)
Get detailed information about a specific ASIM field:
Examples:
Get information about the EventStartTime fieldShow me details for the UserName fieldWhat is the EventResult field used for?Get details on the SourceIPAddress fieldParameters:
fieldName(required): ASIM field name (e.g., "EventStartTime", "UserName", "EventResult")
Returns:
- Field type and logical type
- Field class (Mandatory, Recommended, Optional)
- Description and purpose
- Example values
- Allowed values (where applicable)
- Related fields in other schemas
4. Generate ASIM Query Template (generate_asim_query_template)
Generate a ready-to-use KQL query template for an ASIM schema:
Examples:
Generate a query template for the authentication event schemaCreate a template for network session queriesGenerate a query starting point for file activityGive me a template for DNS activity queriesParameters:
schemaName(required): ASIM schema name
Returns:
- Complete KQL query template
- Standard filter examples
- Common field selections
- Best practices for the schema
- Query explanation
5. Get ASIM Parser Recommendations (get_asim_parser_recommendations)
Get naming conventions and best practices for creating ASIM parsers:
Examples:
Get parser recommendations for authentication eventsShow me naming conventions for network session parsersWhat are the best practices for creating ASIM parsers?Get recommendations for DNS activity parsersParameters:
schemaName(required): ASIM schema name
Returns:
- Unifying parser naming conventions
- Source-specific parser naming patterns
- Parser recommendations
- Query template examples
- Documentation links
6. List ASIM Schemas (list_asim_schemas)
List all available ASIM schemas with versions and status:
Examples:
List all available ASIM schemasShow me all ASIM schemasWhat ASIM schemas are available?List ASIM schema catalogReturns:
- All 11 ASIM schemas with current versions
- Status for each schema (GA, Preview)
- Schema descriptions
- Key entities and fields
- Supported data sources
7. Search ASIM Fields (search_asim_fields)
Search for fields across all ASIM schemas:
Examples:
Find all ASIM fields related to user accountsSearch for timestamp fields in ASIMFind fields related to IP addressesSearch for process-related fieldsParameters:
query(required): Search term for fields
Returns:
- Matching fields across all schemas
- Field names and types
- Schemas containing each field
- Field descriptions
- Usage examples
8. Validate ASIM Parser (validate_asim_parser)
Validate an ASIM parser implementation against schema requirements:
Examples:
Validate parser with fields: EventStartTime, EventEndTime, EventType, EventResult for authentication_event schemaCheck if my parser has all mandatory fields for network_sessionParameters:
schemaName(required): ASIM schema name (e.g., "authentication_event", "network_session")parserName(required): Name of the parser being validatedparserFields(required): List of field names provided by the parser
Returns:
- Validation status (passed/issues found)
- Missing mandatory fields (if any)
- Missing recommended fields (if any)
- Extra/unrecognized fields (if any)
- Coverage summary
9. Get ASIM Parser Requirements (get_asim_parser_requirements)
Get mandatory and recommended fields required for an ASIM parser:
Examples:
What fields are required for an authentication event parser?Show me mandatory and recommended fields for network sessionParameters:
schemaName(required): ASIM schema name
Returns:
- List of all mandatory fields with descriptions
- List of all recommended fields with descriptions
- Total field count for the schema
10. Compare Parser to Schema (compare_parser_to_schema)
Compare parser fields against schema requirements and identify gaps:
Examples:
Compare my parser fields against the authentication_event schemaShow field coverage for my network session parserParameters:
schemaName(required): ASIM schema nameparserFields(required): List of fields in the parser
Returns:
- Field coverage percentage
- Matched and unmatched fields
- Fields missing from parser (organized by requirement level)
- Detailed gap analysis
11. Get ASIM Logical Types (get_asim_logical_types)
Get reference information about ASIM logical types:
Examples:
What are the ASIM logical types?Show me logical type definitions and examplesReturns:
- All logical types used in ASIM
- Description for each type
- Examples for each logical type
- Formatting requirements
12. Get ASIM Schema Relationships (get_asim_schema_relationships)
Get relationships between ASIM schemas:
Examples:
What schemas are related to authentication events?Show me how network session relates to other schemasParameters:
schemaName(required): ASIM schema name
Returns:
- Related schemas
- Relationship descriptions
- Cross-schema field mappings
13. List Available ASIM Schemas (list_available_asim_schemas)
List all available ASIM schemas for validation and normalization:
Examples:
List all ASIM schemas available for validationShow me all ASIM schemas with field countsReturns:
- Complete list of all ASIM schemas
- Schema versions and status
- Description for each schema
- Field count for each schema
Search for KQL queries across GitHub repositories:
- search_kql_queries - Search all of GitHub for KQL queries using natural language
- get_kql_from_file - Extract queries from a specific file
- search_kql_repositories - Find repositories containing KQL queries
- get_rate_limit - View GitHub API rate limit status
- search_repo_kql_queries - Search within a specific repository
- search_user_kql_queries - Search all repos from a user/org
- search_favorite_repos - Search your configured favorite repos
- get_cache_stats - View cache performance and stats
1. Search KQL Queries (search_kql_queries)
Search all of GitHub for KQL queries using natural language:
Examples:
Find KQL queries for detecting failed login attemptsShow me Microsoft Sentinel queries for threat huntingGet queries for monitoring Entra ID sign-insSearch for queries that detect lateral movement in Active DirectoryFind PowerShell execution detection queriesParameters:
query(required): Natural language description of what you're looking formax_results(optional): Maximum number of queries to return (default: 5, max: 50)include_context(optional): Include surrounding documentation (default: true)sort_by(optional): Sort by 'relevance', 'stars', or 'updated' (default: relevance)
Returns:
- KQL queries with syntax highlighting
- Repository and file information
- Descriptions and context
- Relevance scores
- Source code links
2. Get KQL from File (get_kql_from_file)
Extract all KQL queries from a specific file:
Examples:
Get KQL queries from Azure/Azure-Sentinel file Solutions/Azure%20Activity/Hunting%20Queries/Granting_Permissions_to_Account.yamlExtract queries from microsoft/Microsoft-365-Defender-Hunting-Queries file Persistence/scheduled%20task%20creation.txtShow me the queries in reprise99/Sentinel-Queries file Azure%20Active%20Directory/Identity-RiskySigninFollowedbyAdminMFAChange.kqlGet queries from Azure/Azure-Sentinel file Detections/SigninLogs/PrivilegedAccountsSignInFailureSpikes.yamlExtract KQL from microsoft/Microsoft-365-Defender-Hunting-Queries file Exfiltration/EmailAccessViaActiveSync.txtParameters:
owner(required): Repository owner (username or organization)repo(required): Repository namepath(required): File path within the repositoryinclude_context(optional): Include surrounding documentation (default: true)
Returns:
- All KQL queries extracted from the file
- Query descriptions and comments
- Context from surrounding code
- File metadata
3. Search KQL Repositories (search_kql_repositories)
Find GitHub repositories that contain KQL queries:
Examples:
Search for repositories with Microsoft Sentinel detection rulesFind repositories containing Microsoft Defender hunting queriesShow me repos with Kubernetes monitoring KQL queriesFind repositories with threat hunting KQL examplesSearch for Azure Monitor log analytics query collectionsParameters:
query(required): Search terms to find relevant repositories
Returns:
- Repository names and descriptions
- Star counts and activity metrics
- Repository URLs
- Primary programming languages
4. Check Rate Limit (get_rate_limit)
View current GitHub API rate limit status:
Examples:
Check GitHub API rate limit statusHow many API requests do I have remaining?Show rate limit infoWhat's my current rate limit?Check API quota remainingReturns:
- Current rate limit (requests per hour)
- Remaining requests
- Reset time
- Used requests count
5. Search Specific Repository (search_repo_kql_queries)
Search for KQL queries within a specific GitHub repository:
Examples:
Find authentication queries in Azure/Azure-SentinelSearch for network monitoring in microsoft/Microsoft-365-Defender-Hunting-QueriesGet queries for failed login attempts in Azure/Azure-SentinelFind email phishing detection in microsoft/Microsoft-365-Defender-Hunting-QueriesSearch reprise99/Sentinel-Queries for brute force queriesFind ransomware detection in Azure/Azure-SentinelParameters:
owner(required): Repository owner (e.g., "Azure", "microsoft")repo(required): Repository name (e.g., "Azure-Sentinel")query(required): Natural language descriptionmax_results(optional): Maximum results (default: 5, max: 50)include_context(optional): Include documentation (default: true)
Returns:
- KQL queries from the specified repository
- File paths and locations
- Query descriptions
- Relevance scores
6. Search User/Organization Repositories (search_user_kql_queries)
Search all repositories owned by a specific GitHub user or organization:
Examples:
Find all threat hunting queries from microsoftSearch Azure organization for detection rulesGet all KQL queries from reprise99's repositoriesFind DNS queries across all Azure repositoriesSearch microsoft for PowerShell hunting queriesFind all malware detection queries from AzureParameters:
user(required): GitHub username or org (e.g., "microsoft", "Azure")query(required): Natural language descriptionmax_results(optional): Maximum results (default: 5, max: 50)include_context(optional): Include documentation (default: true)sort_by(optional): Sort by 'relevance', 'stars', or 'updated'
Returns:
- KQL queries from all user/org repositories
- Repository names for each query
- File locations
- Context and descriptions
7. Search Favorite Repositories (search_favorite_repos)
Search only your configured favorite repositories:
Examples:
Find failed login queries in my favorite reposSearch my favorites for lateral movement detectionGet phishing email queries from favorite repositoriesFind all process execution queries in favoritesSearch favorites for suspicious registry modificationsParameters:
query(required): Natural language descriptionmax_results(optional): Maximum results (default: 5, max: 50)include_context(optional): Include documentation (default: true)
Configuration: Set FAVORITE_REPOS environment variable in your MCP config
(see Installation section above)
Returns:
- KQL queries from your favorite repositories
- Repository names
- File paths
- Query context
8. Get Cache Statistics (get_cache_stats)
View cache performance and optionally clear cached results:
Examples:
Show me cache statisticsWhat's my cache hit rate?Get cache statsClear the query cacheShow cache stats and clear itHow many cached queries do I have?Parameters:
clear_cache(optional): Clear the cache after showing stats (default: false)
Returns:
- Search cache size
- File cache size
- Cache hit rates
- TTL information
Cache Benefits:
- Reduces GitHub API calls for repeated searches
- 30-minute TTL for search results
- 60-minute TTL for file contents
- Automatic LRU eviction for optimal memory usage
Schema Intelligence Tools (8 tools)
Discover and work with KQL table schemas, plus generate and validate queries:
- get_table_schema - Get comprehensive schema information for a specific table
- search_tables - Search for tables using natural language
- list_table_categories - Browse all available table categories
- get_tables_by_category - Get all tables in a specific category
- generate_query_template - Generate a ready-to-use KQL query template
- generate_query_from_natural_language - Create complete queries from descriptions
- find_column - Find which tables contain a specific column
- get_schema_statistics - View schema index statistics and coverage
1. Get Table Schema (get_table_schema)
Get comprehensive schema information for a specific KQL table:
Examples:
Get schema for SigninLogs tableShow me the DeviceProcessEvents table schemaWhat columns are in the SecurityAlert table?Give me schema details for ASimFileEventLogsShow me the EmailEvents table structureParameters:
table_name(required): Name of the KQL table (e.g., "SigninLogs", "DeviceProcessEvents")
Returns:
- Complete schema including all columns with data types
- Column descriptions and common column indicators
- Join suggestions for related tables
- Example queries
Supported Tables: 331+ tables from Microsoft Defender XDR, Microsoft Sentinel , and Azure Monitor Logs.
2. Search Tables (search_tables)
Search for KQL tables using natural language:
Examples:
Find tables for authentication eventsShow me email security tablesSearch for tables with vulnerability dataWhich tables contain file activity information?Find tables related to network traffic monitoringParameters:
query(required): Natural language description of the type of table you needmax_results(optional): Maximum number of tables to return (default: 10)
Returns:
- Ranked list of tables with relevance scores
- Table descriptions
- Common columns for each table
3. List Table Categories (list_table_categories)
Browse all available table categories:
Examples:
List all table categoriesShow me available KQL table categoriesWhat categories of tables are available?Browse all table typesShow me how tables are organizedReturns:
- Complete list of 57 categories
- Categories include Authentication & Identity, Security & Threats , Email & Collaboration, Network Activity, and more
4. Get Tables by Category (get_tables_by_category)
Get all tables in a specific category:
Examples:
Show me all Authentication & Identity tablesList tables in the Security & Threats categoryGet all Email & Collaboration tablesShow me tables in the Network Activity categoryList all Device & Endpoint tablesParameters:
category(required): Category name (uselist_table_categoriesto see available categories)
Returns:
- All tables in the specified category
- Table descriptions
- Common columns for each table
5. Generate Query Template (generate_query_template)
Generate a ready-to-use KQL query template for a specific table:
Examples:
Generate a query template for SigninLogsCreate a template query for DeviceProcessEventsGive me a starting query for SecurityAlert tableBuild a basic query for EmailEventsGenerate template for ASimFileEventLogsParameters:
table_name(required): Name of the KQL tableinclude_comments(optional): Include explanatory comments (default: true)
Returns:
- Ready-to-use KQL query template
- Common filters and time ranges
- Standard column selections
- Optional explanatory comments
6. Generate Query from Natural Language (generate_query_from_natural_language)
Create a complete KQL query from a natural language description:
Examples:
Show me failed sign-ins in the last 24 hoursCount high severity security alerts by typeFind malicious process executions on Windows devicesGet all email phishing attempts from the last weekShow me suspicious PowerShell commands run in the last hourParameters:
query(required): Natural language description of what data you want to query
Returns:
- Complete KQL query automatically generated
- Appropriate table selection based on description
- Relevant filters and conditions
- Aggregations when appropriate
7. Find Column (find_column)
Find which tables contain a specific column:
Examples:
Which tables have the AccountName column?Find tables containing IPAddressWhere can I find the TimeGenerated column?Show me tables with the FileName columnWhich tables contain ThreatName?Parameters:
column_name(required): Name of the column to search for
Returns:
- List of all tables containing the specified column
- Column details for each table
- Data types
8. Get Schema Statistics (get_schema_statistics)
View statistics about the schema index:
Examples:
Show schema statisticsHow many tables are in the schema index?Get schema coverage informationShow me schema index statsWhat's the coverage of the schema database?Returns:
- Total number of tables
- Number of categories
- Coverage by product (Defender XDR, Sentinel, Azure Monitor)
- Additional statistics
Query Generation & Validation Tools (5 tools)
Generate and validate KQL queries with 100% schema verification:
- generate_kql_query - Generate validated KQL queries from natural language
- validate_kql_query - Validate existing queries for correctness
- get_query_documentation - Get Microsoft Learn documentation for queries/tables
- check_microsoft_docs_mcp - Get Microsoft Docs MCP installation guide
- search_github_examples_fallback - Search GitHub when table not in schema
1. Generate KQL Query (generate_kql_query)
Generate a fully validated KQL query from natural language description. All table names, column names, and data types are verified against the 331+ table schema index.
Examples:
Generate a KQL query to show failed sign-ins from the last 24 hoursCreate a query to find devices with high severity alertsGenerate a query for email events with malicious attachments in the last 7 daysShow me risky sign-ins for admin accountsCreate a query to detect PowerShell execution on devicesParameters:
description(required): Natural language description of what you want to querytable_name(optional): Specific table name if known (e.g., "SigninLogs")time_range(optional): Time range filter (e.g., "24h", "7d", "30d")columns(optional): Specific columns to include in resultsfilters(optional): Additional filters as key-value pairslimit(optional): Maximum number of results (default: 100)include_aggregations(optional): Include summarization/aggregations
Returns:
- Validated KQL query
- Validation results (errors/warnings)
- Microsoft Learn documentation links
- Query explanation
- Table schema information
2. Validate KQL Query (validate_kql_query)
Validate an existing KQL query for syntax correctness, table validity, column validity, and common mistakes before execution.
Examples:
Validate this query: SigninLogs | where TimeGenerated > ago(24h) | project UserPrincipalName, IPAddressCheck if this KQL query is correct: DeviceProcessEvents | where ProcessCommandLine contains "powershell"Validate: EmailEvents | where ThreatTypes has "malware" | top 100 by TimestampParameters:
query(required): The KQL query to validate
Returns:
- Validation status (passed/failed)
- List of errors (if any)
- List of warnings (if any)
- Suggestions for fixes
3. Get Query Documentation (get_query_documentation)
Get Microsoft Learn documentation links for a KQL query or table, including operator documentation and reference guides.
Examples:
Get documentation for SigninLogs tableShow me documentation for this query: DeviceEvents | where ActionType == "ProcessCreated"Get Microsoft Learn docs for DeviceProcessEventsParameters:
query(optional): KQL query to get documentation fortable_name(optional): Table name to get documentation for
Returns:
- Table reference documentation link
- Operator documentation links
- General KQL reference
- Source system documentation
4. Check Microsoft Docs MCP (check_microsoft_docs_mcp)
Get information about the Microsoft Docs MCP server and how to install it for enhanced documentation access.
Examples:
How do I install Microsoft Docs MCP?Tell me about Microsoft Docs MCP integrationWhat is Microsoft Docs MCP?Returns:
- What Microsoft Docs MCP is
- Benefits of using it
- Installation instructions
- Configuration examples
- Links to documentation
5. Search GitHub Examples Fallback (search_github_examples_fallback)
Search GitHub for query examples when a table is not in the schema index. Returns unvalidated examples from public repositories.
Examples:
Find GitHub examples for CustomTable that's not in the schemaSearch for queries using InternalSecurityEvents tableParameters:
table_name(required): Name of the table to search examples fordescription(optional): Additional context for filtering examples
Returns:
- GitHub repository examples
- Warning that examples are unvalidated
- Recommendation to use Microsoft Docs MCP
- Query snippets and context
How It Works
Architecture
┌─────────────────┐
│ Claude Desktop │
│ (MCP Client) │
└────────┬────────┘
│ MCP Protocol
│
┌────────▼────────┐
│ KQL MCP Server │
│ │
│ ┌─────────────┐ │
│ │Natural Lang │ │
│ │ Parser │ │
│ └──────┬──────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │ GitHub │ │
│ │ Client │ │
│ └──────┬──────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │KQL Parser & │ │
│ │ Ranker │ │
│ └─────────────┘ │
└─────────────────┘
│
│ GitHub API
│
┌────────▼────────┐
│ GitHub │
│ (All Repos) │
└─────────────────┘Search Process
- Natural Language Processing: Your plain English query is analyzed to extract relevant keywords
- Query Enhancement: Keywords are combined with KQL-specific terms for optimal GitHub search
- GitHub Code Search: Searches across all public repositories for relevant KQL files
- Content Extraction: Fetches file contents from matching repositories
- KQL Parsing: Intelligently extracts individual KQL queries from files
- Context Gathering: Collects surrounding comments, documentation , and usage examples
- Relevance Ranking: Scores queries based on multiple factors:
- Repository popularity (stars)
- Query complexity and completeness
- Documentation quality
- Search term relevance
- Results Presentation: Returns formatted, ready-to-use queries with full context
File Extensions Searched
The server automatically searches for these file extensions:
.kql- Standard KQL query files (modern format, most common).kusto- Kusto query files (alternative format).csl- CSL query files (legacy Kusto format, less common).yaml/.yml- YAML files with embedded KQL (Microsoft Sentinel detection rules).txt- Text files containing KQL queries (Microsoft 365 Defender hunting queries).md- Markdown files with KQL query examples and documentation
Rate Limits
GitHub API has the following rate limits:
- Authenticated requests: 5,000 requests per hour
- Code search: 30 requests per minute
The server automatically tracks and warns about rate limit usage. Use the
get_rate_limit tool to check your current status.
Troubleshooting
"GITHUB_TOKEN environment variable is required"
Ensure your GitHub token is properly configured in Claude Desktop's config file with the correct environment variable name.
"GitHub API rate limit nearly exceeded"
You're approaching the API limit. Wait for the reset time shown in the error
message, or use the get_rate_limit tool to check status.
"No KQL queries found"
Try:
- Using different or broader search terms
- Checking for typos
- Searching for specific table names or data sources
- Using the
search_kql_repositoriestool to find relevant repositories first
"The command 'npx' needed to run KQL Search was not found" in VS Code
This error means you're trying to use the npx-based setup instead of the VS Code extension.
Solution: Install the KQL Search MCP extension from the VS Code Marketplace:
- Open Extensions panel in VS Code (Ctrl+Shift+X / Cmd+Shift+X)
- Search for "KQL Search MCP"
- Click Install
- Run "KQL Search MCP: Set GitHub Token" from Command Palette
The VS Code extension does NOT require Node.js, npm, or npx - it comes fully bundled!
If you prefer using npx: Install Node.js from nodejs.org, then configure using .vscode/mcp.json as shown in the "Setup for GitHub Copilot (MCP Configuration File)" section above.
Server not appearing in Claude Desktop
- Fully restart Claude Desktop (quit completely and reopen)
- Verify the config file path is correct:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
- Check that your
GITHUB_TOKENis valid and haspublic_reposcope - Ensure you have an active internet connection (npx needs to download the package)
- Check Claude Desktop logs for errors:
- macOS:
~/Library/Logs/Claude/mcp*.log - Windows:
%APPDATA%\Claude\logs\mcp*.log
- macOS:
Security
- Never commit your GitHub token to the repository
- The token is stored only in Claude Desktop's configuration
- Use tokens with minimal required scopes (
public_repoonly) - Rotate tokens regularly
License
MIT License - see LICENSE file for details
Related Projects
- Model Context Protocol - Official MCP documentation
- ugurkocde/KQL-Search - Inspiration for this project
- Microsoft Sentinel KQL Queries - Microsoft's official KQL query repository
Acknowledgments
Inspired by kqlsearch.com by Ugur Koc. This project brings KQL query search to the Model Context Protocol with natural language support and GitHub integration.
