Deploy Agent Monitor with Microsoft Intune
Push managed hooks configuration through Microsoft Intune so macOS and Windows devices send AI coding agent activity to the MintMCP dashboard (no plugin required).
Requirements
- A MintMCP org key (see Find your org key).
- Devices enrolled in Intune. macOS scripts also need the Intune management agent, which installs automatically the first time you assign a shell script. Windows scripts need the device to be Microsoft Entra joined or hybrid joined; the Intune Management Extension installs automatically the first time you assign a script.
- No existing managed hooks file on devices — these scripts create it fresh and overwrite any prior version.
Find your org key
Go to Agent Monitor setup. Your org key starts with llmorgkey_.
macOS
Prepare the script
Paste your org key from Agent Monitor setup — the script updates automatically so you can copy it ready to go.
- Claude Code
- Cursor
#!/bin/bash
# Agent Monitor — Intune shell script (Claude Code, macOS)
# Writes managed-settings.json with native HTTP hooks for MintMCP.
set -euo pipefail
ORG_KEY="YOUR_ORG_KEY_HERE"
if [[ ! "$ORG_KEY" =~ ^llmorgkey_ ]]; then
echo "[AgentMonitor] ERROR: ORG_KEY not set. Edit the script and replace YOUR_ORG_KEY_HERE with your MintMCP org key."
exit 1
fi
TARGET_DIR="/Library/Application Support/ClaudeCode"
SETTINGS_FILE="${TARGET_DIR}/managed-settings.json"
mkdir -p "$TARGET_DIR"
cat > "$SETTINGS_FILE" <<JSON
{
"env": {
"MINTMCP_ORG_KEY": "${ORG_KEY}"
},
"hooks": {
"PreToolUse": [
{
"matcher": ".*",
"hooks": [
{
"type": "http",
"url": "https://app.mintmcp.com/hooks/claudecode",
"headers": {
"X-MINTMCP-ORG-KEY": "\$MINTMCP_ORG_KEY",
"X-MINTMCP-USER": "\$USER"
},
"allowedEnvVars": [
"MINTMCP_ORG_KEY",
"USER"
]
}
]
}
],
"PostToolUse": [
{
"matcher": ".*",
"hooks": [
{
"type": "http",
"url": "https://app.mintmcp.com/hooks/claudecode",
"headers": {
"X-MINTMCP-ORG-KEY": "\$MINTMCP_ORG_KEY",
"X-MINTMCP-USER": "\$USER"
},
"allowedEnvVars": [
"MINTMCP_ORG_KEY",
"USER"
]
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "http",
"url": "https://app.mintmcp.com/hooks/claudecode",
"headers": {
"X-MINTMCP-ORG-KEY": "\$MINTMCP_ORG_KEY",
"X-MINTMCP-USER": "\$USER"
},
"allowedEnvVars": [
"MINTMCP_ORG_KEY",
"USER"
]
}
]
}
]
}
}
JSON
/bin/chmod 0644 "$SETTINGS_FILE"
/usr/sbin/chown root:wheel "$SETTINGS_FILE"
echo "[AgentMonitor] Created ${SETTINGS_FILE} with MintMCP hooks enabled"#!/bin/bash
# Agent Monitor — Intune shell script (Cursor, macOS)
# Writes hooks.json and mint.sh for MintMCP.
set -euo pipefail
ORG_KEY="YOUR_ORG_KEY_HERE"
if [[ ! "$ORG_KEY" =~ ^llmorgkey_ ]]; then
echo "[AgentMonitor] ERROR: ORG_KEY not set. Edit the script and replace YOUR_ORG_KEY_HERE with your MintMCP org key."
exit 1
fi
TARGET_DIR="/Library/Application Support/Cursor"
HOOKS_FILE="${TARGET_DIR}/hooks.json"
SCRIPT_FILE="${TARGET_DIR}/mint.sh"
mkdir -p "$TARGET_DIR"
# Write hooks.json
cat > "$HOOKS_FILE" <<'HOOKS'
{
"version": 1,
"hooks": {
"beforeSubmitPrompt":
[ {"command": "sh /Library/Application Support/Cursor/mint.sh"} ],
"beforeShellExecution":
[ {"command": "sh /Library/Application Support/Cursor/mint.sh"} ],
"beforeMCPExecution":
[ {"command": "sh /Library/Application Support/Cursor/mint.sh"} ],
"beforeReadFile":
[ {"command": "sh /Library/Application Support/Cursor/mint.sh"} ],
"afterShellExecution":
[ {"command": "sh /Library/Application Support/Cursor/mint.sh"} ],
"afterMCPExecution":
[ {"command": "sh /Library/Application Support/Cursor/mint.sh"} ],
"afterAgentResponse":
[ {"command": "sh /Library/Application Support/Cursor/mint.sh"} ]
}
}
HOOKS
# Write mint.sh
cat > "$SCRIPT_FILE" <<SCRIPT
#!/bin/sh
MINTMCP_USER=\${MINTMCP_USER:-\$USER}
URL="https://app.mintmcp.com/h/${ORG_KEY},\${MINTMCP_USER}/cursor"
json_input=\$(cat)
if resp=\$(curl -sS --fail-with-body -H "Content-Type: application/json" -d "\$json_input" "\$URL"); then
printf '%s' "\$resp"
else
status=\$?
printf '%s' "\$resp" >&2
exit \$status
fi
exit 0
SCRIPT
/bin/chmod 0644 "$HOOKS_FILE"
/bin/chmod 0755 "$SCRIPT_FILE"
/usr/sbin/chown root:wheel "$HOOKS_FILE"
/usr/sbin/chown root:wheel "$SCRIPT_FILE"
echo "[AgentMonitor] Created ${HOOKS_FILE} and ${SCRIPT_FILE} with MintMCP hooks enabled"Add the script to Intune
- In the Microsoft Intune admin center, go to Devices > Scripts and remediations > Platform scripts (you can also reach the same flow from Devices > By platform > macOS > Shell scripts).
- Click Add > macOS.
- Name it "MintMCP Agent Monitor Hooks (macOS)" and click Next.
- Paste the script (with your org key filled in) into the Script field, then set:
- Run script as signed-in user: No — the script runs as root, which it needs to write to
/Library/Application Support. - Script frequency: Not configured — runs once per device.
- Max number of times to retry if script fails: 3 (optional).
- Run script as signed-in user: No — the script runs as root, which it needs to write to
- Assign it to the device groups running Claude Code or Cursor, then click Review + save.
Intune picks up the script on the agent's next check-in (roughly every 8 hours). The macOS device must be on macOS 12 or later.
Windows
Prepare the script
Paste your org key — the script updates automatically so you can copy it ready to go.
- Claude Code
- Cursor
#Requires -Version 5
# Agent Monitor — Intune platform script (Claude Code, Windows)
# Writes managed-settings.json with native HTTP hooks for MintMCP.
$ErrorActionPreference = "Stop"
$OrgKey = "YOUR_ORG_KEY_HERE"
if ($OrgKey -notmatch '^llmorgkey_') {
Write-Error "[AgentMonitor] ORG_KEY not set. Edit the script and replace YOUR_ORG_KEY_HERE with your MintMCP org key."
exit 1
}
$TargetDir = "C:/Program Files/ClaudeCode"
$SettingsFile = "$TargetDir/managed-settings.json"
New-Item -ItemType Directory -Force -Path $TargetDir | Out-Null
$Settings = @'
{
"env": {
"MINTMCP_ORG_KEY": "__ORG_KEY__"
},
"hooks": {
"PreToolUse": [
{
"matcher": ".*",
"hooks": [
{
"type": "http",
"url": "https://app.mintmcp.com/hooks/claudecode",
"headers": {
"X-MINTMCP-ORG-KEY": "$MINTMCP_ORG_KEY",
"X-MINTMCP-USER": "$USERNAME"
},
"allowedEnvVars": ["MINTMCP_ORG_KEY", "USERNAME"]
}
]
}
],
"PostToolUse": [
{
"matcher": ".*",
"hooks": [
{
"type": "http",
"url": "https://app.mintmcp.com/hooks/claudecode",
"headers": {
"X-MINTMCP-ORG-KEY": "$MINTMCP_ORG_KEY",
"X-MINTMCP-USER": "$USERNAME"
},
"allowedEnvVars": ["MINTMCP_ORG_KEY", "USERNAME"]
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "http",
"url": "https://app.mintmcp.com/hooks/claudecode",
"headers": {
"X-MINTMCP-ORG-KEY": "$MINTMCP_ORG_KEY",
"X-MINTMCP-USER": "$USERNAME"
},
"allowedEnvVars": ["MINTMCP_ORG_KEY", "USERNAME"]
}
]
}
]
}
}
'@
$Settings = $Settings.Replace("__ORG_KEY__", $OrgKey)
[System.IO.File]::WriteAllText($SettingsFile, $Settings)
Write-Output "[AgentMonitor] Created $SettingsFile with MintMCP hooks enabled"#Requires -Version 5
# Agent Monitor — Intune platform script (Cursor, Windows)
# Writes hooks.json and mint.ps1 for MintMCP.
$ErrorActionPreference = "Stop"
$OrgKey = "YOUR_ORG_KEY_HERE"
if ($OrgKey -notmatch '^llmorgkey_') {
Write-Error "[AgentMonitor] ORG_KEY not set. Edit the script and replace YOUR_ORG_KEY_HERE with your MintMCP org key."
exit 1
}
$TargetDir = "C:/ProgramData/Cursor"
New-Item -ItemType Directory -Force -Path $TargetDir | Out-Null
$Hooks = @'
{
"version": 1,
"hooks": {
"beforeSubmitPrompt": [ {"command": "powershell -NoProfile -ExecutionPolicy Bypass -File C:/ProgramData/Cursor/mint.ps1"} ],
"beforeShellExecution": [ {"command": "powershell -NoProfile -ExecutionPolicy Bypass -File C:/ProgramData/Cursor/mint.ps1"} ],
"beforeMCPExecution": [ {"command": "powershell -NoProfile -ExecutionPolicy Bypass -File C:/ProgramData/Cursor/mint.ps1"} ],
"beforeReadFile": [ {"command": "powershell -NoProfile -ExecutionPolicy Bypass -File C:/ProgramData/Cursor/mint.ps1"} ],
"afterShellExecution": [ {"command": "powershell -NoProfile -ExecutionPolicy Bypass -File C:/ProgramData/Cursor/mint.ps1"} ],
"afterMCPExecution": [ {"command": "powershell -NoProfile -ExecutionPolicy Bypass -File C:/ProgramData/Cursor/mint.ps1"} ],
"afterAgentResponse": [ {"command": "powershell -NoProfile -ExecutionPolicy Bypass -File C:/ProgramData/Cursor/mint.ps1"} ]
}
}
'@
$Script = @'
$OrgKey = "__ORG_KEY__"
$MintUser = if ($env:MINTMCP_USER) { $env:MINTMCP_USER } else { $env:USERNAME }
$Url = "https://app.mintmcp.com/h/$OrgKey,$MintUser/cursor"
$JsonInput = [Console]::In.ReadToEnd()
try {
$resp = Invoke-WebRequest -UseBasicParsing -Method Post -Uri $Url -ContentType "application/json" -Body $JsonInput
[Console]::Out.Write($resp.Content)
} catch {
if ($_.Exception.Response) {
$reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())
[Console]::Error.Write($reader.ReadToEnd())
} else {
[Console]::Error.Write($_.Exception.Message)
}
exit 1
}
exit 0
'@
$Script = $Script.Replace("__ORG_KEY__", $OrgKey)
[System.IO.File]::WriteAllText("$TargetDir/hooks.json", $Hooks)
[System.IO.File]::WriteAllText("$TargetDir/mint.ps1", $Script)
Write-Output "[AgentMonitor] Created $TargetDir/hooks.json and $TargetDir/mint.ps1 with MintMCP hooks enabled"Add the script to Intune
- In the Microsoft Intune admin center, go to Devices > Scripts and remediations > Platform scripts.
- Click Add > Windows 10 and later.
- Name it "MintMCP Agent Monitor Hooks (Windows)" and click Next.
- Paste the script (with your org key filled in) into the PowerShell script field, then set:
- Run this script using the logged on credentials: No — the script runs as SYSTEM, which it needs to write to
C:\Program FilesandC:\ProgramData. - Enforce script signature check: No.
- Run script in 64-bit PowerShell host: Yes.
- Run this script using the logged on credentials: No — the script runs as SYSTEM, which it needs to write to
- Assign it to the device groups running Claude Code or Cursor, then click Review + add.
The Intune Management Extension runs the script once on the next check-in. If it fails, the extension retries on the next three check-ins.
Keep the file enforced with Remediations
A platform script runs once and doesn't re-apply if a user deletes the file. To enforce the configuration over time, repackage the same logic as a Remediation (Devices > Scripts and remediations > Create script package): a detection script that exits 1 when the file is missing or wrong, plus a remediation script that rewrites it, scheduled daily. Remediations require Windows Enterprise E3 or E5 (or Education A3/A5, or VDA) licensing.
Validate on a test device
Confirm the files exist and contents look correct.
- macOS
- Windows
# Claude Code
cat "/Library/Application Support/ClaudeCode/managed-settings.json"
# Cursor
cat "/Library/Application Support/Cursor/hooks.json"
cat "/Library/Application Support/Cursor/mint.sh"
# Claude Code
Get-Content "C:\Program Files\ClaudeCode\managed-settings.json"
# Cursor
Get-Content "C:\ProgramData\Cursor\hooks.json"
Get-Content "C:\ProgramData\Cursor\mint.ps1"
Launch the client and perform some actions. Verify activity appears in MintMCP Agent Monitor.
Hook events captured
- Claude Code
- Cursor
| Hook | Description |
|---|---|
PreToolUse | Fired before any tool execution (Bash, Edit, Write, etc.) |
PostToolUse | Fired after any tool execution completes |
UserPromptSubmit | Fired when the user submits a prompt |
| Hook | Description |
|---|---|
beforeSubmitPrompt | Fired when the user submits a prompt |
beforeShellExecution | Fired before a shell command runs |
afterShellExecution | Fired after a shell command completes |
beforeMCPExecution | Fired before an MCP tool runs |
afterMCPExecution | Fired after an MCP tool completes |
beforeReadFile | Fired before a file is read |
afterAgentResponse | Fired after the agent responds |
Troubleshooting
- macOS script never runs: the Intune management agent installs on the first script assignment, then checks in roughly every 8 hours. Agent logs live in
/Library/Logs/Microsoft/Intune. - Windows script never runs: confirm the device is Entra joined or hybrid joined — workplace-registered-only devices don't receive scripts.
- Cursor activity missing on Windows: confirm
mint.ps1exists inC:\ProgramData\Cursorand check the Hooks Output panel in Cursor for errors.
Reach out to support@mintmcp.com if you have issues.