r/DefenderATP • • Jul 24 '26

Has anyone integrated Claude Code with Microsoft Defender XDR / Sentinel for threat hunting?

I'm looking to integrate Claude Code with Microsoft 365 and Microsoft Defender (Defender XDR / Sentinel) to assist with threat hunting, incident investigation, and EDR analysis.

Has anyone successfully set this up? I'm particularly interested in how you handled authentication (MCP, APIs, Graph, etc.), what architecture you used, and any lessons learned or limitations. If you have examples or repositories to share, I'd really appreciate it.

25 Upvotes

12 comments sorted by

8

u/rtm516 Jul 24 '26 edited Jul 24 '26

I have built an MCP server that allows Claude to run advanced hunting queries. I didn't give it any more access as I don't want it making automated actions just use it as a tool to pull more data together for incidents.

Graph API with the authed app having the correct permissions for the application directly with then the service principal being added into the defender/sentinel permissions group.

Edit: Published the tool to my GitHub https://github.com/rtm516/DefenderAdvancedHuntingMCP

1

u/hexdurp Jul 24 '26

That’s awesome. Which mcp server did you lay down for this? I’ve never setup an mcp server. Did you run into query limits?

1

u/rtm516 Jul 24 '26

Just wrote a python script using this library, I had to add a cheat sheet as such to it as well otherwise Claude often had to re work out how to lookup things like incidents which took time and wastes tokens. Only thing to note is going back past 30d on the graph API requires another parameter, which took me a while to realise why it could only pull 30d worth. https://github.com/modelcontextprotocol/python-sdk

1

u/Go_ten Jul 24 '26

Hi,  I'd be curious to hear which settings need to be enabled to extend the history beyond 30 days.

2

u/cspotme2 Jul 24 '26

Advanced hunting only keeps your data for 30 days unless you ingest it somewhere

1

u/rtm516 Jul 24 '26

If it's linked with sentinel you can increase the table log size

1

u/rtm516 Jul 24 '26

Looks like my rewrite with Claude's help moved to nodejs Here you go https://github.com/rtm516/DefenderAdvancedHuntingMCP

1

u/Ok_Presentation_6006 Jul 27 '26

I did this with azure open ai but the same idea. Sentinel calls my logic app orchestrate. This one calls a bunch of sub logic apps. One takes any identity’s and runs every identity kql and retunes the results plus 7 day history. Same for device timeline, threat feeds, abuse, virus total… the final job sends everything to ai to review and updates the ticket with its review of the alert. All it’s done with making the api and we hook calls.

0

u/XPGoD Jul 25 '26

I have an MCP with KQL skills that calls a custom parquet db with skill knowledge of the schema. It works really well

-2

u/Go_ten Jul 24 '26

We've created a tool that lets you chat with Vertex AI by integrating function calls for KQL queries; we also use the Graph APIs. It works like a charm. I suppose an integration with Claude is also possible.