Skip to content

Last update 

Adoption · Operate

Lessons on access control and data protection

Enforce authorization, least privilege, user context, read-write isolation, and redaction in MCP servers.

Enforce security at every layer

Do not treat Azure API Management or another gateway as the only authorization boundary. A misconfiguration, internal network access, or leaked backend credentials can bypass the gateway. Gateways also miss context-dependent tool-handler rules.

Enforce authorization at every layer:

  1. Gateway. API Management or AI Gateway validates tokens, subscriptions, and rate limits.
  2. MCP server. Validate the Microsoft Entra ID audience (aud) claim and tool-level scopes such as read:customers.
  3. Data store. Data access code enforces per-item authorization by caller identity or region.
  4. Monitoring. Application Insights records authorization outcomes per layer.

Apply least privilege from day one

Never assign Contributor, Owner, or other broad Azure role-based access control (RBAC) roles to MCP server identities. Never grant unused Microsoft Graph permissions to MCP app registrations. A compromised MCP server inherits every permission on its identity.

Use managed identities User-assigned Checked · Source page over service principals so Azure rotates credentials automatically. Define custom delegated scopes per operation, such as read:customers and write:orders. Avoid application permissions unless required. Schedule Entra ID Access reviews Checked · Source page They require Entra ID Governance or Microsoft Entra Suite. Entra ID P2 includes some capabilities..

MCP server Avoid Use instead
CRM reader Contributor on subscription Cosmos DB Built-in Data Reader scoped to the container with Cosmos DB Entra ID data-plane role-based access control Checked · Source page It uses native Cosmos DB for NoSQL role definitions, not Azure RBAC. The Azure portal cannot manage data-plane RBAC. Set disableLocalAuth to block key-based access.
Order writer Owner on resource group Entra ID app role or delegated scope write:orders
Report generator Global Administrator Reports.Read.All on Microsoft Graph

Review permissions every 90 days:

  • Remove permissions unused for 90 days.
  • Replace service principals with managed identities wherever possible.
  • Verify app registrations hold no unused Graph admin consent.
  • Audit which principals can grant permissions to MCP app registrations.

Maintain user context throughout

Do not share one service principal or managed identity across agents. Shared identities hide which user initiated each call, block per-user authorization, blur audits, and let one compromised agent reach every other agent's data.

Choose the pattern that matches your workload:

  • On-Behalf-Of flow. For a single user-facing agent, use Entra ID On-Behalf-Of OAuth flow Checked · Source page Middle-tier MCP servers must validate their own audience claim and relay Conditional Access claims challenges to callers.. The MCP server exchanges the user token for a downstream token to keep user identity end to end.
  • Per-agent identity with token-verified user claims. On multi-agent platforms, assign each agent a dedicated Entra Agent ID identity for agent and user attribution. Derive oid, upn, and roles only from a validated Entra ID On-Behalf-Of or Microsoft Entra Agent ID on-behalf-of token. Never read those claims from caller parameters, per control MCP-01.

Build server-side audit records from verified claims in flat fields for Log Analytics:

// Server-side audit record populated from validated token claims, not caller parameters
{
  "agent_id": "sales-copilot-agent-01",
  "user_id": "00000000-0000-0000-0000-000000000001",
  "user_upn": "alice@contoso.com",
  "user_roles": ["sales.read"],
  "mcp_method": "tools/call",
  "mcp_name": "get_customer",
  "arguments_redacted": {
    "customer_id": "12345"
  }
}
// Hides the initiating user behind one shared service principal
{
  "agent_id": "mcp-service-principal",
  "mcp_method": "tools/call",
  "mcp_name": "get_customer",
  "arguments_redacted": {
    "customer_id": "12345"
  }
}

User context lets Log Analytics attribute calls to a user and agent, and Sentinel alert when one user triggers unusual export volume.

Separate read from write operations

Do not share one MCP server, policy, and identity across read and write tools. On one endpoint, prompt injection or an over-scoped read token can escalate to data modification or deletion.

Deploy separate reader and writer MCP servers with distinct identities, scopes, and approval paths:

  • Reader server. Host crm-reader-mcp on Functions with a read-only managed identity and no human approval gate.
  • Writer server. Host crm-writer-mcp on Container Apps with elevated Entra ID scopes and Multi Round-Trip Requests (MRTR) human confirmation. For calls through Foundry MCP tool Checked · Source page An empty allowed_tools list permits every tool on the server. Long-running tasks, the .NET SDK, and AgentOnBehalfOfUser remain in preview., set require_approval.

MRTR elicitation asks the MCP client user. Foundry require_approval returns an approval request to the calling application. Second-approver workflows, such as manager sign-off for high-value actions, need an external workflow system outside this guide.

Validate inputs and filter outputs

Do not wrap internal APIs without argument validation and response filters. Unvalidated arguments allow SQL and command injection. Unfiltered outputs can expose personally identifiable information (PII), internal hostnames, or credentials in the model context window.

Validate tool arguments against a strict JSON Schema for types, formats, and bounds. Reject suspicious patterns before backend calls. On outbound responses, redact secrets and sensitive fields in server code, cap sizes, and verify outputs against authoritative sources.

Pattern Action Audit log
Credit card number Redact Yes
Social Security Number format Block response Yes
Internal hostname Replace with placeholder Yes
API key or credential pattern Block response Alert security team
External email address Redact when policy requires Yes

Purview DLP is not automatic for arbitrary MCP parameters

Do not rely on Microsoft Purview alone to redact MCP tool arguments or responses. Redact deterministically in MCP server code.

These controls provide AI agent posture and audit visibility:

No Microsoft documentation confirms Purview Automatic DLP for arbitrary MCP tool-call parameters Checked · Source page Purview documents no MCP-specific controls. DLP does not cover arbitrary tool-call parameters automatically..

Classify and control by sensitivity

Do not apply identical controls to public documentation and restricted financial records. Uniform controls either over-restrict low-risk tools or expose regulated GDPR, HIPAA, or PCI-DSS data.

Classify data with Purview and tag MCP servers by sensitivity tier. Isolate high-sensitivity tools on dedicated MCP servers with stricter authentication and approvals.

Tool Data classification Access control
get_public_docs Public Any authenticated user
search_kb_articles Internal Entra ID with multifactor authentication
get_customer_pii Confidential Privileged role and audit logging
export_financial_data Restricted Human approval workflow and audit review

Access and data checklist

Confirm these controls before production rollout:

  • Validate aud and tool scopes in MCP server code, not only at the gateway.
  • Run scheduled Entra ID access reviews and remove unused permissions every 90 days.
  • Use Entra ID On-Behalf-Of for user-facing agents to keep user context.
  • Separate read-only and write MCP servers and identities.
  • Validate inputs against strict schemas and redact response secrets and PII.

Related risks: MCP01 Token Mismanagement and Secret Exposure, MCP02 Privilege Escalation via Scope Creep, MCP05 Command Injection and Execution, MCP06 Intent Flow Subversion, MCP07 Insufficient Authentication and Authorization, MCP08 Lack of Audit and Telemetry, MCP10 Context Injection and Over-Sharing

Return to Enterprise patterns.