purview-dlm-mcp
Copilot instructions9 starsChanged 9 months agoMITView on GitHub
When using the dlm-diagnostics MCP server tools: MCP server enabling AI assistants to diagnose Microsoft Purview Data Lifecycle Management (DLM) issues in Exchange Online. Provides run_powershell (read-only command execution) and get_execution_log (audit trail) tools. Environment variables: DLM_UPN, DLM_ORGANIZATION (required), DLM_COMMAND_TIMEOUT_MS (optional, default 180000). Diagnostic skills live in .github/skills/: - dlm-diagnostics/ — 11 troubleshooting guides for DLM issues - asklearn/ — Fallback skill for Microsoft Learn documentation lookup - skill-creator/ — Meta-skill for authoring new skills Each skill has a SKILL.md…
- Installs packages
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- asklearnSkill
- dlm-diagnosticsSkill
- skill-creatorSkill
- asklearnSkill
- dlm-diagnosticsSkill
- skill-creatorSkill
The file
We split this copilot-instructions.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 5
When using the dlm-diagnostics MCP server tools:
- Very specific: line 15
Follow diagnostic guides in .github/skills/dlm-diagnostics/ when investigating
- Very specific: line 34
Read-only only: Only Get-*, Test-*, Export-* cmdlets are allowed.
- Very specific: line 36
Validation: Every command is checked against allowlist.ts before execution.
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions — Purview DLM Diagnostics MCP Server
MCP Tool Selection (Runtime Diagnostics)
When using the dlm-diagnostics MCP server tools:
| User Intent | Tool | Examples |
| Reports a problem or error | run_powershell | "retention policy not applying", "items not archiving", "policy stuck in Error" |
| Asks how-to or conceptual question | ask_learn | "how do I create a retention policy", "what is eDiscovery" |
| Asks to review commands run | get_execution_log | "show me what we ran", "summarize the investigation" |
- Default to
run_powershellfor anything that sounds like troubleshooting - Never use
ask_learnfor active issues — it returns docs, not diagnostics - Follow diagnostic guides in
.github/skills/dlm-diagnostics/when investigating
Project Overview
MCP server enabling AI assistants to diagnose Microsoft Purview Data Lifecycle Management (DLM) issues in Exchange Online. Provides run_powershell (read-only command execution) and get_execution_log (audit trail) tools.
Key Files
| File | Purpose |
src/index.ts | MCP server entry point, tool registration |
src/powershell/executor.ts | Long-lived pwsh process manager with MSAL auth |
src/powershell/allowlist.ts | Cmdlet allowlist and command validation |
src/asklearn.ts | Purview topic lookup — Learn URLs and guidance |
src/tsg-diagnostics.ts | Pure diagnostic evaluation engine (10 TSGs) |
src/logger.ts | Append-only execution log with Markdown export |
Security Constraints
- Read-only only: Only
Get-*,Test-*,Export-*cmdlets are allowed. - Blocked verbs:
Set-*,New-*,Remove-*,Enable-*,Start-*,Invoke-*,Disable-*,Stop-*,Add-*,Clear-*,Update-*,Register-*,Revoke-*,Grant-*. - Validation: Every command is checked against
allowlist.tsbefore execution. New cmdlets must be added toALLOWED_CMDLETSexplicitly. - No stored credentials: MSAL interactive browser auth only; tokens in-memory.
Code Style
- TypeScript ESM —
"type": "module", use.jsextensions in imports - Strict mode — explicit return types on exported functions
- Zod — for MCP tool input schemas
- Pure evaluators — diagnostic functions in
tsg-diagnostics.tstake parsed data, return structured results (no I/O) - Copyright header on every
.tsfile:// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. - Naming: kebab-case files, camelCase variables/functions, PascalCase types/classes
Build & Test
npm install # Install dependencies
npm run build # Compile TypeScript (tsc)
npm test # Run tests (vitest run)
npm start # Start MCP serverEnvironment variables: DLM_UPN, DLM_ORGANIZATION (required), DLM_COMMAND_TIMEOUT_MS (optional, default 180000).
Skills
Diagnostic skills live in .github/skills/:
dlm-diagnostics/— 11 troubleshooting guides for DLM issuesasklearn/— Fallback skill for Microsoft Learn documentation lookupskill-creator/— Meta-skill for authoring new skills
Each skill has a SKILL.md and a references/ directory with per-symptom troubleshooting guides.
Guidelines for Code Suggestions
- Match existing patterns — follow the structure in
allowlist.tsfor new cmdlets,tsg-diagnostics.tsfor new evaluators. - Read-only cmdlets only — never suggest mutating PowerShell commands in diagnostic steps.
- Add copyright headers — include the Microsoft copyright header on new
.tsfiles. - Keep evaluators pure — diagnostic evaluation functions must not perform I/O or side effects.
- Update the allowlist — if a new
Get-*/Test-*/Export-*cmdlet is needed, add it toALLOWED_CMDLETSinsrc/powershell/allowlist.ts. - Mirror skills — new skills must be placed in both
.github/skills/and.claude/skills/.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

