
ActiveDirectoryMCP
io.github.forestallio/ActiveDirectoryMCP
On-prem Active Directory: users, groups, ACLs, Group Policy, DNS and AD CS, every change reversible.
Documentation
ActiveDirectoryMCP
Let your AI assistant search, explain and change on-premises Active Directory, with every change recorded and reversible.
ActiveDirectoryMCP is a local Model Context Protocol server for on-premises Active Directory. It runs on the administrator's own machine over stdio, with the administrator's own Windows identity, and lets an MCP client (Claude Code, Claude Desktop, VS Code, Cursor and others) work with directory objects, permissions, Group Policy, AD-integrated DNS and Active Directory Certificate Services.
What you can ask
Once the server is connected, you talk to your assistant in plain language and it calls the tools:
- "Which enabled users in the Sales OU have not signed in for 90 days? Are any of them in privileged groups?"
- "Who can reset passwords in the Helpdesk OU, and is that permission set on the OU or inherited?"
- "Create a GPO that adds the Helpdesk group to the local Administrators group of the servers, link it to the Servers OU, and show me a dry run first."
- "Which certificate templates let the requester supply the subject, and who may enroll in them?"
- "Copy the baseline GPO to a staging copy, raise the minimum password length there, and import it back when I say so."
- "Undo the last three changes you made."
Highlights
- Reversible edits. Every edit supports
dryRun, returns the values before and after, and is written to a local change log.ad_rollback_changeandad_rollback_changesundo one change or a whole session, and refuse when the object changed again in the meantime. - Read-only by default. Edit tools exist only when
ModeisReadWrite; otherwise the server cannot change anything. - Data in, data out. The server returns the data that is asked for and makes the change that is asked for. It does not rate risk, protect "Tier-0" objects or hide attributes: authorization comes only from Active Directory ACLs on the caller's identity, and the analysis belongs to your assistant.
- Built on Microsoft components. The official MCP C# SDK and the ActiveDirectory and GroupPolicy PowerShell modules, hosted in-process (AD Web Services, TCP 9389). PowerShell commands are built from bound parameters only, never from script text.
- No stored credentials, no cloud service. The server acts as the signed-in Windows user. Nothing leaves the machine except what your MCP client sends to its model.
- Verifiable builds. Releases are built by GitHub Actions from the tagged source, with SHA-256 sums, an SBOM and signed build provenance you can check with
gh attestation verify; or build it yourself in one command.
What it covers
| Area | Read | Change (ReadWrite mode) |
|---|---|---|
| Directory objects | Search with LDAP filters (also forest-wide), object details, group membership (also nested), OU tree, deleted objects, domain and password policy, attribute replication metadata, replication status, last logon, Windows LAPS passwords | Create, modify, move, rename, delete and restore (Recycle Bin) users, groups, computers, contacts, OUs, gMSAs, password settings objects and subnets; enable, disable and unlock accounts; group membership; password reset |
| Permissions | DACL with inheritance, owner, SACL (audit entries) | Add and remove entries, owner, auditing, inheritance |
| Group Policy | GPOs, links, inheritance, reports, permissions, registry settings, security settings, Advanced Audit Policy, preferences (registry, local users and groups, services), backups | Create, link, enable, delete and restore GPOs; registry-based settings, security settings, audit subcategories and those preferences one by one; backup and restore; staging copies and imports for every other kind of setting |
| DNS (AD-integrated) | Zones and records, also searched by name or data | Add, change and remove records; create and delete zones (a deleted zone comes back with its records through rollback) |
| AD CS | Enterprise CAs, NTAuth, certificate templates with flags and permissions, the CA's status, settings, permissions and request database | Copy and change templates, publish them; approve and deny requests, revoke certificates or put them on hold and release them, publish CRLs, CA settings and permissions, restart the CA service |
| Changes | The change log | Roll back one change or a selection, with a dry run |
36 tools in read-only mode, 90 in ReadWrite mode: see Tools and the generated reference in docs/tools.md.
Quick start
On a domain-joined Windows machine with RSAT, download the zip from the latest release, then:
Unblock-File .\ActiveDirectoryMCP-*-win-x64.zip
Expand-Archive .\ActiveDirectoryMCP-*-win-x64.zip C:\
claude mcp add activedirectory --scope user -- C:\ActiveDirectoryMCP\ActiveDirectoryMCP.exe
Or build it from source with the .NET 10 SDK:
git clone https://github.com/forestallio/ActiveDirectoryMCP.git
cd ActiveDirectoryMCP
dotnet publish src/ActiveDirectoryMCP.Server -c Release -r win-x64 --self-contained -o C:\ActiveDirectoryMCP
claude mcp add activedirectory --scope user -- C:\ActiveDirectoryMCP\ActiveDirectoryMCP.exe
Then ask your assistant: "Using the activedirectory tools, show the domain info." Add -e ADMCP__Mode=ReadWrite to the last command when you want the edit tools. The sections below explain each step and the other MCP clients.
Listings
- MCP Registry:
io.github.forestallio/ActiveDirectoryMCP, installs the.mcpbbundle from the latest release. - Glama: browse the tools and check the server's quality score. The server needs a domain-joined Windows machine with RSAT, so it cannot be tried in an online sandbox; install it from a release instead.
Status
Early development (0.1.0). The read-only, edit, Group Policy, DNS, AD CS and rollback tools work: they are covered by unit tests and by end-to-end tests against a lab with a child domain, a trusted forest and an enterprise CA (tests/lab). Prebuilt releases are on the Releases page. Interfaces may still change. Try it in a lab or with a read-only account first.
Contents
- What you can ask · Highlights · What it covers · Quick start · Listings · Status
- Requirements
- Build and install
- Connect an MCP client
- Configuration
- Tools
- Edits, rollback and logs
- Known limitations
- Data handling and security
- Troubleshooting
- Update and uninstall
- Development
- Contributing
- License
Requirements
Machine that runs the server (usually the administrator's admin workstation or management server):
-
Windows 11 Pro, Enterprise or Education, Windows 10 Enterprise/LTSC, or Windows Server 2016 or later; x64. Tested on Windows Server 2025.
-
Domain-joined, with RSAT:
- Windows Server:
Install-WindowsFeature RSAT-AD-PowerShell, GPMC, RSAT-DNS-Server - Windows 10/11:
Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0,Add-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0andAdd-WindowsCapability -Online -Name Rsat.Dns.Tools~~~~0.0.1.0
The Group Policy module is needed only for the GPO tools (
ad_*gpo*), the DnsServer module only for the DNS tools (ad_*dns*).ad_get_laps_passworduses the LAPS module that is part of Windows (Windows 10/11, Windows Server 2019 or later with the April 2023 update). - Windows Server:
-
Network access to a domain controller of each domain you use: DNS, Kerberos (88), LDAP (389) and AD Web Services (9389); the Group Policy tools also read SYSVOL over SMB (445) and the GPO security settings, audit policy and preference tools write the GPO's
GptTmpl.inf,audit.csv,Registry.xml,Groups.xmlandServices.xmlthere (then raise the GPO version through Windows' Group Policy editor interface, gpedit.dll), andad_set_object_aclandad_get_object_aclwithincludeAudituse LDAP directly (signed and sealed).ad_get_replication_statusandad_get_last_logoncontact every domain controller of the domain. The DNS tools talk to the DNS server (by default the domain controller the server uses) over WinRM/CIM (5985). The CA tools (ad_get_ca_status,ad_list_ca_requests,ad_get_ca_requestand the CA edit tools below) talk to the CA over DCOM/RPC (135 and the dynamic RPC ports; the AD CS role opens them) with Windows' certadm.dll, andad_restart_ca_serviceand the service state inad_get_ca_statususe WinRM (5985) to the CA. -
No .NET installation: the release zip and the build output are self-contained.
Account: the server acts as the Windows user who starts the MCP client. Use an account with exactly the Active Directory permissions you want the AI to have; for example, creating GPOs needs membership in Group Policy Creator Owners, linking a GPO needs write access to the OU, and reading or changing audit entries (SACL) needs the "Manage auditing and security log" right on the domain controllers. Certificate templates and CA objects live in the forest's configuration partition: changing them needs Enterprise Admins or delegated rights there. The CA itself checks its own roles: ManageCertificates (certificate manager) to approve, deny and revoke, ManageCA (CA administrator) for settings, permissions and CRLs. No credentials are stored.
To build from source (not needed with a release zip): the .NET 10 SDK and Git, on any Windows x64 machine (it can be the same machine).
Build and install
From a release (recommended). Download ActiveDirectoryMCP-<version>-win-x64.zip from Releases. The executables are not Authenticode signed; instead, check where the zip comes from, then unblock and extract it:
gh attestation verify .\ActiveDirectoryMCP-v0.1.0-win-x64.zip --repo forestallio/ActiveDirectoryMCP # GitHub CLI; or compare Get-FileHash with SHA256SUMS.txt
Unblock-File .\ActiveDirectoryMCP-v0.1.0-win-x64.zip
Expand-Archive .\ActiveDirectoryMCP-v0.1.0-win-x64.zip C:\ # creates C:\ActiveDirectoryMCP
The attestation shows that GitHub Actions built the zip from this repository at the release tag. The release also has an SPDX SBOM of every package in it (also in the zip under _manifest). Environments that allow only signed code (AppLocker, WDAC) need a rule for the folder, or a build from source.
Claude Desktop extension. The release also has ActiveDirectoryMCP-<version>-win-x64.mcpb, the same build as an MCP Bundle: open it (or drag it onto Settings → Extensions) to install it in Claude Desktop, then pick ReadOnly or ReadWrite as the mode in the extension's settings. The server is also listed in the MCP Registry as io.github.forestallio/ActiveDirectoryMCP.
From source:
-
Install the .NET 10 SDK, for example with
winget install --id Microsoft.DotNet.SDK.10 --exact, or with the installer from the link above. Open a new terminal afterwards sodotnetis on thePATH. -
Get the source and publish it to a folder:
git clone https://github.com/forestallio/ActiveDirectoryMCP.git cd ActiveDirectoryMCP dotnet publish src/ActiveDirectoryMCP.Server -c Release -r win-x64 --self-contained -o C:\ActiveDirectoryMCPThe output (about 130 MB) contains
ActiveDirectoryMCP.exeand everything it needs. If you build on another machine, copy the whole folder. -
Optional: run the unit tests (no Active Directory needed):
dotnet test --solution ActiveDirectoryMCP.slnx.
The server has no user interface. Started by hand it waits silently for MCP messages on stdin; your MCP client starts and stops it.
Connect an MCP client
Point the client at C:\ActiveDirectoryMCP\ActiveDirectoryMCP.exe as a stdio server. In JSON, write backslashes twice. The examples with ADMCP__Mode=ReadWrite enable the edit tools; leave that variable out to run read-only, or set Mode in a configuration file instead.
Claude Code
claude mcp add activedirectory --scope user -- C:\ActiveDirectoryMCP\ActiveDirectoryMCP.exe
# with the edit tools:
claude mcp add activedirectory --scope user -e ADMCP__Mode=ReadWrite -- C:\ActiveDirectoryMCP\ActiveDirectoryMCP.exe
claude mcp list shows whether it connected.
Claude Desktop: Settings → Developer → Edit Config opens %APPDATA%\Claude\claude_desktop_config.json. Add the server, then quit Claude Desktop completely and start it again:
{
"mcpServers": {
"activedirectory": {
"command": "C:\\ActiveDirectoryMCP\\ActiveDirectoryMCP.exe",
"env": { "ADMCP__Mode": "ReadWrite" }
}
}
}
VS Code: in .vscode/mcp.json of a workspace, or in the user configuration (command MCP: Open User Configuration):
{
"servers": {
"activedirectory": {
"type": "stdio",
"command": "C:\\ActiveDirectoryMCP\\ActiveDirectoryMCP.exe",
"env": { "ADMCP__Mode": "ReadWrite" }
}
}
}
Cursor: in %USERPROFILE%\.cursor\mcp.json (all projects) or .cursor/mcp.json in a project, then restart Cursor:
{
"mcpServers": {
"activedirectory": {
"command": "C:\\ActiveDirectoryMCP\\ActiveDirectoryMCP.exe",
"env": { "ADMCP__Mode": "ReadWrite" }
}
}
}
Other clients: any MCP client that starts a local stdio server works the same way.
Check it: ask the assistant something like "Using the activedirectory tools, show the domain info". The resource admcp://config/effective shows the mode, the identity the server runs as and the pinned domain controllers. Without an AI client, the MCP Inspector (Node.js 22 or later) can call the tools directly: npx @modelcontextprotocol/inspector C:\ActiveDirectoryMCP\ActiveDirectoryMCP.exe.
Configuration
Settings are read in this order; later sources override earlier ones:
appsettings.jsonnext to the exe (replaced when you publish again)%APPDATA%\ActiveDirectoryMCP\config.json(the place for your own settings)- Environment variables
ADMCP__<Section>__<Name>, for example from the client configuration
config.json uses the same layout as appsettings.json:
{
"ActiveDirectoryMCP": {
"Mode": "ReadWrite",
"Domains": [
{ "Name": "corp.example", "Default": true },
{ "Name": "emea.corp.example", "Server": "dc01.emea.corp.example" }
],
"Limits": { "MaxResults": 2000 }
}
}
| Setting | Environment variable | Default | Meaning |
|---|---|---|---|
Mode | ADMCP__Mode | ReadOnly | ReadOnly or ReadWrite (registers the edit tools) |
Domains[] | ADMCP__Domains__0__Name, __Server, __Default | empty | Optional domain profiles: Name (DNS name), Server (domain controller to use; otherwise one is discovered), Default. A profile also makes a domain usable that is neither in the forest nor reached through a trust (see below) |
Limits:MaxResults | ADMCP__Limits__MaxResults | 1000 | Most objects read for one query; more are reported as truncated |
Limits:DefaultPageSize | ADMCP__Limits__DefaultPageSize | 50 | Items per page when the tool call does not say |
Limits:CommandTimeoutSeconds | ADMCP__Limits__CommandTimeoutSeconds | 60 | Limit for one read command, and for one call to a CA or one LDAP security descriptor read or write. See Interrupted edits |
Limits:WriteTimeoutSeconds | ADMCP__Limits__WriteTimeoutSeconds | 300 | Limit for one write command through PowerShell (a recursive delete or a GPO restore can take longer than a read) |
Audit:Enabled | ADMCP__Audit__Enabled | true | Write the audit log |
Audit:Path | ADMCP__Audit__Path | %LOCALAPPDATA%\ActiveDirectoryMCP\audit | Audit log folder |
Changes:Path | ADMCP__Changes__Path | %LOCALAPPDATA%\ActiveDirectoryMCP\changes | Change log folder (used by rollback) |
Logging:LogLevel:Default | Logging__LogLevel__Default | Information | Diagnostic log level; the log goes to stderr, which the MCP client captures |
Domains and forests. Without configuration the server uses the computer's domain. Other domains of the forest, and domains of forests with a trust, work through the domain parameter of each tool, by DNS or NetBIOS name: the server accepts the domains of its forest (from the configuration partition), the targets of the forest's trusts and, for a forest trust, the domains below its name, and the domains in Domains[]. Any other name is refused with the list of names it accepts, so a mistyped or unknown name never sends the caller's credentials to an unexpected server. The first use of a domain pins a domain controller for the process lifetime, so reads and the writes that follow them go to the same DC. The DNS tools' dnsServer parameter accepts only a domain controller of the domain. ad_search_objects with forest=true searches the whole forest through the Global Catalog. For a forest without a trust, use a separate installation: an admin machine where you sign in with an account of that forest, with its own MCP client and ActiveDirectoryMCP.
Tools
The full reference with every parameter is in docs/tools.md (generated from the server).
Read-only (always available)
| Tool | Purpose |
|---|---|
ad_search_objects | Search with type, name, enabled and raw LDAP filters; domain or whole forest (Global Catalog); paged |
ad_get_object | One object of any type with all or selected attributes |
ad_get_user, ad_get_computer, ad_get_group | One user, computer or group with its account state and common attributes |
ad_get_group_members | Direct or nested members (Get-ADGroupMember; groups over 5000 members return an error that explains the LDAP alternative) |
ad_get_member_of | Direct, nested and primary-group memberships of an object |
ad_get_ou_tree | OU hierarchy with linked GPOs, blocked inheritance and object counts |
ad_get_domain_info | Domain, forest, domain controllers, trusts, Recycle Bin state |
ad_get_password_policy | Default and fine-grained password policies, resultant policy of a user |
ad_get_object_acl | Owner and DACL with trustee names and schema GUIDs resolved |
ad_get_attribute_history | Replication metadata: when each attribute last changed and on which DC |
ad_list_gpos, ad_get_gpo_report | Group Policy Objects with their links, and one GPO's settings report |
ad_get_gpo | One GPO with status, versions, links and permissions |
ad_get_gpo_inheritance | GPOs that apply to an OU or the domain, in precedence order, and whether inheritance is blocked |
ad_get_gpo_registry_value | Registry-based (Administrative Templates) settings configured in a GPO under a key |
ad_list_gpo_backups | GPO backups in a folder on this machine (the server's own backup folder by default, or any folder such as an extracted security baseline), newest first |
ad_get_gpo_security_settings | A GPO's security settings from its GptTmpl.inf: user rights with their principals, restricted groups, security options, account, Kerberos and audit policies, and every other entry as written |
ad_get_gpo_preference_registry | A GPO's Group Policy Preferences registry items from its Registry.xml, in processing order, with action, type, full value, collection, item-level targeting and options |
ad_get_gpo_preference_local_users_and_groups | A GPO's Group Policy Preferences local groups (action, SID, members added or removed) and local users (action, built-in account, account options, stored cpassword as it is in the file) from its Groups.xml |
ad_get_gpo_preference_services | A GPO's Group Policy Preferences service items from its Services.xml: startup type, service action, wait, log-on account and recovery actions |
ad_get_gpo_audit_policy | A GPO's Advanced Audit Policy from its audit.csv: each configured subcategory with category, GUID and setting; optionally every subcategory |
ad_list_deleted_objects | Objects in the Deleted Objects container |
ad_get_replication_status | Inbound replication partners of every DC (last attempt, last success, result, consecutive failures) and recorded replication failures |
ad_get_last_logon | lastLogon, badPwdCount and badPasswordTime from every DC, the most recent logon, and lastLogonTimestamp |
ad_get_laps_password | Windows LAPS or legacy LAPS password of a computer (decrypted when the caller may), with expiration and history |
ad_list_dns_zones | Zones of a DNS server: type, AD integration, replication scope, dynamic updates, reverse lookup |
ad_get_dns_records | Records of a zone, or of one name and/or type, with data, TTL and the dynamic-registration timestamp |
ad_find_dns_records | Records in every zone whose name or data contains a text, for example the A and PTR records of an IP address |
ad_list_certificate_authorities | Enterprise CAs (configuration string, CA certificate, published templates, NTAuth membership), NTAuth and root certificates in AD |
ad_list_certificate_templates, ad_get_certificate_template | Certificate templates with settings decoded (EKUs, validity, subject and enrollment flags, approval, signatures, key options), publishing CAs, and Enroll / AutoEnroll / control rights |
ad_get_ca_status | An enterprise CA's type, configuration (EditFlags, InterfaceFlags, AuditFilter, CRLFlags with flag names, request handling, validity and CRL periods, publication URLs), permissions, the caller's CA roles and the CertSvc state |
ad_list_ca_requests, ad_get_ca_request | Requests and certificates in a CA's database (issued, pending, revoked, denied, failed; by requester, template, serial, expiry, date), and one with its certificate details (SANs, EKUs, template and SID extensions) |
Edit (ReadWrite mode only)
| Tool | Purpose |
|---|---|
ad_create_user, ad_create_group, ad_create_ou | Create an object. A user without a password is created disabled; generatePassword=true returns a random one |
ad_create_computer, ad_create_service_account, ad_create_password_policy | Pre-stage a computer account; create a group managed service account (gMSA); create a fine-grained password policy and apply it to groups or users |
ad_create_object | Create an object of any class, for example a contact or a subnet in the configuration partition |
ad_set_object_acl | Permissions (DACL): add or remove entries (with object types such as an attribute or an extended right, and inheritance), remove all entries of a trustee, disable or enable inheritance. Owner: set a new owner. Auditing (SACL): add or remove audit entries |
ad_set_attributes | Replace, add, remove or clear values of any attribute |
ad_set_account_state | Enable, disable, unlock, set or clear the expiration date |
ad_reset_password | Reset a password (given or generated), optionally require a change at next logon and unlock |
ad_set_group_membership | Add and remove members; members of a trusted forest are added by SID (foreign security principal) |
ad_move_object, ad_rename_object | Move to another OU, rename |
ad_delete_object | Delete; recursive for containers, removeProtection for objects protected from accidental deletion |
ad_restore_object | Restore from the AD Recycle Bin by objectGUID or last known name |
ad_create_gpo, ad_delete_gpo | Create a GPO; delete a GPO and its links (backed up first, restorable with the same GUID) |
ad_set_gpo | Rename a GPO, or set its status (all, user or computer settings disabled) |
ad_set_gpo_link, ad_set_gpo_inheritance | Link, change (enabled, enforced, order) or unlink a GPO on an OU or the domain; block or unblock inheritance |
ad_set_gpo_permission | Permission of a user, group or computer on a GPO, including security filtering |
ad_set_gpo_registry_value | Set, disable or remove a registry-based policy setting |
ad_backup_gpo, ad_restore_gpo | Back up a GPO; restore a GPO's settings and permissions from a backup |
ad_copy_gpo | Copy a GPO with all its settings into a new, unlinked GPO, in the same or another domain; permissions only with copyAcl |
ad_import_gpo_settings | Replace all settings of a GPO with those of a backup of another GPO: every kind of setting, including security settings, audit policy, preferences and scripts |
ad_set_gpo_user_right | Add or remove principals of a user right (for example SeDenyNetworkLogonRight), set its whole list, or make it not configured |
ad_set_gpo_restricted_group | Members and member-of lists of a restricted group (usually a local group of the computers), or take it out |
ad_set_gpo_security_option | One security option: a registry value under MACHINE\ that the security engine sets, for example LmCompatibilityLevel |
ad_set_gpo_security_policy | One value of the password, lockout, Kerberos or legacy audit policy ([System Access], [Kerberos Policy], [Event Audit]) |
ad_set_gpo_preference_registry_value | One Group Policy Preferences registry value (Create, Replace, Update or Delete, with its type and value), or remove its items |
ad_set_gpo_preference_local_group | One Group Policy Preferences local group (Create, Replace, Update or Delete; new name, description, delete all members first, members to add, remove or drop), or remove its items |
ad_set_gpo_preference_local_user | One Group Policy Preferences local user or built-in account (Create, Replace, Update or Delete; names, description, account and password options, expiry; no passwords), or remove its items |
ad_set_gpo_preference_service | One Group Policy Preferences service item (startup type, service action, wait), or remove its items |
ad_set_gpo_audit_policy | One Advanced Audit Policy subcategory: No Auditing, Success, Failure, Success and Failure, or not configured |
ad_add_dns_record, ad_remove_dns_record | Add an A, AAAA, CNAME, PTR, MX, SRV or TXT record; remove the records of a name that match the given data, or all of them |
ad_set_dns_record | Make one record the only record of its name and type: change an address, retarget a CNAME, change a TTL |
ad_create_dns_zone, ad_delete_dns_zone | Create an AD-integrated primary zone (forward, or reverse from a network ID); delete a zone with its records (restorable from the Recycle Bin) |
ad_publish_certificate_template | Publish a template on an enterprise CA, or unpublish it |
ad_set_certificate_template | Change template settings: display name, validity and renewal, subject supplied in the request, manager approval, authorized signatures, EKUs, exportable key, key size, autoenrollment, raw flags |
ad_copy_certificate_template | Duplicate a template with a new OID (not published, no Enroll rights); grant Enroll with ad_set_object_acl (extended right Certificate-Enrollment) |
ad_revoke_certificate | Revoke a certificate with a CRL reason, or release one from hold |
ad_approve_certificate_request, ad_deny_certificate_request | Approve or deny a request that waits for CA manager approval |
ad_publish_crl | Publish a base or delta CRL |
ad_set_ca_setting, ad_set_ca_permission | Change a CA configuration value (named flags of EditFlags, InterfaceFlags, AuditFilter, CRLFlags; any value), grant or remove CA permissions (ManageCA, ManageCertificates, ...) |
ad_restart_ca_service | Restart Certificate Services so changed settings and permissions take effect |
ad_rollback_change | Undo a recorded change |
ad_rollback_changes | Undo several changes, newest first: a list, everything since a time, or everything of a server session |
ad_list_changes | Recorded changes on this machine, newest first |
Group Policy editing covers what the Microsoft GroupPolicy module can do, plus the security settings, Advanced Audit Policy and three kinds of preferences. Registry-based settings (Administrative Templates), security settings (user rights, restricted groups, security options, account, Kerberos and legacy audit policies), Advanced Audit Policy subcategories and Group Policy Preferences registry, local users and groups, and services items can be changed one by one. The other kinds of setting (scripts, the other Group Policy Preferences such as scheduled tasks, drive maps or files, software installation) cannot be written one by one, but whole sets of them move between GPOs with ad_copy_gpo and ad_import_gpo_settings. A typical change, like a check-out and check-in:
ad_copy_gpomakes an unlinked staging copy of the GPO.- Change the copy: registry-based and security settings with the tools above, everything else in the Group Policy Management Editor. Link it to a test OU if you want to try it.
- Compare the two with
ad_get_gpo_report. ad_backup_gpobacks up the copy, andad_import_gpo_settingsputs its settings into the original. The original keeps its name, GUID, links and permissions, andad_rollback_changebrings back its previous settings.
The same import applies a template GPO or a Microsoft security baseline, which ships as GPO backups (ad_list_gpo_backups with the extracted folder). A backup from another domain or forest may need a migration table (migrationTable) for its accounts and UNC paths. WMI filters and site links are not supported.
DNS editing covers records of the types above and AD-integrated primary zones. DNS server settings (forwarders, scavenging, conditional forwarders, zone transfers, DNSSEC) are not supported.
The AD CS tools cover the directory side (CA and template objects in the configuration partition) and the CA itself: its database (requests and certificates), revocation, approval, CRL publication, configuration values and permissions, and restarting Certificate Services. Key archival and recovery, database cleanup, CA backup and renewal of the CA certificate are not supported. The tools return settings and rights as data; they do not assess them.
Resources: admcp://config/effective (mode, identity, pinned domain controllers, limits, log folders) and, in ReadWrite mode, admcp://changes/{changeId} (one recorded change with typed before and after values).
Edits, rollback and logs
Every edit tool takes dryRun=true to preview: it reads the current values and shows the intended result without writing anything. An applied change returns its changeId with the before and after values, read from the pinned domain controller.
ad_rollback_change applies the inverse of a recorded change: previous attribute values are written back, created objects are deleted, deleted objects are restored from the Recycle Bin, moves, renames, membership and account-state changes are reversed. The target is found by objectGUID, so a later move or rename does not break it; group members and the parent a moved object came from are recorded by objectGUID too. If the object changed after the recorded change, nothing is done and the differences are returned; force=true rolls back anyway. A rollback is itself a recorded change and can be rolled back. Password resets and unlocks cannot be rolled back, and a deletion cannot be undone when the Recycle Bin is not enabled; the tools say so in their result.
ad_set_attributes records secret attributes (a name that contains password or pwdhistory or ends in pwd, such as unicodePwd, ms-Mcs-AdmPwd and msLAPS-Password, and supplementalCredentials, msDS-ManagedPassword) as ***, so a change of one cannot be rolled back. Changes of pwdLastSet and lockoutTime are recorded but marked irreversible, because Active Directory accepts only 0 or -1 for pwdLastSet and only 0 for lockoutTime, not their previous value.
Deleting an object below an OU and rolling it back restores the subtree, the object first: objects that are already live again are skipped, and objects that fail are listed in the result and in the record (notRestored) and can still be brought back with ad_restore_object. Rolling back such a restore deletes the subtree again, so it is refused when objects were created below it after the restore. Deleted objects of the configuration partition (certificate templates, sites, subnets) are looked up in that partition's Deleted Objects container.
Interrupted edits. Edits run one at a time; once an edit starts, cancelling the tool call does not stop it halfway. A PowerShell command that runs past its limit (Limits:CommandTimeoutSeconds for reads, Limits:WriteTimeoutSeconds for writes) is stopped; one that does not stop within 15 more seconds (a cmdlet waiting in native code, for example on SMB or DCOM) is abandoned, and the next command gets a new PowerShell session. A call to a CA or an LDAP security descriptor read or write is abandoned after Limits:CommandTimeoutSeconds. The error says when the outcome of a write is uncertain. If an edit fails or times out after it sent a write and before it recorded the change, the server saves an Incomplete change record with the error and the write commands it sent (details.writes), and the error names its changeId. An Incomplete change cannot be rolled back: check the object and correct it by hand.
Security descriptor changes (ad_set_object_acl) write only the parts that change (owner, DACL, SACL) and record them before and after; rolling back writes those parts back. They are written with System.DirectoryServices over LDAP, bound to the object by its GUID, because the ActiveDirectory module writes only the DACL.
Group Policy changes follow the same model. A GPO setting, permission or restore is preceded by a Backup-GPO, whose ID is in the change record, so ad_restore_gpo can also bring back the whole GPO as it was. Rolling back a GPO deletion restores the GPO's directory object from the Recycle Bin, then its settings and permissions from the backup (same GUID), then its links by the OUs' GUIDs; a link that cannot be restored is listed in the result. An import of settings (ad_import_gpo_settings) is preceded by a backup of the target and rolls back like a restore. Rolling back a GPO restore or import, or the undo of a GPO deletion, replaces the whole GPO from a backup, so it is refused when the GPO's version changed afterwards, unless every later change of that GPO recorded on this machine was rolled back. Rolling back a copy (ad_copy_gpo) deletes the copy, after a backup; it stops while the copy is linked. Name, status, links and inheritance blocking are attributes of the GPO or of the OU and are rolled back like attribute changes.
Security settings live in the GPO's Machine\Microsoft\Windows NT\SecEdit\GptTmpl.inf, which the GroupPolicy module cannot write. The security tools change only the lines they are asked to, in the file on the pinned domain controller, and keep every other line as it is. Then Windows' own Group Policy editor interface raises the GPO version and registers (or, when the last security setting goes, unregisters) the security extension, as the Group Policy Management Editor does. Principals are stored as SIDs. The change record holds the changed lines before and after, and rolling back writes the previous lines again. A rollback stops when one of those lines changed afterwards. When computers stop receiving a security setting, Windows puts user rights and the known security options back to their earlier values, but a registry value outside the known security options keeps the value it last got.
Advanced Audit Policy lives in the GPO's Machine\Microsoft\Windows NT\Audit\audit.csv. The tool changes one subcategory line, written as GPMC writes it and found by the subcategory's GUID; audit options and global object access auditing lines stay as they are. Then the GPO editor interface raises the version and registers the audit extension. No Auditing is a setting (computers turn auditing of the subcategory off); not configured takes the line out. Rolling back writes the subcategory's earlier line again, or removes it, and stops when the line changed afterwards. In the lab, a computer that stopped receiving a subcategory went back to No Auditing, which was also its setting before.
Group Policy Preferences registry items live in Machine\Preferences\Registry\Registry.xml (or User\...). The server reads and writes this file itself, because Set-GPPrefRegistryValue writes string values one character short and Get-GPPrefRegistryValue reads them one character short (seen in Windows PowerShell 5.1 and PowerShell 7.6). A change touches only the items of one value: the first item is changed in place, so its item-level targeting and options stay, and the value's further items are removed; collections, order and every other item of the file stay. Then the GPO editor interface raises the GPO version and registers the preferences extension, as for security settings. The record holds that value's items before and after. Rolling back puts the earlier items back in place, without touching the file's other values, and stops when the value's items changed afterwards.
Local users and groups (Machine\Preferences\Groups\Groups.xml or User\...) and services (Machine\Preferences\Services\Services.xml) work the same way; there is no cmdlet for them. A change covers the items of one local group, one local user or one service. Built-in groups are written by SID and built-in accounts by RID, as GPMC writes them, and a group's member entries change one by one (add, remove, or drop an entry). A service item keeps its log-on account and recovery settings. The record holds those items before and after, and rolling back puts the earlier items back. In the lab, a computer applied a member added and removed, a local account changed and deleted, and a service disabled, set to manual and started.
DNS record changes record the records of the name and type before and after. Rolling one back undoes only what that change did: it removes the records it added and adds back, with their old TTL, the records it removed; records that someone else added to the same name stay. It stops when a record the change added is gone or one it removed is back. Rolling back a zone deletion restores the zone's directory object from the Recycle Bin under its original name, then its record objects, then has the DNS server load it again: the same zone with its records, timestamps and permissions. This works for AD-integrated primary zones with the Recycle Bin enabled.
Publishing a template and changing its settings are attribute changes and roll back like them; like any change of the settings, the rollback raises the template's minor revision, so clients read the template again. Rolling back a template copy deletes the template and its OID object together; rolling that back restores both from the Recycle Bin with the same GUID, OID and permissions. A template that is published on a CA is not deleted by a rollback until it is unpublished. The CA picks up a publish or unpublish from its domain controller within seconds (about 15 in the lab).
On the CA, only a certificate hold can be undone: rolling back a hold releases the certificate, and rolling back a release puts it on hold again. Revocations for any other reason, approvals, denials, CRL publications and restarts are recorded but marked irreversible, and ad_rollback_change says why. CA settings and permissions roll back to their previous value (a value that did not exist is deleted again); like the change itself, the rollback takes effect when Certificate Services restarts.
ad_rollback_changes undoes several changes in one call, newest first, for example session=current for everything done through the running server. Changes that were already rolled back, and change + rollback pairs, are skipped; a change whose rollback was itself rolled back is in effect again and is rolled back. Each record is read again just before its step, so a change that was rolled back meanwhile is skipped too. It stops at the first failure. Run it with dryRun=true first.
- Change log:
%LOCALAPPDATA%\ActiveDirectoryMCP\changes\<changeId>.json, one file per applied change.ad_rollback_changereads it, also after a restart; changes made on another machine cannot be rolled back here. Secret values are recorded as***. - GPO backups:
%LOCALAPPDATA%\ActiveDirectoryMCP\changes\gpo-backups, one folder per backup. They contain the GPO's settings; delete old ones when you no longer need to roll back. - Audit log:
%LOCALAPPDATA%\ActiveDirectoryMCP\audit\audit-YYYYMMDD.jsonl, one line per tool call with its arguments (secret arguments and secret attribute values masked, also inside nested arguments), error, duration andchangeId. Several server processes can write to the same file. - Both are plain files owned by the user who runs the server; they are a convenience, not tamper-proof evidence. Active Directory's own auditing (events 4738, 4728, 5136, ...) remains the authoritative record.
Known limitations
- Edits by other tools in between. Edits are serialized only inside one server process. A change made by another tool or another server process between an edit's read and its write is not detected; rollback, which checks the current state first, is where differences show up.
- DN-valued attributes. Rolling back a change of an attribute that holds a DN (
manager,managedBy, ...) writes the DN that was recorded. If the referenced object was moved or renamed since, the rollback fails; if another object now has that DN, it points to that object. - GPO registry values. A MultiString value with no strings is recorded as no value, so rolling back a change of such a value fails; set it again by hand.
- DNS names. A node with a child of the same label (for example
a.abelowa) cannot be told apart from it: the child's records are counted as the node's own. Rolling back the removal of a dynamically registered record adds it back with a new timestamp (the current hour), so aging starts again. - Batch dry runs.
ad_rollback_changeswithdryRun=truechecks each step against the current state; it cannot simulate a step that depends on an earlier step in the same batch (see Troubleshooting). - GPO backups taken before GPO changes are not deleted automatically.
ad_restore_gporestores from any backup folder the account can read. That is by design: the caller is an administrator and chooses the backup.- GPO security settings.
- A user right, restricted group or account policy can cut this machine off from the domain controllers. Then
ad_rollback_changecannot reach them either: correct the GPO from another machine or a DC console. - Someone editing the same GPO in the Group Policy Management Editor at the same time can overwrite the change, or have it overwritten.
- The GPO editor interface updates GPT.INI through the domain's SYSVOL namespace, which can be served by a domain controller other than the pinned one; the versions agree once SYSVOL replication has run (usually seconds).
- File system, registry key and service security entries (
[File Security],[Registry Keys],[Service General Setting]) are shown and kept, but not edited. - The Group Policy Preferences other than registry, local users and groups, and services items, and scripts, are not edited one by one.
- A user right, restricted group or account policy can cut this machine off from the domain controllers. Then
- Advanced Audit Policy.
- Audit options (
Option:lines such as CrashOnAuditFail) and global object access auditing are shown and kept, but not edited. - The server knows the 60 subcategories Windows Server 2019 and 2025 list (the Access Rights subcategory only exists on some versions). A subcategory is written with its English GPMC name; computers use its GUID.
- Audit options (
- Registry preferences.
- Preferences are applied but not enforced: a value stays on the computers after the GPO stops applying, unless the item says "remove this item when it is no longer applied" (set in the Group Policy Management Editor; the server keeps the option but does not set it).
- Items for a key's default value and items that act on a whole key are shown but cannot be set.
- Rolling back a value whose earlier items were in different collections puts them all back where the first one was.
- Local users and groups, and services preferences.
- What an item did stays on the computers after the GPO stops applying or the item is rolled back (a member stays added, a service stays disabled), unless the item says to remove it; rolling back changes the GPO, not the computers.
- Passwords are not written (GPMC stopped storing them with MS14-025). Create and Replace make a local account without a password, which a computer accepts only where its password policy allows an empty one; elsewhere the item fails on the computer with 0x800708C5 (seen in the lab). A stored cpassword in an old item is shown, kept, or removed with
clearStoredPassword. - Startup types are the ones GPMC's editor writes (No change, Automatic, Manual, Disabled); Automatic (Delayed Start) and other values in a file are shown as they are. A service's log-on account and recovery actions are shown and kept, but not set.
- The current user options of user-side group items ("add/remove the current user") are kept, but not set.
Data handling and security
- Tool results are sent to the LLM provider that your MCP client uses. If you ask for password, LAPS or BitLocker attributes, they are returned and sent there too, and so is a password generated by
ad_create_userorad_reset_passwordor returned byad_get_laps_password. That is the administrator's decision. - Text stored in the directory (descriptions, notes, display names) is returned as data. Anyone who can write such attributes can try to steer an AI that reads them. The server never acts on that text itself, but your AI client might, so check what it proposes before it writes: keep the server read-only unless you need edits, use
dryRun, and leave the client's tool approval prompts on. - Commands run through the ActiveDirectory module with bound parameters only; no script text is built from tool input.
- Report vulnerabilities as described in SECURITY.md.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| The client lists no tools, or the server "failed to start" | Check the path to ActiveDirectoryMCP.exe (doubled backslashes in JSON) and restart the client. The server's diagnostic output is in the client's MCP log (Claude Desktop: %APPDATA%\Claude\logs; VS Code: the MCP output channel; Claude Code: claude --debug). |
| Edit tools are missing | Mode is not ReadWrite. admcp://config/effective shows the mode in effect. |
| Some tools are missing in the client, for example in Cursor | Some clients pass only a limited number of tools to the model; Cursor has long allowed 40 across all MCP servers. This server lists 36 tools in ReadOnly mode and 90 in ReadWrite mode. Turn off the tools you do not need in the client's MCP settings. Claude Code loads large tool lists on demand. |
| "The ActiveDirectory PowerShell module could not be loaded" | Install RSAT: Active Directory module for Windows PowerShell (see Requirements). |
| "The GroupPolicy PowerShell module could not be loaded" | Install Group Policy Management Tools (GPMC). |
| "The DnsServer PowerShell module could not be loaded" | Install RSAT: DNS Server Tools (see Requirements). |
| A DNS tool fails with a WinRM or CIM error | The DNS tools reach the DNS server over WinRM (TCP 5985). Check that WinRM is reachable on that domain controller, or pick another DNS server with dnsServer. |
| A CA tool fails with "The RPC server is unavailable" | The CA is not reachable over DCOM/RPC (TCP 135 and the dynamic RPC ports) or Certificate Services is stopped. Right after a restart, wait a few seconds. |
| A CA tool fails with "Access is denied" | The account lacks the CA role: ManageCertificates to approve, deny or revoke, ManageCA for settings, permissions and CRLs (ad_get_ca_status shows the caller's roles). |
| "'x' is not a domain this server uses" | The name is not a domain of the forest or of a trust (the message lists the names that work). Check the spelling, or add the domain to Domains[] with a Server when it is reachable without a trust. |
| "dnsServer 'x' is not a domain controller of ..." | dnsServer accepts only the domain's own domain controllers (the message lists them). |
| "... did not finish within N seconds" | A command ran past Limits:CommandTimeoutSeconds (reads) or Limits:WriteTimeoutSeconds (writes). Narrow the query or raise the limit. For a write the message says the outcome is uncertain; when the edit had already written, it names an Incomplete change: check the object by hand. |
| "The cursor is unknown or has expired" | A cursor lives 15 minutes, the server keeps at most 100 of them (the oldest goes first), and a new server process (for example after the client restarted) has none. Run the query again without a cursor. |
| "Unable to contact the server" | No domain controller with AD Web Services was reached: check DNS and TCP 9389, or set Domains[].Server. In a remote PowerShell session this is also the Kerberos double hop; run the client in an interactive logon. |
| "Insufficient access rights" or "Access is denied" | The account lacks the Active Directory permission. Objects protected from accidental deletion need removeProtection=true to be deleted. |
A group with more than 5000 members fails in ad_get_group_members | Use ad_search_objects with the LDAP filter given in the error message. |
Results are cut off (truncated: true) | Narrow the query or raise Limits:MaxResults. |
| Audit entries (SACL) cannot be read or changed (privilege not held) | The account needs the "Manage auditing and security log" user right (SeSecurityPrivilege) on the domain controllers; Domain Admins have it by default. |
ad_set_object_acl reports that the DACL is not in canonical order | Entries are out of the standard order (some tools write them that way). Reorder them once in Active Directory Users and Computers (open the Security tab and apply); the tool then works. |
ad_rollback_changes dry run shows a step as blocked | The check runs against the current state; a step that depends on an earlier rollback in the same list (for example deleting a GPO whose link is removed first) passes when the batch runs. |
Update and uninstall
Update: close the MCP clients that use the server (the exe is in use while they run), then replace the folder with the new release zip (delete the old folder first so no stale files remain), or git pull and run the same dotnet publish command. Settings in %APPDATA%\ActiveDirectoryMCP and the logs in %LOCALAPPDATA%\ActiveDirectoryMCP are kept.
Uninstall: remove the server from the client configuration (claude mcp remove activedirectory --scope user for Claude Code), delete the install folder, and optionally %APPDATA%\ActiveDirectoryMCP and %LOCALAPPDATA%\ActiveDirectoryMCP.
Development
dotnet build ActiveDirectoryMCP.slnx
dotnet test --solution ActiveDirectoryMCP.slnx # unit tests, no Active Directory needed
.\scripts\Update-ToolReference.ps1 # regenerate docs/tools.md after changing a tool
src/ActiveDirectoryMCP.Core: options, LDAP filters, identity and domain resolution, change log, audit logsrc/ActiveDirectoryMCP.PowerShell: the single-runspace executor that hosts the ActiveDirectory modulesrc/ActiveDirectoryMCP.Server: MCP host, tools, edit enginetests/lab: scripts for a lab domain:Seed-Lab.ps1(test OU with sample objects),Invoke-SmokeTest.ps1(read-only tools through the MCP Inspector) andInvoke-EditTest.ps1(every edit tool and its rollback) andInvoke-GpoTest.ps1(every GPO tool, GPO delete and restore, staging copy and import, batch rollback;-TargetDomainadds a copy to another domain) andInvoke-GpoSecurityTest.ps1(the security settings, preference and advanced audit policy tools, with the machine it runs on as the Group Policy client: it moves that computer into a work OU, checks that harmless settings, two preference values, a local group member, a test account, a service startup type and one audit subcategory are applied, removes them again, and moves it back) andInvoke-AdminTasksTest.ps1(permissions, owner and auditing, computer, contact, subnet, gMSA and password policy creation, replication, last logon, LAPS;-LapsComputerchecks decryption on a Windows LAPS client) andInvoke-DnsTest.ps1(every DNS tool in temporary zones andadmcp-e2e-*names, zone delete and restore, batch rollback) andInvoke-AdcsTest.ps1(CA and template reads, template copy, settings, Enroll right, publish, rollback chain; needs an enterprise CA) andInvoke-CaTest.ps1(the CA itself: requests with certreq, approve, deny, hold and release, revoke, CRL, settings, permissions, restart; changes the lab CA and restores it). Run them only in a lab.
Design, decisions and the history of each phase: PLAN.md. Working notes for AI coding sessions on this repository: CLAUDE.md.
Contributing
Issues and pull requests are welcome. Before you start on something larger, open an issue to discuss it. The project deliberately stays a thin MCP server: tools that read and change Active Directory, with rollback. Policy engines, risk ratings, reports or a web interface are out of scope (see the design notes in PLAN.md). A change should come with unit tests (dotnet test --solution ActiveDirectoryMCP.slnx), keep tool names, descriptions and messages in English, and regenerate docs/tools.md when a tool changes. Never commit names, addresses or credentials of a real environment. Report security problems privately as described in SECURITY.md.
License
Apache-2.0. Copyright forestall.io; see NOTICE.
https://github.com/forestallio/ActiveDirectoryMCP/releases/download/v0.1.0/ActiveDirectoryMCP-v0.1.0-win-x64.mcpb# mcpb: https://github.com/forestallio/ActiveDirectoryMCP/releases/download/v0.1.0/ActiveDirectoryMCP-v0.1.0-win-x64.mcpb