Connect Microsoft Defender to ChatGPT: Resolve Alerts & Triage
Learn how to connect Microsoft Defender to ChatGPT using Truto's SuperAI MCP server. Automate alert triage, machine isolation, and SOC workflows.
If you want to connect Microsoft Defender to ChatGPT so your AI agents can autonomously triage security alerts, isolate compromised machines, and analyze file threats in real time, you need a Model Context Protocol (MCP) server. This server translates ChatGPT's JSON-RPC tool calls into authenticated, schema-compliant Microsoft Defender API requests.
If your team uses Claude, check out our guide on connecting Microsoft Defender to Claude or explore our broader architectural overview on connecting Microsoft Defender to AI Agents.
Giving a Large Language Model (LLM) read and write access to an enterprise Extended Detection and Response (XDR) platform is a massive engineering undertaking. You have to handle complex RBAC (Role-Based Access Control) requirements, map deeply nested OData responses to MCP tool definitions, and safely expose destructive actions like machine isolation. You can either spend weeks building and maintaining a custom MCP server, or use a managed integration infrastructure layer like Truto to dynamically generate a secure, authenticated MCP server URL.
This guide breaks down exactly how to use Truto to generate a secure MCP server for Microsoft Defender, connect it natively to ChatGPT, and execute complex Security Operations Center (SOC) workflows using natural language.
Microsoft Defender to ChatGPT Quickstart Guide
If you just want the fastest path from a fresh Truto account to ChatGPT calling the Microsoft Defender API, follow these steps. We cover both UI and API-driven workflows.
What you need:
- A Truto account with API access.
- A Microsoft 365 / Azure AD administrator who can approve the OAuth consent for Defender API scopes.
- A ChatGPT Pro, Plus, Business, Enterprise, or Education seat with Developer mode enabled.
Step 1: Connect Microsoft Defender to Truto
In the Truto dashboard, navigate to Integrated Accounts -> New Integrated Account, select Microsoft Defender, and run the OAuth flow. Truto securely stores the refresh token and automatically refreshes access tokens before they expire, ensuring ChatGPT never drops a session due to an expired credential.
Grab your integrated_account_id. You can copy it from the account detail page or list it via the API:
curl https://api.truto.one/integrated-account \
-H "Authorization: Bearer $TRUTO_API_TOKEN"Step 2: Create the MCP Server
Truto dynamically generates MCP tools based on the available Defender API endpoints. You can create the MCP server URL via the UI or the API.
Method A: Via the Truto UI
- Navigate to the integrated account page for your Microsoft Defender connection.
- Click the MCP Servers tab.
- Click Create MCP Server.
- Select the desired configuration (name, allowed methods like
readorwrite, and specific tool tags likealertsormachines). - Copy the generated MCP server URL (e.g.,
https://api.truto.one/mcp/<token>).
Method B: Via the Truto API
Make a single POST request to scope an MCP endpoint strictly to this integrated account. You can filter by methods and tags to heavily constrain what ChatGPT is allowed to do:
curl -X POST https://api.truto.one/integrated-account/$INTEGRATED_ACCOUNT_ID/mcp \
-H "Authorization: Bearer $TRUTO_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Defender SOC Agent",
"config": {
"methods": ["read", "write", "custom"],
"tags": ["alerts", "machines", "files"]
}
}'The response contains a url field. That single URL handles routing, tool generation, and authentication - treat it as a sensitive secret.
Step 3: Connect the MCP Server to ChatGPT
Now, point ChatGPT to the Truto MCP URL.
Method A: Via the ChatGPT UI
- In ChatGPT, go to Settings -> Apps -> Advanced settings.
- Enable Developer mode.
- Under MCP servers / Custom connectors, click to add a new server.
- Name: "Microsoft Defender (Truto)"
- Server URL: Paste the
https://api.truto.one/mcp/<token>URL you copied in Step 2. - Click Add and save. ChatGPT will instantly connect, perform the MCP handshake, and list the available Defender tools.
Method B: Via Manual Config File If you are using a local agent framework or standardizing configurations via Claude Desktop, Cursor, or a local ChatGPT integration wrapper, you can define the MCP connection via a JSON configuration using Server-Sent Events (SSE):
{
"mcpServers": {
"microsoft-defender": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-sse",
"--url",
"https://api.truto.one/mcp/<your_token>"
]
}
}
}The Engineering Reality of the Microsoft Defender API
Building an MCP server is rarely just a matter of wrapping a REST API. Enterprise APIs - specifically security products like Microsoft Defender - have rigid, complex architectures that break naive tool generation. If you build this in-house, here is the reality of what you have to manage.
Delegated vs. Application Permission Granularity
The Microsoft Graph and Defender APIs enforce strict separation between Delegated (user context) and Application (service context) permissions. An LLM might be able to list alerts using basic Application permissions, but executing an active response - like microsoft_defender_machines_isolate - often requires highly specific Delegated permissions (e.g., Machine.Isolate). A custom MCP server must flawlessly handle this context mapping. Truto abstracts this by leveraging the underlying integrated account's OAuth scope logic, ensuring the MCP server only exposes tools the connected credential is actually authorized to execute.
Rate Limits and Pagination Strictness
Security APIs are heavily throttled to prevent abuse. When an LLM aggressively loops through paginated alerts, it will inevitably hit a rate limit.
Factual note on rate limits: Truto does not retry, throttle, or apply backoff on rate limit errors. When the upstream Microsoft Defender API returns an HTTP 429 Too Many Requests, Truto passes that error directly to the caller. However, Truto normalizes the upstream rate limit information into standardized headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset) per the IETF specification. The caller (your LLM framework or custom orchestration code) is strictly responsible for interpreting these headers and executing retry or exponential backoff logic.
Entity Graph Complexity
An "Alert" in Defender is not a standalone object; it is deeply tied to a Machine, a User, and often a Domain or File. LLMs struggle to infer relationship IDs unless the tool schema explicitly defines the required parameters. The proxy layer must flatten these relationships or provide heavily annotated JSON Schemas to prevent the model from hallucinating UUIDs.
Hero Tools for Microsoft Defender
By dynamically parsing the Microsoft Defender API documentation, Truto generates deterministic JSON Schemas for every endpoint. Here are the highest-leverage tools you can expose to ChatGPT for SOC automation.
List All Microsoft Defender Alerts
Retrieves a paginated collection of active security alerts. This is the entry point for automated triage, allowing the LLM to identify high-severity incidents that require immediate attention.
Contextual usage: Best used with query parameters to filter by severity or status to avoid overwhelming the context window.
"Fetch all high-severity open alerts from Microsoft Defender from the last 24 hours."
Get Single Microsoft Defender Machine By ID
Retrieves detailed device context related to a specific alert or machine ID, including OS version, health state, and network configuration.
Contextual usage: Crucial for enrichment. Once the LLM identifies an alert, it needs this tool to understand the blast radius of the affected endpoint.
"Get the machine details for device ID '1a2b3c4d-5678-90ab-cdef-1234567890ab' and summarize its current risk score."
Analyze File Statistics
Retrieves global statistics and prevalence data for a given file hash (SHA1 or SHA256) across the organization.
Contextual usage: Used by the LLM to determine if a flagged file is a rare, targeted executable or a widely distributed artifact.
"Check the Defender file statistics for the SHA256 hash 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'."
Isolate Compromised Machine
Executes an active response action to isolate a device from the external network while maintaining connectivity to the Defender service for forensics.
Contextual usage: This is a highly destructive operation. Use Truto's method filtering (require_api_token_auth) or Human-in-the-Loop patterns in your agent framework before allowing the LLM to call this.
"Isolate the machine with ID '1a2b3c4d' from the network immediately. Add the comment: 'Automated containment due to confirmed ransomware behavior'."
Initiate AV Scan
Initiates a Microsoft Defender Antivirus scan on a specific device.
Contextual usage: A low-risk active response. The LLM can automatically trigger a Quick or Full scan on devices exhibiting suspicious behavior before waking up an on-call analyst.
"Run a quick antivirus scan on the machine associated with alert ID '654321' and log the action."
Update Alert Status
Updates the properties of an existing alert, such as assigning it to an analyst, changing its status to 'Resolved', or updating its classification.
Contextual usage: Closes the loop. Once the LLM finishes investigating and isolating, it uses this tool to document the findings directly in the Defender console.
"Resolve alert '654321' as a True Positive, assign it to me, and add a comment that the machine has been isolated."
To view the complete list of available operations, required parameters, and schemas, visit the Microsoft Defender integration page.
Workflows in Action
Connecting these tools transforms ChatGPT from a simple chat interface into an active SOC orchestrator. Here are two concrete workflows you can execute today.
Scenario 1: Automated Alert Triage & Machine Isolation
Persona: Tier 1 SOC Analyst / Incident Responder
When a high-severity alert fires in the middle of the night, time to containment is critical. Instead of logging into the Defender portal, cross-referencing IPs, and manually clicking 'Isolate', the analyst can direct ChatGPT to investigate and act.
"Look up the details for alert ID '987654'. If the alert involves a malicious file execution, get the machine details, isolate the machine from the network, and update the alert status to 'In Progress'."
Execution Steps:
get_single_microsoft_defender_alert_by_id: ChatGPT fetches the alert payload to confirm the trigger was a malicious file execution.get_single_microsoft_defender_alert_machine_by_id: ChatGPT extracts themachineIdfrom the alert and fetches the device context to ensure it is online and managed.microsoft_defender_machines_isolate: ChatGPT calls the isolation tool, passing themachineIdand a system-generated comment.update_a_microsoft_defender_alert_by_id: ChatGPT modifies the alert state, assigning it to the SOC queue for morning review.
sequenceDiagram
participant User as SOC Analyst
participant ChatGPT as ChatGPT (MCP Client)
participant Truto as Truto MCP Server
participant Upstream as Microsoft Defender API
User->>ChatGPT: "Investigate alert 987654..."
ChatGPT->>Truto: Call get_single_microsoft_defender_alert_by_id
Truto->>Upstream: GET /alerts/987654
Upstream-->>Truto: Alert Payload
Truto-->>ChatGPT: JSON result
ChatGPT->>Truto: Call microsoft_defender_machines_isolate
Truto->>Upstream: POST /machines/{id}/isolate
Upstream-->>Truto: 201 Created (Action queued)
Truto-->>ChatGPT: JSON result
ChatGPT->>Truto: Call update_a_microsoft_defender_alert_by_id
Truto->>Upstream: PATCH /alerts/987654
Upstream-->>Truto: 200 OK
Truto-->>ChatGPT: JSON result
ChatGPT-->>User: "Machine isolated. Alert updated."Scenario 2: Malicious File Investigation & Active Scanning
Persona: Threat Hunter
A threat hunter wants to know how widespread a specific payload is across the environment and actively remediate it without writing PowerShell scripts.
"Check our environment for file hash 'e3b0c442...'. Tell me how many machines have seen it. For every machine that has seen this file, initiate a full antivirus scan."
Execution Steps:
list_all_microsoft_defender_file_machines: ChatGPT queries Defender for all devices that have reported the specific file hash.- Reasoning loop: ChatGPT parses the list of returned
machineIds. microsoft_defender_machines_run_antivirus_scan: ChatGPT iterates over themachineIds, calling the scan tool for each device withScanTypeset toFull.
Outcome: The LLM returns a summarized list of the affected machines and confirms that full AV scans have been successfully queued for each endpoint.
Security and Access Control
Giving an LLM write-access to your endpoint security infrastructure requires rigid guardrails. Truto's MCP architecture provides several layers of access control out of the box:
- Method Filtering: When generating the MCP server, you can configure
methods: ["read"]. This hardcodes the server to only exposeGETandLISToperations, guaranteeing ChatGPT cannot mutate data or isolate machines. - Tag Filtering: You can restrict the server to specific resource tags. For example,
tags: ["alerts", "investigations"]ensures the LLM cannot access or list vulnerable software inventories. - Require API Token Auth: By setting
require_api_token_auth: true, possession of the MCP URL is no longer enough. The client (ChatGPT or custom framework) must pass a valid Truto API token via theAuthorizationheader, adding a critical second layer of authentication. - Server Expiration: You can set an
expires_atISO datetime when creating the MCP server. Truto's infrastructure enforces this time-to-live natively; once expired, the server URL becomes permanently invalid, which is perfect for temporary contractor access or limited-time incident response bridges.
Moving Forward
Building a reliable, secure connection between ChatGPT and Microsoft Defender is not about formatting JSON - it is about managing OAuth lifecycles, understanding complex security API schemas, and architecting strict access controls.
By leveraging Truto's dynamically generated MCP servers, you bypass the boilerplate of building custom integration infrastructure. Your SOC analysts get immediate natural-language access to endpoint data, and your engineering team gets to focus on core product value instead of maintaining API connector code.
Ready to equip your AI agents with enterprise-grade tools? Book a demo with our engineering team today.
FAQ
- How do I connect Microsoft Defender to ChatGPT?
- You can connect Microsoft Defender to ChatGPT by generating a Model Context Protocol (MCP) server URL using Truto, and then adding that URL to ChatGPT's custom connectors under Developer settings.
- Can ChatGPT isolate machines in Microsoft Defender?
- Yes. By exposing the 'Isolate Compromised Machine' tool through an MCP server, ChatGPT can issue the command to isolate endpoints. We strongly recommend using Truto's method filtering or human-in-the-loop approvals for destructive actions.
- How does Truto handle Microsoft Defender rate limits?
- Truto passes HTTP 429 Too Many Requests errors directly back to the caller while normalizing the rate limit data into standard IETF headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset). Your LLM orchestrator is responsible for handling retries and backoff.
- Does Truto store Microsoft Defender alert data?
- No. Truto uses a zero-data-retention, pass-through architecture. Data fetched from Microsoft Defender is routed directly to ChatGPT without being stored at rest.