Skip to content

Last update 

Adoption · Operate

Lessons on governance, telemetry, and testing

Curate MCP tools, stage rollouts, log audits, test threats, pin digests, and restrict egress.

Curate tools intentionally

Never publish internal APIs as MCP tools without a review of sensitivity, descriptions, and composition risks. Agents call unready tools, misread vague descriptions, or chain low-risk tools such as list_all_users and export_data into high-risk actions.

Register approved MCP servers in API Center Private MCP registry Checked · Source page It stores metadata for approved remote and local MCP servers. Integration with the Foundry private tool catalog remains in preview.. Review each proposed tool in seven steps:

  1. Define explicit input and output schemas.
  2. Threat-model trust boundaries and chained-tool risks.
  3. Review the description for clarity and ambiguity.
  4. Classify source data sensitivity.
  5. Run adversarial prompt tests.
  6. Approve the tool, register its MCP server in API Center, and record owner metadata per tool.
  7. Monitor production calls and remove unused tools quarterly.

Record the review in catalog metadata:

tool:
  name: get_customer_details
  version: 1.2.0
  sensitivity: Confidential
  requires_approval: false
  allowed_roles:
    - sales.read
    - support.read
  description: "Retrieves customer details by ID. Returns name, email, and account status."
  approved_by: "security-team@contoso.com"
  approved_date: "2026-11-26"
  review_frequency: "Quarterly"

Hide experimental and internal-only tools from default discovery so agents see only permitted tools.

Start small and expand gradually

Never expose 50 or more REST endpoints as MCP tools in week one before you validate monitoring and governance. Large tool sets widen breaches, degrade tool selection, and leave no anomaly baseline.

Roll out MCP servers in stages across development, staging, and production. Add tools in this order:

  1. Start with 3 to 5 read-only tools and monitor Application Insights for 2 to 4 weeks.
  2. Expand read tools once controls hold.
  3. Add write tools in weeks 9 to 12 only behind human approvals.

Enforce deployment gates with Azure Policy:

Make audit trails first-class

Log the agent, user, tool, parameters, and outcome for every MCP tool call. Without structured telemetry, you cannot detect abuse, troubleshoot failures, or prove GDPR, HIPAA, SOC 2, or ISO 27001 compliance.

Send structured traces to Application Insights and centralize them in Log Analytics. Build dashboards in Azure Monitor and detection rules in Sentinel.

Changed in 2026-07-28

Model Context Protocol (MCP) specification 2026-07-28 removes protocol sessions and Mcp-Session-Id. Log a correlation ID and any application-issued opaque state handle instead. See What's new.

Log each tool call as a structured record:

{
  "timestamp": "2026-11-26T10:30:00Z",
  "correlation_id": "abc-123-def-456",
  "agent_id": "sales-copilot-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_details",
  "tool_version": "1.2.0",
  "arguments_redacted": {
    "customer_id": "12345"
  },
  "http_status": 200,
  "jsonrpc_error_code": null,
  "is_error": false,
  "response_size_bytes": 2048,
  "duration_ms": 145,
  "state_handle": "handle-789",
  "previous_tools": ["search_customers", "get_customer_details"],
  "prompt_hash": "sha256-placeholder",
  "filtered": false,
  "approval_required": false
}

Never log full prompt text, raw PII from tool responses, or credentials. Hash or redact sensitive inputs and route high-sensitivity records to a restricted audit workspace.

This record extends MCP08 Lack of Audit and Telemetry core fields with operational fields such as is_error. Query workspace-based Application Insights AppTraces custom dimensions in Log Analytics:

// Assumes AppTraces custom dimensions: mcp_method, mcp_name, user_id
AppTraces
| where TimeGenerated > ago(1h)
| extend
    McpMethod = tostring(Properties.mcp_method),
    ToolName = tostring(Properties.mcp_name),
    UserId = tostring(Properties.user_id)
| where McpMethod == "tools/call" and ToolName == "export_customer_data"
| summarize Count = count() by UserId
| where Count > 10
| project UserId, Count, AlertMessage = "Unusual export activity"
// Assumes AppTraces custom dimensions: mcp_name, user_id, http_status, jsonrpc_error_code
AppTraces
| where TimeGenerated > ago(24h)
| extend
    ToolName = tostring(Properties.mcp_name),
    UserId = tostring(Properties.user_id),
    HttpStatus = toint(Properties.http_status),
    JsonRpcError = toint(Properties.jsonrpc_error_code)
| where HttpStatus in (401, 403) or JsonRpcError == -32020
| summarize FailedAttempts = count() by UserId, ToolName
| order by FailedAttempts desc
// Assumes AppTraces custom dimensions: mcp_method, mcp_name
AppTraces
| where TimeGenerated > ago(7d)
| extend
    McpMethod = tostring(Properties.mcp_method),
    ToolName = tostring(Properties.mcp_name)
| where McpMethod == "tools/call" and isnotempty(ToolName)
| summarize Invocations = count() by ToolName
| order by Invocations desc

Alert in Sentinel on five conditions:

  • One user exceeds 100 tool calls per hour.
  • One caller exceeds 5 authorization failures per hour.
  • A caller invokes a restricted tool outside business hours.
  • A tool exports over 10 MB.
  • A caller invokes a tool outside the approved catalog.

Test for MCP-specific threats

Add threat models, penetration tests, and adversarial prompt validation beyond functional tests. Functional tests miss indirect prompt injection, poisoned tool descriptions, parameter manipulation, and unauthorized tool chains.

Include MCP servers in application security and red-team programs:

  • Threat models. Map trust boundaries between agents, MCP servers, and backends before deployment.
  • Adversarial tests. Test hidden instruction overrides, unauthorized admin calls, secret exfiltration, multi-tool chains, and SQL or command injection in arguments.
  • Build scanning. Run static analysis, secret scanning, and dependency scanning on every build. See MCP04 Software Supply Chain Attacks and Dependency Tampering for supply-chain controls.
  • Image scanning. Scan Azure Container Registry images with Defender for Cloud Agentless container vulnerability assessment Checked · Source page It requires Defender for Containers or Defender CSPM with Registry access enabled. Images not running and with no push or pull in 30 days get no daily rescan..
  • Template scanning. Scan infrastructure templates with Defender for Cloud DevOps security infrastructure-as-code scanning Checked · Source page Pipeline scanning with the Microsoft Security DevOps extension is generally available in Foundational or Defender CSPM. Agentless code scanning is in preview, and pull request annotations require paid Defender CSPM..
  • Red-team exercises. Re-run adversarial suites on each tool release and hold quarterly MCP red-team exercises.

Verify eight threat classes before launch:

  • Prompt injection, command injection, and tool poisoning
  • Privilege escalation and authorization bypass
  • Token leakage in logs or errors
  • External data exfiltration and rate-limit evasion

Version servers like APIs

Do not deploy mutable latest tags or change tool schemas without a deprecation path. Unannounced schema changes break connected agents and block clean rollback after a security regression.

Tag images with semantic versions such as crm-mcp:1.2.0 and pin production by @sha256:... digest. Shift revision traffic gradually with Container Apps Multiple-revision traffic splitting Checked · Source page It requires multiple revision mode with combined weights that total 100%. Deployment labels remain in preview.. Publish version histories and deprecation notices in API Center.

Increment major versions for breaking changes, minor versions for new tools or optional parameters, and patch versions for bug fixes.

Enforce strict network boundaries

Do not grant MCP servers unrestricted outbound internet access. A compromised MCP server, poisoned tool, or prompt injection can exfiltrate data to attacker-controlled hosts or open command-and-control channels.

Deploy MCP servers in a virtual network with strict network security group rules. Apply these network controls:

  • Route Azure data over private endpoint so database traffic stays off public endpoints.
  • Default-deny other egress with Azure Firewall FQDN egress filtering rules Checked · Source page Application-rule FQDN filtering covers HTTP, HTTPS, and Azure SQL on Basic, Standard, and Premium SKUs. Network-rule FQDN filtering requires Standard or Premium..
  • Allowlist only exact fully qualified domain names of required external endpoints in Azure Firewall, such as login.microsoftonline.com.
  • Send Azure Firewall denied-egress logs to Log Analytics and alert on unexpected destinations.
  • Capture traffic with virtual network Flow logs Checked · Source page Network security group flow logs retire on 2027-09-30, and you cannot create new ones. Use virtual network flow logs instead..

Operations checklist

Confirm these controls before production rollout:

  • Review and register every production tool in API Center with owner, sensitivity, and quarterly review metadata.
  • Log structured calls with correlation IDs and verified user claims to Log Analytics, without secrets or raw PII.
  • Run adversarial prompt, injection, and chained-tool tests before each new or updated tool release.
  • Pin all MCP server container images by @sha256:... digest.
  • Enforce default-deny egress with Azure Firewall FQDN allowlists and private endpoint.

Related risks: MCP02 Privilege Escalation via Scope Creep, MCP03 Tool Poisoning, MCP04 Software Supply Chain Attacks and Dependency Tampering, MCP06 Intent Flow Subversion, MCP08 Lack of Audit and Telemetry, MCP09 Shadow MCP Servers

Return to Enterprise patterns.