D365 F&O Security & Licence Intelligence MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
D365 F&O Security & Licence Intelligence MCP Server
Exposes security analysis, licence intelligence, and SoD detection as MCP tools consumable by AI agents and copilots.
Quick Start
Prerequisites
Python 3.10+
A D365 F&O environment with OData access
An Azure AD / Entra ID app registration with
Dynamics ERP→CustomService.FullAccesspermission
1. Install
git clone https://github.com/yuriirask-bit/d365fo-security-mcp.git
cd d365fo-security-mcp
pip install -e ".[dev]"2. Configure
cp env.example .env
# Edit .env with your D365 environment URL and Azure AD credentials3. Run
d365fo-security-mcpThe server starts on stdio transport (standard MCP protocol).
4. Connect
MCP clients (Claude Desktop, Claude Code, GitHub Copilot, Cursor, etc.) launch
the server as a subprocess. Environment variables must be passed in the client's MCP
configuration — the server does not inherit your shell environment or read
.env when launched this way.
Claude Desktop — edit %APPDATA%\Claude\claude_desktop_config.json (Windows)
or ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"d365fo-security": {
"command": "d365fo-security-mcp",
"env": {
"D365FO_BASE_URL": "https://your-env.operations.dynamics.com",
"D365FO_TENANT_ID": "your-tenant-id",
"D365FO_CLIENT_ID": "your-client-id",
"D365FO_CLIENT_SECRET": "your-client-secret",
"LICENCE_SOURCE": "graph"
}
}
}
}Claude Code — edit .claude/mcp.json in your project root:
{
"mcpServers": {
"d365fo-security": {
"command": "d365fo-security-mcp",
"env": {
"D365FO_BASE_URL": "https://your-env.operations.dynamics.com",
"D365FO_TENANT_ID": "your-tenant-id",
"D365FO_CLIENT_ID": "your-client-id",
"D365FO_CLIENT_SECRET": "your-client-secret",
"LICENCE_SOURCE": "graph"
}
}
}
}GitHub Copilot (VS Code) — add to github.copilot.chat.mcp.servers in
your VS Code settings.json, or create a .vscode/mcp.json file in the
project root:
{
"servers": {
"d365fo-security": {
"command": "d365fo-security-mcp",
"env": {
"D365FO_BASE_URL": "https://your-env.operations.dynamics.com",
"D365FO_TENANT_ID": "your-tenant-id",
"D365FO_CLIENT_ID": "your-client-id",
"D365FO_CLIENT_SECRET": "your-client-secret",
"LICENCE_SOURCE": "graph"
}
}
}
}Cursor — edit .cursor/mcp.json in your project root (or
~/.cursor/mcp.json for global configuration):
{
"mcpServers": {
"d365fo-security": {
"command": "d365fo-security-mcp",
"env": {
"D365FO_BASE_URL": "https://your-env.operations.dynamics.com",
"D365FO_TENANT_ID": "your-tenant-id",
"D365FO_CLIENT_ID": "your-client-id",
"D365FO_CLIENT_SECRET": "your-client-secret",
"LICENCE_SOURCE": "graph"
}
}
}
}Important: After changing env values in MCP config, you must fully restart the client (not just reconnect the server) for the new values to take effect.
MCP Inspector (for local testing — reads .env automatically):
npx @modelcontextprotocol/inspector d365fo-security-mcp5. First Tool Call
Ask your AI agent:
"What licence does each user in our D365 environment need?"
Related MCP server: Enterprise MCP Knowledge Platform
Available Tools
Tool | Description |
| Calculate minimum licence tier per user. Supports |
| Find users on too-expensive licence tiers |
| Find users at compliance risk (under-licensed) |
| Simulate role changes and see licence/cost impact. Now includes SoD conflict projection alongside licence impact |
| Aggregate licence consumption overview with compact per-user list |
| Explain why a role requires its licence tier. Use |
| Inspect server configuration, D365 connectivity, licence source setup, tool capabilities, and limitations |
| Test licence source connectivity with structured validation breakdown and remediation guidance |
SoD Conflict Detection & Security Analysis
Tool | Description |
| Run SoD conflict rules against all users or a specific user |
| Inspect the configured SoD conflict ruleset with category filter |
| Full role → duty → privilege hierarchy for a user with SoD violations. Supports |
| Rank users by SoD violation count and severity |
| Role hierarchy with sub-roles and optional SoD conflict annotations |
| Complete user-role assignment matrix. Supports |
| Legal entity scoped access map |
| Role assignment changes over time (via App Insights custom events — requires X++ event handler) |
| Privileged users with no recent login (three-source: App Insights + Database Logging + Graph) |
| Quarterly compliance access review list |
| Aggregate security posture score (0–100) with dimensional breakdown |
Tip: Most user-scanning tools accept an
exclude_service_accountsparameter that uses Provider-based native detection to filter out service and system accounts from results.
Configuration
Variable | Required | Default | Description |
| Yes | — | D365 F&O environment URL |
| Yes | — | Azure AD tenant ID |
| Yes | — | App registration client ID |
| Yes | — | App registration client secret |
| No |
| Licence data provider: |
| No | — | Path to licence CSV/JSON (when |
| No |
| ISO 4217 currency code for cost calculations |
| No |
| OAuth scope for Microsoft Graph API calls |
| No |
| Days after which licence source data is considered stale |
| No | — | D365 application version override (e.g., |
| No | — | Path to SoD conflict ruleset JSON file. See docs/sod-ruleset-format.md |
| No | — | Azure Application Insights connection string for login activity tracking. Requires Monitoring Reader RBAC role. See App Insights setup |
App Insights Setup (Optional — Login Activity)
Tools like find_dormant_privileged_accounts, run_user_access_review, and
get_security_health_score use login activity data to detect dormant accounts.
The primary source for D365 login sessions is Azure Application Insights.
1. Enable Application Insights in D365 F&O
In the D365 F&O environment, go to System administration → Setup → Monitoring and telemetry parameters
Enable Custom Telemetry + Application Insights
Paste your App Insights Instrumentation Key into the configuration field
Save and allow a few minutes for telemetry to start flowing
2. Get the Connection String
In the Azure Portal, navigate to your Application Insights resource
On the Overview page, copy the Connection String (not just the instrumentation key — the full string starting with
InstrumentationKey=...;IngestionEndpoint=...;ApplicationId=...)
3. Grant the Service Principal Read Access
The MCP server's service principal (the same app registration used for D365 OData access) needs the Monitoring Reader role on the App Insights resource.
Why not API keys? App Insights API keys were deprecated by Microsoft and retired in March 2026. Azure AD authentication with RBAC is the only supported method going forward.
Option A — Azure Portal (UI):
Navigate to your Application Insights resource
Go to Access control (IAM) → Add → Add role assignment
Role: search for and select Monitoring Reader
Members: select User, group, or service principal, click + Select members
Search for your app registration name (e.g.,
ICU-DEV1) and select itClick Review + assign
Option B — Azure CLI:
# Get the service principal object ID
SP_ID=$(az ad sp show --id <your-D365FO_CLIENT_ID> --query id -o tsv)
# Get the App Insights resource ID
AI_SCOPE=$(az monitor app-insights component show \
-g <resource-group> --app <app-insights-name> --query id -o tsv)
# Assign Monitoring Reader role
az rest --method put \
--url "${AI_SCOPE}/providers/Microsoft.Authorization/roleAssignments/$(uuidgen)?api-version=2022-04-01" \
--body "{
\"properties\": {
\"roleDefinitionId\": \"/subscriptions/<subscription-id>/providers/Microsoft.Authorization/roleDefinitions/43d0d8ad-25c7-4714-9337-8ba259a9fe05\",
\"principalId\": \"${SP_ID}\",
\"principalType\": \"ServicePrincipal\"
}
}"Note:
43d0d8ad-25c7-4714-9337-8ba259a9fe05is the built-in role definition ID for Monitoring Reader — it is the same across all Azure subscriptions.
4. Configure the MCP Server
Add the connection string to your environment configuration:
APP_INSIGHTS_CONNECTION_STRING=InstrumentationKey=xxxxx;IngestionEndpoint=https://...;ApplicationId=xxxxxOr in your MCP client config (claude_desktop_config.json / .claude/mcp.json):
{
"env": {
"APP_INSIGHTS_CONNECTION_STRING": "InstrumentationKey=xxxxx;IngestionEndpoint=https://...;ApplicationId=xxxxx"
}
}4. Verify
After a user logs into D365 and navigates a few pages, run:
pageViews
| summarize LoginTime=min(timestamp) by user_Id, session_Id
| order by LoginTime descin the App Insights Logs blade to confirm telemetry is arriving.
How It Works
D365 F&O emits pageView events to Application Insights for every interactive
session. The MCP server queries these via the App Insights API to derive login
sessions — summarising the first page view per user/session as the login
timestamp. No custom X++ entities are required.
Note: App Insights is one of three login data sources. The server also queries D365 Database Logging (
SysUserLogviaDatabaseLogsentity) and Microsoft GraphsignInActivityin parallel. The most recent timestamp from any source wins. All sources are optional — the tools degrade gracefully with warnings when sources are unavailable. GraphsignInActivityrequires an Entra ID P1/P2 (Premium) licence on the tenant — see Step 5b.
How It Works
MCP Client (Claude, Copilot) → MCP Server → OData API → D365 F&O
↓
Licence Source
(assess-only | file | graph)The server queries D365 F&O security metadata via OData, calculates licence requirements per user, and exposes the results as MCP tools.
Licence Source Options
Source | Description | Setup Required |
| Calculate requirements only — no assigned licence comparison | None (default) |
| Compare against a CSV/JSON file of assigned licences | Set |
| Query Azure AD / Entra ID for assigned licences | Set |
| Power Platform Admin Center (not yet implemented) | — |
Common Agent Prompts
Licence Intelligence
"What licence does each user in our D365 environment need?"
"Which users are over-licensed and how much could we save?"
"Are any users under-licensed and at risk of enforcement?"
"What happens to licence costs if I remove the Finance Controller role from user jsmith?"
"Give me an executive summary of our D365 licence spend"
"Why does the Accountant role require a Finance licence?"
SoD & Security Analysis
"Are there any segregation of duties violations in our environment?"
"What SoD rules are you checking against?"
"Show me everything about user jsmith's security access"
"Who are our highest-risk users?"
"Are there any dormant privileged accounts?"
"Give me a full access review list for our quarterly audit"
"How healthy is our D365 security overall?"
Limitations
The PPAC licence provider is not yet implemented (stub only)
The Graph provider covers common Microsoft 365 SKU GUIDs; uncommon SKUs are logged as warnings
Duty/privilege breakdown uses flat lists matching the D365 OData data model structure
Single-environment operation — multi-environment comparison is a future capability
Development
pip install -e ".[dev]"
ruff check src/ tests/
pytest --cov=src/d365fo_security_mcp/toolsLicence
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Compliance frameworks (SOC 2, ISO 27001, CMMC, NIST, more) delivered to AI agents as MCP tools.
Read-only finance and operations controls for AI agents with evidence and safe next actions.
MCP gateway with runtime security policy, tool-call-level control, and audit of agent actions.
Zero-secret MCP gateway for AI agents: risk-scored, audited calls with human-in-the-loop approval.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to explore metadata, query data, and perform write operations across multiple Microsoft Dynamics 365 Finance & Operations environments. It features specialized tools for OData execution and data analysis with built-in read-only safety for production environments.41 npm10MIT
- FlicenseNot gradedqualityCmaintenanceEnables governed, read-only SQL analytics, hybrid RAG knowledge search, financial metric calculation, and database schema introspection through MCP, with role-based access control, audit logging, and AI observability.-
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to manage Magento 2 / Adobe Commerce products, stock, orders, and customers through 12 read/write MCP tools with secure, audited access.AGPL 3.0

Civic MCP Gatewayofficial
AlicenseNot gradedqualityDmaintenanceEnables AI agents to connect to tools and data through a governed MCP endpoint with agent identity, scoped permissions, guardrails, and full audit trails. Access is user-controlled and can be revoked instantly, with every tool call logged by agent identity and timestamp.MIT