Skip to content
Back to search

security-investigator

Automated security investigation tool using Microsoft MCP Servers, GitHub Copilot, Python Modules and custom copilot-instructions.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/scstelz--security-investigator/badge.svg)](/listings/scstelz--security-investigator)

HTML

<a href="/listings/scstelz--security-investigator"><img src="/api/listings/scstelz--security-investigator/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

# 1. Clone and open in VS Code
git clone https://github.com/SCStelz/security-investigator.git
code security-investigator

# 2. Set up Python environment
python -m venv .venv
.venv\Scripts\Activate.ps1          # Windows
# source .venv/bin/activate          # macOS/Linux
pip install --require-hashes -r requirements.lock   # Hash-verified (recommended)
# pip install -r requirements.txt                   # Without hash verification

# 3. Configure environment
copy config.json.template config.json
# Edit config.json → add your Sentinel workspace ID, tenant ID
copy .env.template .env
# Edit .env → add your API tokens (ipinfo, AbuseIPDB, vpnapi, Shodan)

# 4. Configure MCP servers
copy .vscode\mcp.json.template .vscode\mcp.json
# All platform servers are pre-configured — just needs a GitHub PAT on first use
# GitHub Copilot app / CLI instead? Use the user-scope template:
#   copy .copilot\mcp-config.json.template $env:USERPROFILE\.copilot\mcp-config.json
#   (works as-is — see "Running in the GitHub Copilot App" below)

# 5. Open Copilot Chat (Ctrl+Shift+I) in Agent mode and start with:
#    "Run a threat pulse scan"

**🚀 Recommended first run:** The **Threat Pulse** skill is the best starting point. It runs a broad-spectrum scan across 9 security domains (incidents, identity, endpoint, exposure, email, UEBA, auth spray, privileged ops, CVEs) and produces prioritized findings with color-coded verdicts (🔴 Escalate / 🟠 Investigate / 🟡 Monitor / ✅ Clear). Each finding includes a drill-down recommendation pointing to a specialized skill — so after the scan, you'll know exactly where to focus and which follow-up command to run.

**Other example prompts:**

"Investigate user@domain.com for the last 7 days"    → user-investigation
"Analyze incident 12345"                              → incident-investigation
"Is this IP malicious? 203.0.113.42"                  → ioc-investigation
"What skills do you have access to?"                  → lists all 25 skills

**For detailed workflows and KQL queries:** → [.github/copilot-instructions.md](.github/copilot-instructions.md) (universal patterns, skill detection) → [.github/skills/](.github/skills/) (25 specialized investigation workflows) → [queries/](queries/) (verified KQL query library)

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 821 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # 🔒 Security Investigation Automation System
  2. **Comprehensive, automated security investigations powered by Microsoft Sentinel, Defender XDR, Graph API, and threat intelligence — with 25 specialized Agent Skills**
  3. > 🎛️ **Walkthrough using GitHub Copilot (15 min):** See the new Mission Control canvas app in action — [Watch on LinkedIn](https://lnkd.in/p/gm4yB-9Y). A guided tour of the launchable skills dashboard: filter investigation skills by domain, search, and one-click launch skills or route an entity to the right investigation.
  4. > 📺 **Walkthrough using VS Code:** See this project in action — [Watch on YouTube](https://youtu.be/3UFqWA4cmoE?t=1470) (starts at the Security Investigator demo). Covers the end-to-end workflow: natural language investigations, MCP server integration, KQL query execution, threat intelligence enrichment, and automated report generation.
  5. An investigation automation framework that combines **GitHub Copilot**, **VS Code Agent Skills**, and **Model Context Protocol (MCP) servers** to enable natural language security investigations. Ask questions like *"Investigate this user for the last 7 days"* or *"Is this IP malicious?"* and get comprehensive analysis with KQL queries, threat intelligence correlation, and professional reports.
  6. > 🖥️ **Also runs in the [GitHub Copilot app](https://github.com/features/ai/github-app) (desktop)** — ideal for **scheduled automations** (unattended Threat Pulse / Threat Intel Campaign runs). It uses a worktree-per-session model with a few setup differences from VS Code — see [Running in the GitHub Copilot App](#️-running-in-the-github-copilot-app-desktop).
  7. ### Quick Start (TL;DR)
  8. ```powershell
  9. # 1. Clone and open in VS Code
  10. git clone https://github.com/SCStelz/security-investigator.git
  11. code security-investigator
  12. # 2. Set up Python environment
  13. python -m venv .venv
  14. .venv\Scripts\Activate.ps1 # Windows
  15. # source .venv/bin/activate # macOS/Linux
  16. pip install --require-hashes -r requirements.lock # Hash-verified (recommended)
  17. # pip install -r requirements.txt # Without hash verification
  18. # 3. Configure environment
  19. copy config.json.template config.json
  20. # Edit config.json → add your Sentinel workspace ID, tenant ID
  21. copy .env.template .env
  22. # Edit .env → add your API tokens (ipinfo, AbuseIPDB, vpnapi, Shodan)
  23. # 4. Configure MCP servers
  24. copy .vscode\mcp.json.template .vscode\mcp.json
  25. # All platform servers are pre-configured — just needs a GitHub PAT on first use
  26. # GitHub Copilot app / CLI instead? Use the user-scope template:
  27. # copy .copilot\mcp-config.json.template $env:USERPROFILE\.copilot\mcp-config.json
  28. # (works as-is — see "Running in the GitHub Copilot App" below)
  29. # 5. Open Copilot Chat (Ctrl+Shift+I) in Agent mode and start with:
  30. # "Run a threat pulse scan"
  31. ```
  32. **🚀 Recommended first run:** The **Threat Pulse** skill is the best starting point. It runs a broad-spectrum scan across 9 security domains (incidents, identity, endpoint, exposure, email, UEBA, auth spray, privileged ops, CVEs) and produces prioritized findings with color-coded verdicts (🔴 Escalate / 🟠 Investigate / 🟡 Monitor / ✅ Clear). Each finding includes a drill-down recommendation pointing to a specialized skill — so after the scan, you'll know exactly where to focus and which follow-up command to run.
  33. **Other example prompts:**
  34. ```
  35. "Investigate user@domain.com for the last 7 days" → user-investigation
  36. "Analyze incident 12345" → incident-investigation
  37. "Is this IP malicious? 203.0.113.42" → ioc-investigation
  38. "What skills do you have access to?" → lists all 25 skills
  39. ```
  40. **For detailed workflows and KQL queries:**
  41. → [.github/copilot-instructions.md](.github/copilot-instructions.md) (universal patterns, skill detection)
  42. → [.github/skills/](.github/skills/) (25 specialized investigation workflows)
  43. → [queries/](queries/) (verified KQL query library)
  44. ---
  45. ## Architecture Overview
  46. ```
  47. ┌────────────────────────────────────────────────────────────────────┐
  48. │ GitHub Copilot (VS Code) │
  49. ├────────────────────────────────────────────────────────────────────┤
  50. │ .github/copilot-instructions.md │
  51. │ (Skill detection, universal patterns, routing) │
  52. ├────────────────────────────────────────────────────────────────────┤
  53. │ .github/skills/*.md │
  54. │ (25 specialized workflows with KQL, risk assessment) │
  55. ├────────────────────────────────────────────────────────────────────┤
  56. │ MCP Servers (Platform) │
  57. │ ┌─────────────┐ ┌──────────────┐ ┌───────────────────────────┐ │
  58. │ │ Sentinel │ │ Graph API │ │ Sentinel Triage (XDR) │ │
  59. │ │ Data Lake │ │ (Identity) │ │ (Advanced Hunting) │ │
  60. │ └─────────────┘ └──────────────┘ └───────────────────────────┘ │
  61. │ ┌─────────────┐ ┌──────────────┐ ┌───────────────────────────┐ │
  62. │ │ KQL Search │ │ Microsoft │ │ Azure MCP Server │ │
  63. │ │ (Schema) │ │ Learn (Docs) │ │ (ARM + Monitor) │ │
  64. │ └─────────────┘ └──────────────┘ └───────────────────────────┘ │
  65. │ ┌─────────────┐ │
  66. │ │ Sentinel │ │
  67. │ │ Graph (Rel) │ │
  68. │ └─────────────┘ │
  69. ├────────────────────────────────────────────────────────────────────┤
  70. │ MCP Apps (Local Custom Servers) │
  71. │ ┌─────────────┐ ┌──────────────┐ ┌───────────────────────────┐ │
  72. │ │ Geomap │ │ Heatmap │ │ Incident Comment │ │
  73. │ │ (Attack Map)│ │ (Patterns) │ │ (Sentinel Integration) │ │
  74. │ └─────────────┘ └──────────────┘ └───────────────────────────┘ │
  75. ├────────────────────────────────────────────────────────────────────┤
  76. │ Python Utilities │
  77. │ generate_report_from_json.py │ enrich_ips.py │ report_generator│
  78. └────────────────────────────────────────────────────────────────────┘
  79. ```
  80. **Key Components:**
  81. - **25 Agent Skills** — Modular investigation workflows for incidents, users, devices, IoCs, authentication, scope drift (SPN/User/Device), MCP monitoring, exposure management, AI agent posture, app registration posture, identity posture, data security analysis, email threat posture, MITRE ATT&CK coverage, ingestion analysis, detection authoring, threat pulse scanning, SVG dashboards, and more
  82. - **6 MCP Server Integrations** — Sentinel Data Lake (incl. Exposure Graph tools), Graph API, Defender XDR Triage, KQL Search, Microsoft Learn, Azure MCP Server
  83. - **3 Local MCP Apps** — Interactive heatmaps, geographic attack maps, incident commenting
  84. - **Python Utilities** — HTML report generation with IP enrichment (geolocation, VPN detection, abuse scores, Shodan port/service/CVE intelligence)
  85. ---
  86. ## 🤖 Agent Skills
  87. This system uses **[VS Code Agent Skills](https://code.visualstudio.com/docs/copilot/customization/agent-skills)** to provide modular, domain-specific investigation workflows. Skills are automatically detected based on keywords in your prompts.
  88. ### Available Skills (25)
  89. | Category | Skill | Description | Trigger Keywords |
  90. |----------|-------|-------------|------------------|
  91. | ⚡ Quick Scan | **[threat-pulse](/.github/skills/threat-pulse/SKILL.md)** | Rapid broad-spectrum security scan across 7 domains: active incidents, identity (human + NHI), endpoint, email threats, admin & cloud ops, exposure. Prioritized Threat Pulse findings with color-coded verdicts and drill-down recommendations | "threat pulse", "quick scan", "security pulse", "morning hunt", "what can you do", "where do I start", "what's going on" |
  92. | 🔍 Core Investigation | **[computer-investigation](/.github/skills/computer-investigation/SKILL.md)** | Device security analysis for Entra Joined, Hybrid Joined, and Entra Registered devices: Defender alerts, compliance, logged-on users, vulnerabilities, process/network/file events | "investigate computer", "investigate device", "investigate endpoint", "check machine", hostname |
  93. | 🔍 Core Investigation | **[honeypot-investigation](/.github/skills/honeypot-investigation/SKILL.md)** | Honeypot security analysis: attack patterns, threat intel, vulnerabilities, executive reports | "honeypot", "attack analysis", "threat actor" |
  94. | 🔍 Core Investigation | **[incident-investigation](/.github/skills/incident-investigation/SKILL.md)** | Comprehensive incident analysis for Defender XDR and Sentinel incidents: criticality assessment, entity extraction, filtering, recursive entity investigation | "investigate incident", "incident ID", "analyze incident", "triage incident", incident number |
  95. | 🔍 Core Investigation | **[ioc-investigation](/.github/skills/ioc-investigation/SKILL.md)** | Indicator of Compromise analysis: IP addresses, domains, URLs, file hashes. Includes Defender Threat Intelligence, Sentinel TI tables, CVE correlation, organizational exposure | "investigate IP", "investigate domain", "investigate URL", "investigate hash", "IoC", "is this malicious" |
  96. | 🔍 Core Investigation | **[user-investigation](/.github/skills/user-investigation/SKILL.md)** | Entra ID user security analysis: sign-ins, anomalies, MFA, devices, audit logs, incidents, Identity Protection, HTML reports | "investigate user", "security investigation", "check user activity", UPN/email |
  97. | 🔐 Auth & Access | **[authentication-tracing](/.github/skills/authentication-tracing/SKILL.md)** | Entra ID authentication chain forensics: SessionId analysis, token reuse vs interactive MFA, geographic anomalies | "trace authentication", "SessionId analysis", "token reuse", "geographic anomaly" |
  98. | 🔐 Auth & Access | **[ca-policy-investigation](/.github/skills/ca-policy-investigation/SKILL.md)** | Conditional Access policy forensics: sign-in failure correlation, policy state changes, security bypass detection | "Conditional Access", "CA policy", "device compliance", "policy bypass" |
  99. | 📈 Behavioral Analysis | **[scope-drift-detection/device](/.github/skills/scope-drift-detection/device/SKILL.md)** | Device process drift: configurable-window baseline, 5-dimension Drift Score (Volume/Processes/Accounts/Chains/Signing), fleet-wide or single-device, Heartbeat uptime corroboration | "device drift", "endpoint drift", "process baseline", "device behavioral change" |
  100. | 📈 Behavioral Analysis | **[scope-drift-detection/spn](/.github/skills/scope-drift-detection/spn/SKILL.md)** | SPN scope drift: 90-day baseline vs 7-day comparison, 5-dimension Drift Score, correlated with AuditLogs, SecurityAlert, DeviceNetworkEvents | "scope drift", "service principal drift", "SPN behavioral change", "SPN drift" |
  101. | 📈 Behavioral Analysis | **[scope-drift-detection/user](/.github/skills/scope-drift-detection/user/SKILL.md)** | User scope drift: 90-day baseline vs 7-day comparison, dual Drift Scores (7-dim interactive + 6-dim non-interactive), correlated with AuditLogs, SecurityAlert, Identity Protection, CloudAppEvents, EmailEvents | "user drift", "user scope drift", "user behavioral change", "UPN drift" |
  102. | 🛡️ Posture & Exposure | **[exposure-investigation](/.github/skills/exposure-investigation/SKILL.md)** | Vulnerability & Exposure Management reporting: CVE assessment with exploit/CVSS data, security configuration compliance, end-of-support software, ExposureGraph critical assets, attack paths, Defender health, certificate status | "vulnerability report", "exposure report", "CVE assessment", "security posture", "TVM" |
  103. | 🛡️ Posture & Exposure | **[ai-agent-posture](/.github/skills/ai-agent-posture/SKILL.md)** | AI agent security posture audit for Copilot Studio and M365 Copilot agents: agent inventory, authentication gaps, access control misconfigurations, MCP tool proliferation, knowledge source exposure, XPIA risk, credential detection, Agent Security Score | "AI agent posture", "agent security audit", "Copilot Studio agents", "agent inventory", "unauthenticated agents", "agent sprawl" |
  104. | 🛡️ Posture & Exposure | **[app-registration-posture](/.github/skills/app-registration-posture/SKILL.md)** | App registration and service principal security posture: Graph API permission inventory (dangerous grants, permission concentration), app ownership risk, credential hygiene (stale secrets, multi-credential apps), cross-tenant SPN exposure, KQL attack chain detection (AuditLogs, AADServicePrincipalSignInLogs, MicrosoftGraphActivityLogs), App Permission Risk Score with 5 dimensions | "app registration posture", "app registration abuse", "service principal permissions", "dangerous app permissions", "app ownership", "overprivileged apps" |
  105. | 🛡️ Posture & Exposure | **[email-threat-posture](/.github/skills/email-threat-posture/SKILL.md)** | Email threat protection posture report for Microsoft Defender for Office 365: inbound mail flow overview, threat composition (phishing/spam/malware), email authentication (DMARC/DKIM/SPF/CompAuth), ZAP post-delivery remediation, Safe Links click protection, attachment analysis, detection method breakdown, MDO security incidents, Email Protection Score with 5 dimensions. Inline chat, markdown file, and SVG dashboard output | "email threat report", "email security posture", "phishing report", "MDO report", "Defender for Office 365 report", "ZAP effectiveness", "Safe Links report", "DMARC report" |
  106. | 🛡️ Posture & Exposure | **[identity-posture](/.github/skills/identity-posture/SKILL.md)** | Identity security posture report using IdentityAccountInfo (MDI/Advanced Hunting): multi-provider account inventory (Entra ID, AD, Okta, SailPoint, CyberArk, Ping), privileged account audit with role distribution, stale/disabled/deleted account hygiene, password posture, risk distribution, multi-provider identity linking, MDI tag analysis, Identity Posture Score with 5 dimensions. Inline chat and markdown file output | "identity posture", "identity security report", "account hygiene", "stale accounts", "privileged accounts", "password posture", "identity providers", "honeytoken" |
  107. | 🔒 Data Security | **[data-security-analysis](/.github/skills/data-security-analysis/SKILL.md)** | DataSecurityEvents (Purview/IRM) analysis: SIT access breakdowns, user risk ranking, file inventory, DLP policy correlation, Copilot SIT exposure, SIT GUID-to-name resolution, anomaly detection. Designed for 100k+ user environments | "data security", "sensitive information type", "SIT access", "DLP events", "DataSecurityEvents", "EDM access", "insider risk activity", "Purview data security" |
  108. | 📊 Visualization | **[geomap-visualization](/.github/skills/geomap-visualization/SKILL.md)** | Interactive world map visualization for Sentinel data: attack origin maps, geographic threat distribution, IP geolocation with enrichment drill-down | "geomap", "world map", "geographic", "attack map", "attack origins" |
  109. | 📊 Visualization | **[heatmap-visualization](/.github/skills/heatmap-visualization/SKILL.md)** | Interactive heatmap visualization for Sentinel data: attack patterns by time, activity grids, IP vs hour matrices, threat intel drill-down | "heatmap", "show heatmap", "visualize patterns", "activity grid" |
  110. | 📊 Visualization | **[svg-dashboard](/.github/skills/svg-dashboard/SKILL.md)** | SVG data visualization dashboards: dual-mode renderer supporting manifest-driven structured dashboards (from skill reports) and freeform adaptive visualizations from ad-hoc investigation data. 14-widget component library | "generate SVG dashboard", "create a visual dashboard", "visualize this report", "SVG from this data" |
  111. | 🔧 Tooling & Monitoring | **[detection-authoring](/.github/skills/detection-authoring/SKILL.md)** | Create, deploy, update, and manage Defender XDR custom detection rules via Graph API. Query adaptation from Sentinel KQL, manifest-driven batch deployment via PowerShell, lifecycle management | "create custom detection", "deploy detection", "detection rule", "custom detection", "deploy rule", "batch deploy" |
  112. | 🔧 Tooling & Monitoring | **[kql-query-authoring](/.github/skills/kql-query-authoring/SKILL.md)** | KQL query creation using schema validation, community examples, Microsoft Learn | "write KQL", "create KQL query", "help with KQL", "query [table]" |
  113. | 🔧 Tooling & Monitoring | **[mcp-usage-monitoring](/.github/skills/mcp-usage-monitoring/SKILL.md)** | MCP server usage monitoring and audit: Graph MCP endpoint analysis, Sentinel MCP auth events, Azure MCP ARM operations, workspace query governance, MCP Usage Score with 5 health/risk dimensions | "MCP usage", "MCP server monitoring", "MCP activity", "MCP audit", "Graph MCP", "Sentinel MCP", "Azure MCP" |
  114. | 🔧 Tooling & Monitoring | **[sentinel-ingestion-report](/.github/skills/sentinel-ingestion-report/SKILL.md)** | Sentinel workspace ingestion & cost analysis: table-level volume breakdown, tier classification (Analytics/Basic/Data Lake), SecurityEvent/Syslog/CommonSecurityLog deep dives, ingestion anomaly detection, analytic rule inventory via REST API, custom detection inventory via Graph API, rule health via SentinelHealth, data lake tier migration candidates, license benefit analysis (DfS P2, M365 E5) | "ingestion report", "usage report", "data volume", "cost analysis", "table breakdown", "data lake tier", "ingestion anomaly", "cost optimization" |
  115. | 🔧 Tooling & Monitoring | **[mitre-coverage-report](/.github/skills/mitre-coverage-report/SKILL.md)** | MITRE ATT&CK coverage analysis: YAML-driven PowerShell pipeline gathers analytic rule MITRE tags, custom detection techniques, SOC Optimization recommendations, alert/incident operational data. Tactic-level coverage matrix, technique-level drill-down with rule mapping, coverage gap identification, SOC Optimization threat scenario alignment, untagged rule remediation, MITRE Coverage Score (5 weighted dimensions). Inline chat and markdown file output | "MITRE coverage", "ATT&CK coverage", "MITRE report", "tactic coverage", "technique coverage", "coverage gaps", "MITRE score", "detection coverage report", "MITRE matrix" |
  116. ### How Skills Work
  117. 1. You ask Copilot a question (e.g., "Investigate user@domain.com for the last 7 days")
  118. 2. Copilot detects keywords and loads the appropriate skill from `.github/skills/<skill-name>/SKILL.md`
  119. 3. The skill provides specialized workflow, KQL queries, and risk assessment criteria
  120. 4. Universal patterns from `.github/copilot-instructions.md` are inherited automatically
  121. ### Triggering Skills with Natural Language
  122. You don't need to mention the skill name — keywords are detected automatically:
  123. | What you say | Skill triggered |
  124. |--------------|-----------------|
  125. | "Investigate user@domain.com for the last 7 days" | user-investigation |
  126. | "Analyze incident 12345" | incident-investigation |
  127. | "Is this IP malicious? 203.0.113.42" | ioc-investigation |
  128. | "Check the device WORKSTATION-01 for threats" | computer-investigation |
  129. | "Show attack patterns on a heatmap" | heatmap-visualization |
  130. | "Generate an SVG dashboard from the report" | svg-dashboard |
  131. | "Map the geographic origins of these attacks" | geomap-visualization |
  132. | "Write a KQL query to find failed sign-ins" | kql-query-authoring |
  133. | "Trace this authentication back to the original MFA" | authentication-tracing |
  134. | "Detect scope drift in service principals" | scope-drift-detection/spn |
  135. | "Check user behavioral drift for user@domain.com" | scope-drift-detection/user |
  136. | "Analyze device process drift across the fleet" | scope-drift-detection/device |
  137. | "Show me MCP server usage for the last 30 days" | mcp-usage-monitoring |
  138. | "Generate a Sentinel ingestion report" | sentinel-ingestion-report |
  139. | "Create custom detections for Event ID 4799" | detection-authoring |
  140. | "Audit AI agent security posture" | ai-agent-posture |
  141. | "Who accessed files with credit card numbers?" | data-security-analysis |
  142. | "Generate an email threat protection report" | email-threat-posture |
  143. | "Run an identity posture report" | identity-posture |
  144. | "Generate a MITRE ATT&CK coverage report" | mitre-coverage-report |
  145. | "Run a threat pulse scan" | threat-pulse |
  146. | "Audit our app registration security posture" | app-registration-posture |
  147. ### Follow-ups and Chaining
  148. After running an investigation, ask follow-up questions without re-running the entire workflow:
  149. ```
  150. Is that IP a VPN?
  151. Trace authentication for that suspicious location
  152. Was MFA used for those sign-ins?
  153. ```
  154. Skills can be chained for comprehensive analysis:
  155. ```
  156. 1. "Investigate incident 12345" → incident-investigation extracts entities
  157. 2. "Now investigate the user from that incident" → user-investigation runs on extracted UPN
  158. 3. "Check if that IP is malicious" → ioc-investigation analyzes the suspicious IP
  159. 4. "Show me a heatmap of the attack patterns" → heatmap-visualization
  160. ```
  161. Copilot uses existing investigation data from `temp/investigation_*.json` when available.
  162. ### Discovering Skills
  163. ```
  164. What investigation skills do you have access to?
  165. Explain the high-level workflow of the user-investigation skill
  166. What data sources does the ioc-investigation skill use?
  167. ```
  168. **📖 Reference:** [GitHub Agent Skills Documentation](https://docs.github.com/en/copilot/concepts/agents/about-agent-skills)
  169. ### Authoring New Skills & Queries from Investigations
  170. Ad-hoc investigations naturally evolve into reusable assets. After completing an investigation, ask Copilot to package the verified queries, schema pitfalls, and analytical logic into a new SKILL.md or query file.
  171. ```
  172. "Based on the investigation we just completed, create a new reusable skill"
  173. "Read this threat intel article: <URL> — extract TTPs and IOCs, then write, test, and tune a queries file for reusable threat hunts"
  174. ```
  175. ---
  176. ## 📁 Project Structure
  177. ```
  178. security-investigator/
  179. ├── enrich_ips.py # Standalone IP enrichment utility
  180. ├── config.json # Configuration (workspace IDs, mappings)
  181. ├── config.json.template # Config template (committed to Git)
  182. ├── .env # API tokens (gitignored, auto-loaded by python-dotenv)
  183. ├── .env.template # Token template (committed to Git)
  184. ├── requirements.txt # Python dependencies
  185. ├── requirements.lock # Hash-verified dependency lockfile
  186. ├── .vscode/
  187. │ └── mcp.json.template # VS Code MCP server config template (copy to mcp.json)
  188. ├── .copilot/
  189. │ └── mcp-config.json.template # GitHub Copilot app/CLI MCP config template (copy to ~/.copilot/mcp-config.json)
  190. ├── .github/
  191. │ ├── copilot-instructions.md # Skill detection, universal patterns, routing
  192. │ ├── manifests/ # Auto-generated discovery indexes
  193. │ │ ├── discovery-manifest.yaml # Query file + skill index (domains, MITRE, prompts)
  194. │ │ └── build_manifest.py # Manifest generator script
  195. │ └── skills/ # 25 Agent Skills (modular investigation workflows)
  196. │ ├── ai-agent-posture/
  197. │ ├── app-registration-posture/
  198. │ ├── authentication-tracing/
  199. │ ├── ca-policy-investigation/
  200. │ ├── computer-investigation/
  201. │ ├── data-security-analysis/
  202. │ ├── detection-authoring/
  203. │ ├── email-threat-posture/
  204. │ ├── exposure-investigation/
  205. │ ├── geomap-visualization/
  206. │ ├── heatmap-visualization/
  207. │ ├── honeypot-investigation/
  208. │ ├── identity-posture/
  209. │ ├── incident-investigation/
  210. │ ├── ioc-investigation/
  211. │ ├── kql-query-authoring/
  212. │ ├── mcp-usage-monitoring/
  213. │ ├── mitre-coverage-report/
  214. │ ├── scope-drift-detection/
  215. │ │ ├── spn/ # Service principal drift (5 dimensions)
  216. │ │ ├── user/ # User account drift (7+6 dimensions)
  217. │ │ └── device/ # Device process drift (5 dimensions)
  218. │ ├── sentinel-ingestion-report/
  219. │ ├── svg-dashboard/
  220. │ ├── threat-pulse/
  221. │ └── user-investigation/
  222. ├── queries/ # Verified KQL query library (grep-searchable, by data domain)
  223. │ ├── cloud/ # Cloud app & exposure management queries
  224. │ ├── email/ # Defender for Office 365 email queries
  225. │ ├── endpoint/ # Defender for Endpoint device queries
  226. │ ├── identity/ # Entra ID / Azure AD identity queries
  227. │ ├── incidents/ # SecurityIncident & SecurityAlert queries
  228. │ └── network/ # Network telemetry queries
  229. ├── scripts/ # Python utilities
  230. │ ├── generate_report_from_json.py # Report generator (main entry point)
  231. │ ├── report_generator.py # HTML report builder class
  232. │ ├── investigator.py # Data models and core types
  233. │ ├── cleanup_old_investigations.py # Automated cleanup (3+ days old)
  234. │ └── generate_tocs.py # Auto-generate query file TOCs
  235. ├── mcp-apps/ # Local MCP servers (visualization, automation)
  236. │ ├── sentinel-geomap-server/
  237. │ ├── sentinel-heatmap-server/
  238. │ └── sentinel-incident-comment/
  239. ├── docs/ # Setup guides and reference documentation
  240. ├── authoring/ # Blog drafts, writing guides, and marketing content
  241. ├── reports/ # Generated investigation reports (organized by type)
  242. │ ├── ai-agent-posture/ # AI agent security posture reports
  243. │ ├── app-registration-posture/ # App registration posture reports
  244. │ ├── computer-investigations/ # Device security investigation reports
  245. │ ├── data-security/ # Data security SIT analysis reports
  246. │ ├── email-threat-posture/ # Email threat protection posture reports
  247. │ ├── exposure/ # Exposure management reports
  248. │ ├── honeypot/ # Honeypot executive reports
  249. │ ├── identity-posture/ # Identity security posture reports
  250. │ ├── mcp-usage/ # MCP usage monitoring reports
  251. │ ├── scope-drift/ # Scope drift analysis reports
  252. │ ├── sentinel/ # Sentinel ingestion & cost analysis reports
  253. │ ├── threat-pulse/ # Threat Pulse scan reports
  254. │ └── user-investigations/ # HTML user investigation reports
  255. ├── temp/ # Investigation JSON files (auto-cleaned after 3 days)
  256. └── archive/ # Legacy code and design docs
  257. ```
  258. ### Query Library (`queries/`)
  259. The `queries/` folder contains **verified, battle-tested KQL query collections** organized by detection scenario. These are the **Priority 2 lookup source** in the [KQL Pre-Flight Checklist](.github/copilot-instructions.md) — Copilot searches them before writing any ad-hoc KQL.
  260. Each file uses a standardized metadata header for efficient `grep_search` discovery:
  261. ```markdown
  262. # <Title>
  263. **Tables:** <exact KQL table names>
  264. **Keywords:** <searchable terms — attack techniques, scenarios, field names>
  265. **MITRE:** <ATT&CK technique IDs, e.g., T1021.001, TA0008>
  266. **Domains:** <domain tags for manifest indexing, e.g., identity, endpoint, email>
  267. ```
  268. ### Discovery Manifest (`.github/manifests/`)
  269. The **discovery manifest** provides a machine-readable index of all query files and skills, enabling deterministic cross-referencing by domain and MITRE technique. The Threat Pulse skill loads this manifest to match findings to downstream query files and drill-down skills automatically.
  270. - **`discovery-manifest.yaml`** — Compact index (~500 lines) with `title`, `path`, `domains`, `mitre`, and `prompt` fields for each query file and skill
  271. - **`build_manifest.py`** — Generator script that scans `queries/` metadata headers and skill YAML frontmatter to produce the manifest
  272. **How it works:**
  273. 1. Query files declare `**Domains:**` tags in their metadata header (valid tags: `incidents`, `identity`, `spn`, `endpoint`, `email`, `admin`, `cloud`, `exposure`)
  274. 2. Skills declare `threat_pulse_domains:` and `drill_down_prompt:` in their YAML frontmatter
  275. 3. `python .github/manifests/build_manifest.py` scans both and emits the manifest
  276. 4. The Threat Pulse skill reads the manifest to match non-✅ findings → relevant query files and skills by domain tag and MITRE technique overlap
  277. **Regenerate after** creating or renaming query files/skills, or changing `Domains:`/`threat_pulse_domains:` values:
  278. ```powershell
  279. python .github/manifests/build_manifest.py
  280. ```
  281. ---
  282. ## 🚀 Setup
  283. ### Prerequisites
  284. | Requirement | Details |
  285. |-------------|---------|
  286. | **VS Code** | Version 1.99+ recommended (Agent mode + MCP support). |
  287. | **GitHub Copilot** | Active subscription — [Copilot Pro+](https://github.com/features/copilot), Business, or Enterprise. Agent mode must be enabled. |
  288. | **Python 3.8+** | For IP enrichment utility and report generation. [Download](https://www.python.org/downloads/) |
  289. | **Azure CLI** | Required for Azure MCP Server (underlying auth) and `sentinel-ingestion-report` skill (`az monitor log-analytics query` for all KQL queries, `az rest` for analytic rule inventory, `az monitor log-analytics workspace table list` for tier classification). [Install](https://aka.ms/installazurecli). Authenticate: `az login --tenant <tenant_id>`, then `az account set --subscription <subscription_id>`. Requires **Log Analytics Reader** (KQL queries + table list) and **Microsoft Sentinel Reader** (analytic rule inventory) on the workspace. |
  290. | **`log-analytics` CLI extension** | Required by the `sentinel-ingestion-report` skill for `az monitor log-analytics query` (all KQL queries in Phases 1-5). Install: `az extension add --name log-analytics`. Verify: `az extension list --query "[?name=='log-analytics']"`. |
  291. | **PowerShell 7.0+** | Required for `sentinel-ingestion-report` skill (parallel query execution via `ForEach-Object -Parallel`). [Install](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell). Verify: `$PSVersionTable.PSVersion`. |
  292. | **Node.js 18+** | Required for KQL Search MCP (`npx`) and building local MCP Apps. [Download](https://nodejs.org/) or install via `winget install OpenJS.NodeJS.LTS` (Windows) / `brew install node` (macOS). |
  293. | **Microsoft Sentinel** | Log Analytics workspace with data. You'll need the workspace GUID and tenant ID. |
  294. | **Entra ID Permissions** | If you can query Sentinel in the Azure Portal, you likely have sufficient access. The **Graph MCP server** requires a [one-time tenant provisioning](https://learn.microsoft.com/en-us/graph/mcp-server/get-started?tabs=http%2Cvscode) by an admin. See [MCP Server Setup](#-mcp-server-setup) for detailed per-server requirements. |
  295. | **Microsoft.Graph PowerShell** | Required for `detection-authoring` skill (`CustomDetection.ReadWrite.All` — create/update/delete custom detection rules via Graph API). Also used by `sentinel-ingestion-report` skill for rule inventory (`CustomDetection.Read.All` — read-only, degrades gracefully if not installed). `Install-Module Microsoft.Graph.Authentication -Scope CurrentUser`. |
  296. | **GitHub PAT** | `public_repo` scope — [Create one here](https://github.com/settings/tokens/new). Used by KQL Search MCP. |
  297. ### 1. Install Dependencies
  298. Verify prerequisites:
  299. ```powershell
  300. python --version # Requires 3.8+
  301. node --version # Requires 18+ (needed for KQL Search MCP)
  302. az --version # Azure CLI (needed for Azure MCP Server, ingestion report skill)
  303. pwsh --version # Requires 7.0+ (needed for sentinel-ingestion-report skill)
  304. ```
  305. If Node.js is missing: [Download](https://nodejs.org/) or run `winget install OpenJS.NodeJS.LTS` (Windows) / `brew install node` (macOS).
  306. If Azure CLI is missing: [Install](https://aka.ms/installazurecli), then `az login --tenant <tenant_id>` and `az account set --subscription <subscription_id>`.
  307. If the `log-analytics` extension is missing: `az extension add --name log-analytics` (required for `sentinel-ingestion-report` skill).
  308. Set up Python environment:
  309. ```powershell
  310. python -m venv .venv
  311. .\.venv\Scripts\Activate.ps1
  312. pip install -r requirements.txt
  313. ```
  314. ### 2. Configure Environment
  315. Copy `config.json.template` to `config.json` and fill in your workspace details:
  316. ```json
  317. {
  318. "sentinel_workspace_id": "YOUR_WORKSPACE_ID_HERE",
  319. "tenant_id": "YOUR_TENANT_ID_HERE",
  320. "subscription_id": "YOUR_SUBSCRIPTION_ID_HERE",
  321. "azure_mcp": {
  322. "resource_group": "YOUR_LOG_ANALYTICS_RESOURCE_GROUP",
  323. "workspace_name": "YOUR_LOG_ANALYTICS_WORKSPACE_NAME",
  324. "tenant": "YOUR_TENANT_ID_HERE",
  325. "subscription": "YOUR_SUBSCRIPTION_ID_HERE"
  326. },
  327. "output_dir": "reports"
  328. }
  329. ```
  330. | Setting | Required | Description |
  331. |---------|----------|-------------|
  332. | `sentinel_workspace_id` | Yes | Microsoft Sentinel (Log Analytics) workspace GUID |
  333. | `tenant_id` | Yes | Entra ID (Azure AD) tenant ID for your Sentinel workspace |
  334. | `subscription_id` | Yes | Azure subscription ID containing the Sentinel workspace |
  335. | `azure_mcp.*` | Yes | Azure MCP Server parameters — resource group, workspace name, tenant, subscription. Required to avoid cross-tenant auth errors. |
  336. | `output_dir` | No | Directory for HTML reports (default: `reports`) |
  337. #### API Tokens (`.env` file)
  338. API tokens for IP enrichment are stored in a `.env` file (gitignored) rather than `config.json` for security. Copy the template and add your keys:
  339. ```powershell
  340. copy .env.template .env
  341. # Edit .env with your token values
  342. ```
  343. ```dotenv
  344. IPINFO_TOKEN=your_token_here
  345. ABUSEIPDB_TOKEN=your_token_here
  346. VPNAPI_TOKEN=your_token_here
  347. SHODAN_TOKEN=your_token_here
  348. ```
  349. These are auto-loaded by `enrich_ips.py` via `python-dotenv` — no manual sourcing needed.
  350. | Token | Required | Description |
  351. |-------|----------|-------------|
  352. | `IPINFO_TOKEN` | Recommended | [ipinfo.io](https://ipinfo.io/) API token — geolocation, ASN, org. Free: 1K/day; token: 50K/month; paid plans include VPN detection |
  353. | `ABUSEIPDB_TOKEN` | Recommended | [AbuseIPDB](https://www.abuseipdb.com/) API token — IP reputation scoring (0-100 confidence). Free: 1K/day |
  354. | `VPNAPI_TOKEN` | Optional | [vpnapi.io](https://vpnapi.io/) API token — VPN/proxy/Tor detection. Not needed if ipinfo.io is on a paid plan |
  355. | `SHODAN_TOKEN` | Optional | [Shodan](https://account.shodan.io/) API key — open ports, services, CVEs, OS detection, tags. Free InternetDB fallback if no key or credits exhausted |
  356. ### 3. Configure MCP Servers
  357. Copy the MCP server template (all platform servers + 3 optional MCP Apps are pre-configured):
  358. ```powershell
  359. copy .vscode/mcp.json.template .vscode/mcp.json
  360. ```
  361. The template includes inline documentation for each server. On first use, VS Code will prompt for:
  362. - **Entra ID login** — browser-based auth for Sentinel Data Lake, Graph, and Triage servers
  363. - **[GitHub PAT](https://github.com/settings/tokens/new)** — for KQL Search MCP (schema intelligence and query discovery). Needs `public_repo` scope.
  364. > **Using the GitHub Copilot app or CLI?** Use [`.copilot/mcp-config.json.template`](.copilot/mcp-config.json.template) instead — see [MCP config for the app](#mcp-config-for-the-app).
  365. See [MCP Server Setup](#-mcp-server-setup) below for per-server permissions and installation guides.
  366. ### 4. Build MCP Apps (Optional — Visualization Skills)
  367. **PowerShell (Windows):**
  368. ```powershell
  369. cd mcp-apps/sentinel-geomap-server; npm install; npm run build; cd ../..
  370. cd mcp-apps/sentinel-heatmap-server; npm install; npm run build; cd ../..
  371. cd mcp-apps/sentinel-incident-comment; npm install; npm run build; cd ../..
  372. ```
  373. **Bash (macOS/Linux):**
  374. ```bash
  375. cd mcp-apps/sentinel-geomap-server && npm install && npm run build && cd ../..
  376. cd mcp-apps/sentinel-heatmap-server && npm install && npm run build && cd ../..
  377. cd mcp-apps/sentinel-incident-comment && npm install && npm run build && cd ../..
  378. ```
  379. The `sentinel-incident-comment` MCP App requires an Azure Logic App backend. See [mcp-apps/sentinel-incident-comment/README.md](mcp-apps/sentinel-incident-comment/README.md) for setup. Based on [stefanpems/mcp-add-comment-to-sentinel-incident](https://github.com/stefanpems/mcp-add-comment-to-sentinel-incident).
  380. ---
  381. ## 🖥️ Running in the GitHub Copilot App (Desktop)
  382. This project also runs great in the **[GitHub Copilot app](https://github.com/features/ai/github-app)** (desktop), not just VS Code. The app is especially useful for **scheduled automations**: its built-in **Workflows** system runs skills unattended on a schedule — for example the [Daily Threat Pulse](automations/daily-threat-pulse.workflow.md) and [Weekly Threat Intel Campaign](automations/weekly-threat-intel-campaign.workflow.md) definitions in [`automations/`](automations/). It also runs each task in an isolated git worktree, so you can run multiple investigations in parallel without them colliding.
  383. > 📥 **Download:** [github.com/features/ai/github-app](https://github.com/features/ai/github-app)
  384. ### Why use the app
  385. - **Scheduled automations (Workflows)** — run the Threat Pulse scan every morning, or the Threat Intel Campaign weekly, fully unattended. See [`automations/`](automations/) for ready-to-import, PII-free workflow definitions.
  386. - **Parallel, isolated sessions** — each session is its own git worktree + branch, so concurrent investigations don't step on each other.
  387. - **Background agents** — long-running hunts and report generation can run in the background while you keep working.
  388. ### 🎛️ Mission Control (Canvas extension)
  389. The app also supports **[Canvas extensions](https://docs.github.com/en/copilot/how-tos/github-copilot-app/working-with-canvas-extensions)** — interactive panels that render beside the chat, where both you and the agent act on the same surface. This repo ships one: **Mission Control**, a launchable dashboard for the whole framework. It self-registers from [`.github/extensions/skills-canvas/`](.github/extensions/skills-canvas/) — no build step, no install.
  390. Just start a session and prompt:
  391. > 💬 **"Start Mission Control"**
  392. The panel opens with three tabs:
  393. - **🗂️ Skills** — every investigation skill as a launchable card. Filter by domain, search, and one-click launch — with optional fleet-wide scope and inline/markdown report toggles.
  394. - **📋 Queries** — all KQL query files, domain-filtered. Open any to read the markdown or hand it to the agent as context for a targeted hunt.
  395. - **📊 Findings** — when the agent finishes an investigation it records the result back into the canvas (severity, entities, evidence, and tailored one-click follow-ups). Click a severity pill to filter.
  396. The human launches work; the agent reports back to the same surface — a control plane for investigations, not just a UI.
  397. ![Mission Control — Skills tab: every investigation skill as a launchable card, filterable by domain, with a highlighted Threat Pulse starting point.](docs/images/mission-control-skills.png)
  398. *Skills tab — launch any investigation with optional fleet-wide scope and inline/markdown output. The left rail filters skills and queries by domain; the entity quick-launch bar routes a UPN / IP / hash / device / incident to the right investigation.*
  399. ![Mission Control — Findings tab: agent-reported investigation results with severity, evidence chips, linked reports, and recommended one-click follow-ups.](docs/images/mission-control-findings.png)
  400. *Findings tab — the agent reports each result back to the canvas: summary, evidence chips, linked reports, and tailored one-click follow-ups (e.g. drill into a flagged CVE, user, or incident).*
  401. ### ⚠️ Caveats & differences vs VS Code
  402. The app behaves slightly differently from VS Code. The most important difference: **each session is a fresh git worktree**, and gitignored local files (`config.json`, `.env`, MCP config) do **not** exist in a newly created worktree — they live only in your main checkout. You need a small **post-checkout step** to copy them into each session, otherwise the first query fails with a missing-config error.
  403. | Concern | VS Code | GitHub Copilot app |
  404. |---|---|---|
  405. | **MCP config** | `.vscode/mcp.json` (per workspace) | **User scope:** `~/.copilot/mcp-config.json` — start from [`.copilot/mcp-config.json.template`](.copilot/mcp-config.json.template) (see [MCP config for the app](#mcp-config-for-the-app) below). The platform servers and the `kql-search` `GITHUB_TOKEN` go here, not in `.vscode/mcp.json`. Authenticate once interactively so OAuth tokens cache and refresh silently in scheduled runs. |
  406. | **`config.json` / `.env`** | One copy in your workspace folder | Gitignored, so **absent in each new worktree** — must be copied in per session (see below). |
  407. | **Memory / tenant context** | VS Code AppData memory store (auto-loads ~200 lines) | `~/.copilot/memories/` (user) and `~/.copilot/memories/repo/` (repo). **Scheduled runs are non-interactive, so repo memory does NOT auto-load** — automation prompts must read the context file explicitly by path (the `automations/` definitions do this in STEP 1.5). |
  408. | **Sessions / workspace** | Single workspace folder, one branch | One git **worktree + branch per session**, created under your worktrees root (e.g. `~/copilot-worktrees/<repo>/<branch>`). Operate only inside the session worktree — never the main checkout. |
  409. #### MCP config for the app
  410. The app (and Copilot CLI) reads MCP servers from **user scope** (`~/.copilot/mcp-config.json`), not `.vscode/mcp.json`. The format differs from VS Code: top-level `mcpServers` key, strict JSON (no comments / `inputs` block), and no `${workspaceFolder}` variable. A ready-to-use template with all platform servers is provided:
  411. ```powershell
  412. # Windows (merge manually if you already have a mcp-config.json)
  413. copy .copilot\mcp-config.json.template $env:USERPROFILE\.copilot\mcp-config.json
  414. ```
  415. ```bash
  416. # macOS/Linux
  417. cp .copilot/mcp-config.json.template ~/.copilot/mcp-config.json
  418. ```
  419. Then:
  420. 1. Set a `GITHUB_TOKEN` environment variable ([GitHub PAT](https://github.com/settings/tokens/new), `public_repo` scope) — `kql-search` reads it via `${env:GITHUB_TOKEN}`.
  421. 2. Run `az login --tenant <tenant_id>` for `azure-mcp-server` (uses `AzureCliCredential`).
  422. 3. Restart the app / CLI and sign in once interactively so OAuth tokens cache for scheduled runs.
  423. **Multi-tenant (optional):** If your account has access to multiple tenants (e.g., guest/B2B or CSP), pin the Sentinel and Graph servers to a specific tenant by adding a header to `sentinel-data-mcp`, `sentinel-triage-mcp`, and `Graph-mcp-server`:
  424. ```json
  425. "headers": {
  426. "x-mcp-client-tenant-id": "<your-tenant-id>"
  427. }
  428. ```
  429. Without it, sign-in uses your account's home tenant.
  430. **Optional MCP Apps** (geomap, heatmap, incident-comment) need absolute paths in user scope. After [building them](#4-build-mcp-apps-optional--visualization-skills), add entries like the following to `mcpServers`:
  431. ```json
  432. "custom-sentinel-geomap": {
  433. "tools": ["*"],
  434. "type": "stdio",
  435. "command": "node",
  436. "args": ["C:/path/to/security-investigator/mcp-apps/sentinel-geomap-server/dist/main.js", "--stdio"]
  437. }
  438. ```
  439. Use `mcp-apps/sentinel-heatmap-server/dist/main.js` for the heatmap, and `mcp-apps/sentinel-incident-comment/dist/index.js` (plus `"env": { "SENTINEL_COMMENT_WEBHOOK_URL": "<your Logic App URL>" }`) for incident comments.
  440. #### Post-checkout workflow (persist config into each session)
  441. Because `config.json`, `.env`, and `.vscode/mcp.json` are gitignored, a freshly created worktree won't contain them. Set up a **`post-checkout` git hook** that copies them from your main checkout into the new worktree. Example (`.git/hooks/post-checkout`, marked executable):
  442. ```bash
  443. #!/usr/bin/env bash
  444. # Copy gitignored local config from the main checkout into a fresh worktree/session.
  445. MAIN="/path/to/your/main/checkout" # adjust to your primary clone
  446. for f in config.json .env .vscode/mcp.json; do
  447. if [ ! -f "$f" ] && [ -f "$MAIN/$f" ]; then
  448. mkdir -p "$(dirname "$f")"
  449. cp "$MAIN/$f" "$f"
  450. fi
  451. done
  452. ```
  453. > Alternatively, define the same copy logic as a **per-session setup command** in the app. Either way the goal is identical: every session ends up with a valid `config.json`, `.env`, and MCP config before the first query runs.
  454. For **scheduled automations**, the workflow prompts in [`automations/`](automations/) also include a **STEP 1 bootstrap** that recreates `config.json` from known values if it's missing — a belt-and-suspenders guarantee for non-interactive runs (it never commits `config.json`, which stays gitignored).
  455. ---
  456. ## 🔌 MCP Server Setup
  457. The system uses several Model Context Protocol (MCP) servers. All are **pre-configured** in [.vscode/mcp.json.template](.vscode/mcp.json.template) — copy it to `.vscode/mcp.json` to get started (see [Step 3 above](#3-configure-mcp-servers)). For the GitHub Copilot app / CLI, use [.copilot/mcp-config.json.template](.copilot/mcp-config.json.template) instead (see [MCP config for the app](#mcp-config-for-the-app)). The sections below document permissions, tools, and installation guides for each server.
  458. ### At a Glance
  459. | # | Server | MCP URL / Transport | Setup Guide | Key Permissions |
  460. |---|--------|---------------------|-------------|-----------------|
  461. | 1 | **Sentinel Data Lake** | `https://sentinel.microsoft.com/mcp/data-exploration` | [Setup](https://learn.microsoft.com/en-us/azure/sentinel/datalake/sentinel-mcp-get-started) | Log Analytics Reader |
  462. | 2 | **Microsoft Graph** | `https://mcp.svc.cloud.microsoft/enterprise` | [Setup](https://learn.microsoft.com/en-us/graph/mcp-server/get-started?tabs=http%2Cvscode) | User.Read.All, Device.Read.All |
  463. | 3 | **Sentinel Triage** | `https://sentinel.microsoft.com/mcp/triage` | [Setup](https://learn.microsoft.com/en-us/azure/sentinel/datalake/sentinel-mcp-triage-tool) | SecurityReader |
  464. | 4 | **KQL Search** | `npx -y kql-search-mcp` (stdio) | [Setup](https://www.npmjs.com/package/kql-search-mcp) | [GitHub PAT](https://github.com/settings/tokens/new) (`public_repo`) |
  465. | 5 | **Microsoft Learn** | `https://learn.microsoft.com/api/mcp` | [Setup](https://github.com/MicrosoftDocs/mcp) | None (free) |
  466. | 6 | **Azure MCP Server** | VS Code extension (stdio) | [Setup](https://learn.microsoft.com/en-us/azure/developer/azure-mcp-server/overview) | Contributor or Reader on subscription |
  467. ### 1. Microsoft Sentinel MCP Server
  468. **📖 [Installation Guide](https://learn.microsoft.com/en-us/copilot/security/developer/mcp-get-started)**
  469. **Tools:** `query_lake`, `search_tables`, `list_sentinel_workspaces`
  470. **Exposure Graph tools (bundled here):** `find_blastradius`, `find_exposure_perimeter`, `find_walkable_paths`, `find_connected_nodes`, `find_nodes`, `get_graph_context`, plus entity analysis (`analyze_user_entity`, `analyze_url_entity`, `analyze_application_entity`). These ship in the Data Lake server with no `graph_` prefix.
  471. **Permissions:**
  472. - **Log Analytics Reader** (minimum) — query workspace data
  473. - **Sentinel Reader** (recommended) — full investigation capabilities
  474. - **Sentinel Contributor** — watchlist management (optional)
  475. ### 2. MCP Server for Microsoft Graph
  476. **📖 [Installation Guide](https://learn.microsoft.com/en-us/graph/mcp-server/get-started?tabs=http%2Cvscode)**
  477. **Tools:** `microsoft_graph_suggest_queries`, `microsoft_graph_get`, `microsoft_graph_list_properties`
  478. **⚡ One-time tenant provisioning** (requires **Application Administrator** or **Cloud Application Administrator** role):
  479. ```powershell
  480. # 1. Install the Entra Beta PowerShell module (v1.0.13+)
  481. Install-Module Microsoft.Entra.Beta -Force -AllowClobber
  482. # 2. Authenticate to your tenant
  483. Connect-Entra -Scopes 'Application.ReadWrite.All', 'Directory.Read.All', 'DelegatedPermissionGrant.ReadWrite.All'
  484. # 3. Register the MCP Server and grant permissions to VS Code
  485. Grant-EntraBetaMCPServerPermission -ApplicationName VisualStudioCode
  486. ```
  487. > This only needs to be done **once per tenant**. After provisioning, all users in the tenant can use the Graph MCP server by signing in with their own account.
  488. **Permissions (delegated, per-user):**
  489. - **User.Read.All** — user profiles and authentication methods
  490. - **UserAuthenticationMethod.Read.All** — MFA methods
  491. - **Device.Read.All** — device compliance and enrollment
  492. - **IdentityRiskEvent.Read.All** — Identity Protection risk detections
  493. ### 3. Microsoft Sentinel Triage MCP Server
  494. **📖 [Installation Guide](https://learn.microsoft.com/en-us/azure/sentinel/datalake/sentinel-mcp-triage-tool)**
  495. **Tools (30+):** `RunAdvancedHuntingQuery`, `ListIncidents`, `GetAlertById`, `GetDefenderMachine`, `GetDefenderFileInfo`, `GetDefenderIpAlerts`, `ListUserRelatedMachines`, `GetDefenderMachineVulnerabilities`, and more.
  496. **Permissions:**
  497. - **Microsoft Defender for Endpoint API** — SecurityReader role minimum
  498. - **Advanced Hunting** — read access to Defender XDR data
  499. ### 4. KQL Search MCP Server
  500. **📖 [Installation Guide](https://www.npmjs.com/package/kql-search-mcp)**
  501. **Option A: VS Code Extension (Recommended)**
  502. 1. Extensions panel → Search "KQL Search MCP" → Install
  503. 2. Command Palette → `KQL Search MCP: Set GitHub Token`
  504. **Option B: NPX** — already configured in `.vscode/mcp.json.template`. Just needs a [GitHub PAT](https://github.com/settings/tokens/new) with `public_repo` scope (prompted on first use).
  505. **Tools (34):** Schema intelligence, query validation, GitHub search, ASIM support for 331+ tables.
  506. ### 5. Microsoft Learn MCP Server
  507. **📖 [Installation Guide](https://github.com/MicrosoftDocs/mcp)**
  508. **One-click:** [Install in VS Code](https://vscode.dev/redirect/mcp/install?name=microsoft-learn&config=%7B%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Flearn.microsoft.com%2Fapi%2Fmcp%22%7D) — or already configured in `.vscode/mcp.json.template`.
  509. **Tools:** `microsoft_docs_search`, `microsoft_docs_fetch`, `microsoft_code_sample_search`
  510. No API key required — free, cloud-hosted by Microsoft.
  511. ### 6. Azure MCP Server
  512. **📖 [Installation Guide](https://learn.microsoft.com/en-us/azure/developer/azure-mcp-server/overview)**
  513. Install via VS Code extension: search "Azure MCP Server" in Extensions, or install from the [Marketplace](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.azure-mcp). The extension registers as a stdio MCP server automatically.
  514. **Tools:** `monitor_workspace_log_query`, `monitor_activitylog_list`, `group_list`, `subscription_list`, and 40+ namespaces covering AI, identity, security, databases, storage, compute, and networking.
  515. **Permissions:**
  516. - **Reader** (minimum) — read-only access to Azure resources
  517. - **Log Analytics Reader** — for `workspace_log_query` (KQL against Log Analytics)
  518. - **Contributor** — for write/modify operations (optional)
  519. **Configuration:** Requires `azure_mcp` parameters in `config.json` (tenant, subscription, resource group, workspace name) to avoid cross-tenant auth errors. See [Configure Environment](#2-configure-environment).
  520. ### Verify Setup
  521. Open **Copilot Chat** (`Ctrl+Shift+I`) in **Agent mode** and try these prompts:
  522. | Test | Prompt to type in Copilot Chat |
  523. |------|--------------------------------|
  524. | Sentinel Data Lake | `List my Sentinel workspaces` |
  525. | Microsoft Graph | `Look up my user profile in Graph` |
  526. | Sentinel Triage | `List recent security incidents` |
  527. | KQL Search | `What columns does the SigninLogs table have?` |
  528. | Microsoft Learn | `Search Microsoft docs for KQL query language` |
  529. | All skills | `What investigation skills do you have access to?` |
  530. If any server fails, check the **MCP Servers** panel in VS Code (click the `{}` icon in the bottom status bar) to verify each server shows a green connected status.
  531. ---
  532. ## ⚙️ Configuration Details
  533. ### API Rate Limits (IP Enrichment)
  534. | Provider | Free Tier | With Token |
  535. |----------|-----------|------------|
  536. | **ipinfo.io** | 1,000/day (geo, org, ASN) | 50,000/month; paid plans include VPN detection |
  537. | **AbuseIPDB** | 1,000/day | 10,000/day ($20/month) |
  538. | **vpnapi.io** | 1,000/month | 10,000/month ($9.99/month) |
  539. | **Shodan** | InternetDB (unlimited, ports/vulns/tags) | $49 one-time membership: 100 queries/month (adds services, banners, SSL, OS) |
  540. **Token priority:** If `ipinfo_token` is a paid plan, VPN detection is included and `vpnapi_token` is optional. Shodan uses the full API when a paid key is available; on 403/429 it automatically falls back to the free InternetDB.
  541. IP enrichment happens during **report generation** (not data collection), so you can re-generate reports without re-querying Sentinel/Graph.
  542. ### Dependencies
  543. ```powershell
  544. pip install -r requirements.txt
  545. ```
  546. Core packages: **requests** (HTTP client for enrichment APIs), **python-dateutil** (date parsing for KQL time ranges).
  547. ---
  548. ## 🔒 Security Considerations
  549. 1. **Confidential Data** — Reports contain PII and sensitive security data. Mark as CONFIDENTIAL and follow organizational data classification policies.
  550. 2. **Access Control** — Restrict access to authorized SOC personnel. Use Azure RBAC for Sentinel, PIM for Graph API permissions.
  551. 3. **Audit Trail** — All investigations are timestamped. JSON files in `temp/` preserve snapshots; HTML reports include generation metadata.
  552. 4. **Data Retention** — Investigations older than 3 days are auto-deleted (configurable). Archive important investigations before cleanup.
  553. 5. **API Token Security** — Never commit `config.json` with tokens (already in `.gitignore`). Use environment variables or Azure Key Vault for production.
  554. 6. **Investigation JSON Files** — Stored in `temp/` (not committed to Git). Contain complete data including IP enrichment. Can be re-analyzed without re-querying.
  555. ---
  556. ## 🛠️ Troubleshooting
  557. | Issue | Solution |
  558. |-------|----------|
  559. | **"No anomalies found"** | `Signinlogs_Anomalies_KQL_CL` table doesn't exist or has no data. See user-investigation skill docs. Wait 24h for initial population. |
  560. | **"IP enrichment failed"** | ipinfo.io rate limits (1K/day free). Add token to `config.json` for 50K/month. |
  561. | **"MCP server not available"** | Check VS Code MCP server config. Verify authentication tokens are valid. |
  562. | **"User ID not found" (Graph)** | Verify UPN is correct. Check Graph permissions: User.Read.All. |
  563. | **"Sentinel query timeout"** | Reduce date range. Add `\| take 10` to limit results. |
  564. | **Report generation fails** | Validate JSON: `python -m json.tool temp/investigation_*.json`. Check required fields. |
  565. | **SecurityIncident returns 0 results** | Use BOTH `targetUPN` and `targetUserId` (Object ID). Some incidents use Object ID. |
  566. | **Risky sign-ins 404** | Must use `/beta` endpoint, not `/v1.0`. |
  567. ### Verify Connectivity
  568. In **Copilot Chat** (Agent mode):
  569. - `"List my Sentinel workspaces"` — verifies Sentinel Data Lake MCP
  570. - `"Look up user@domain.com in Graph"` — verifies Graph MCP
  571. - `"List recent incidents"` — verifies Sentinel Triage MCP
  572. In **terminal**:
  573. ```powershell
  574. python enrich_ips.py 8.8.8.8 # Verifies IP enrichment API tokens
  575. ```
  576. ---
  577. ## 🧠 (Optional) Persistent Tenant Context
  578. GitHub Copilot Chat in VS Code provides agents with a **`memory` tool** — a built-in filesystem (`/memories/`) for persisting notes across conversations. Copilot already uses this internally; you can extend it with tenant-specific context (known infrastructure IPs, validated personnel, false-positive patterns, lab automation signatures) so investigations don't repeatedly mis-classify documented activity as 🔴 critical.
  579. Two memory tiers are relevant:
  580. | Tier | Path | Auto-loaded? | Use for |
  581. |---|---|---|---|
  582. | **User memory** | `/memories/*.md` | ✅ Yes (~200 lines) | Short trigger rules ("when you see tenant X, read repo file Y") |
  583. | **Repo memory** | `/memories/repo/*.md` | ❌ Filenames only | Rich tenant context (IPs, personnel, FP patterns) — pulled in by trigger rules |
  584. > The memory tool is an internal agent capability — VS Code does not publish a dedicated docs page for it. Closest related concepts are [custom instructions](https://code.visualstudio.com/docs/copilot/customization/custom-instructions) and [Agent Skills](https://code.visualstudio.com/docs/copilot/customization/agent-skills), which serve different purposes (always-applied conventions and specialized workflows, respectively).
  585. **This workspace ships with:**
  586. - **Templates** in [`notes/memory/examples/`](notes/memory/examples/) — copy and adapt for your tenant (one user-tier example, two repo-tier examples)
  587. - **Sync script** [`scripts/sync-repo-memory.ps1`](scripts/sync-repo-memory.ps1) — backs up workspace-scoped (`repo`) memory from VS Code AppData into the workspace folder, surviving VS Code reinstall and workspace rename. Any cloud sync attached to your workspace (OneDrive, Dropbox, iCloud, etc.) then mirrors the backup across machines. Defaults to one-way export (`ToBackup`); restore mode (`FromBackup`) requires `-Force` because it writes into Copilot's trusted memory store.
  588. - **Setup guide** [`notes/memory/README.md`](notes/memory/README.md) — full walkthrough, sync usage, security model, and the trigger-rule pattern that makes Copilot actually consult repo memory
  589. **Quickstart:** Open a template from `notes/memory/examples/`, then ask Copilot in chat to *"create this as a memory file at `/memories/...`, replacing placeholders with my tenant values."* Copilot uses its `memory` tool to write it directly — no AppData path navigation needed.
  590. **🎛️ From Mission Control (Copilot app):** The **Mission Control** canvas surfaces the whole memory loop as one-click actions in its **Findings** tab — no manual path navigation or prompt-writing:
  591. - **⚙️ Set memory file** — names your tenant context-memory file (under `.copilot/memories/repo/`) and saves it to `config.json`. The memory features work on first run with a sensible per-tenant default even before you customize it.
  592. - **🧠 Use memory** — prepends a directive to every investigation you launch, telling the agent to consult the context-memory file — searching it for the task's specific entities rather than reading it in full — and apply its documented ground truth (known-good IPs, automation fingerprints, account classifications, false-positive rules) *before* rendering a verdict.
  593. - **🧠 Compact to memory** — hands the agent a propose-only prompt (via the [`context-memory-review`](/.github/skills/context-memory-review/SKILL.md) skill) that distills accumulated findings into candidate ADD / MODIFY / FLAG changes for the memory file, for human approval. Offered again before you clear findings, so evidence is preserved.
  594. Together these close the loop: findings recorded in the canvas → compacted into tenant memory → applied automatically on the next investigation.
  595. > ⚠️ **Memory = trusted input.** Anything in `notes/memory/repo/` becomes authoritative instructions for Copilot in every future chat (with MCP tool access to Sentinel, Graph, Azure). Review diffs from forks/PRs before restoring, never paste secrets, and if your workspace is cloud-synced, confirm the destination is acceptable for security context. See [`notes/memory/README.md`](notes/memory/README.md#%EF%B8%8F-security-memory-is-trusted-input) for the full threat model.
  596. ---
  597. ## 📄 License
  598. This project is licensed under the [MIT License](LICENSE). Use it, fork it, adapt it for your SOC — just keep the copyright notice.
  599. ---
  600. ## 🙏 Acknowledgments
  601. ### Microsoft Security Platform
  602. - **[Microsoft Sentinel](https://learn.microsoft.com/en-us/azure/sentinel/)** — SIEM/SOAR platform powering all KQL queries and incident management
  603. - **[Microsoft Defender XDR](https://learn.microsoft.com/en-us/defender-xdr/)** — Advanced Hunting, device telemetry, vulnerability management
  604. - **[Microsoft Graph API](https://learn.microsoft.com/en-us/graph/)** — Entra ID identity data, user/group management, role assignments
  605. - **[Microsoft Entra ID Protection](https://learn.microsoft.com/en-us/entra/id-protection/)** — Risk detections, risky sign-ins, user risk states
  606. ### MCP Servers
  607. - **[Sentinel Data Lake MCP](https://learn.microsoft.com/en-us/azure/sentinel/datalake/)** — KQL query execution against Sentinel workspace
  608. - **[Sentinel Triage MCP](https://learn.microsoft.com/en-us/azure/sentinel/datalake/sentinel-mcp-triage-tool)** — Incident triage, Advanced Hunting, Defender entity APIs
  609. - **[MCP Server for Microsoft Graph](https://github.com/nicholasgasior/mcp-server-microsoft-graph)** — Graph API endpoint discovery and execution
  610. - **[KQL Search MCP](https://www.npmjs.com/package/kql-search-mcp)** — Schema intelligence, GitHub KQL query discovery, ASIM validation
  611. - **[Microsoft Learn MCP](https://learn.microsoft.com/en-us/training/support/mcp-get-started)** — Official documentation search and code sample retrieval
  612. ### Threat Intelligence APIs
  613. - **[ipinfo.io](https://ipinfo.io/)** — IP geolocation, ISP/ASN identification, hosting provider detection
  614. - **[vpnapi.io](https://vpnapi.io/)** — VPN, proxy, Tor exit node, and relay detection
  615. - **[AbuseIPDB](https://www.abuseipdb.com/)** — Community-sourced IP abuse scoring and recent attack reports
  616. - **[Shodan](https://www.shodan.io/)** — Open port enumeration, service/banner detection, CVE identification, infrastructure tagging
  617. ### Development Tools
  618. - **[GitHub Copilot](https://github.com/features/copilot)** — AI coding assistant powering the natural language investigation interface
  619. - **[VS Code Agent Skills](https://code.visualstudio.com/docs/copilot/customization/agent-skills)** — Modular skill framework for specialized investigation workflows
  620. - **[Model Context Protocol (MCP)](https://modelcontextprotocol.io/)** — Open protocol connecting LLMs to external data sources and tools
  621. Special thanks to the Microsoft Security community for sharing KQL queries and detection logic, and to [stefanpems](https://github.com/stefanpems/mcp-add-comment-to-sentinel-incident) for the Sentinel incident commenting MCP pattern.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.