AI

AgentOps: validate MCP tool annotations before automating approvals

A production runbook for verifying read-only, destructive, idempotent and open-world MCP tool annotations before relaxing approvals, with canary evidence and rollback.

13 Oct 2026 aiagentopsmcpmicrosoft-foundrytoolsapprovalssecurityevaluationguardrailsobservabilityautomationrunbookrollbackproduction

An operations agent has used an MCP server for several weeks to read incidents, create change tasks and restart jobs. Every call requires human approval. The team now wants to remove confirmation for operations declared read-only and automatically retry calls declared idempotent.

The efficiency gain is real, but the decision depends on metadata supplied by the server. An MCP annotation states intent; it does not prove backend behavior, identity scope or the runtime’s ability to enforce approval. This runbook qualifies that contract before turning a hint into production authority.

Freeze the inventory actually exposed

Start from the tools/list response seen by the production runtime. Do not start from server source code: a gateway, Toolbox version or allowed_tools configuration may change the surface actually presented to the agent.

Preserve the server name, version, digest of the normalized response, connection identity and approval policy. For each tool, record its input schema and the four common risk annotations: readOnlyHint, destructiveHint, idempotentHint and openWorldHint.

yaml 01-mcp-tool-contract.yml
server: ops-mcp
version: 2026.10.13-3
contract_digest: <sha256>
connection_identity: mi-foundry-ops-prod

tools:
- name: incidents.get
  annotations:
    readOnlyHint: true
    destructiveHint: false
    idempotentHint: true
    openWorldHint: false
  approval: candidate-for-bypass

- name: jobs.restart
  annotations:
    readOnlyHint: false
    destructiveHint: true
    idempotentHint: true
    openWorldHint: false
  approval: always

- name: vendors.create_ticket
  annotations:
    readOnlyHint: false
    destructiveHint: false
    idempotentHint: false
    openWorldHint: true
  approval: always

A missing annotation should trigger the cautious posture: the tool may write, may be destructive, may not be idempotent and may interact with the external world. Do not silently infer missing values from the tool name.

Turn annotations into testable hypotheses

The four indicators answer different questions.

  • readOnlyHint means the call should not change any observable state.
  • destructiveHint qualifies a write that may overwrite, delete or make state unavailable.
  • idempotentHint means repeating the same call with the same arguments should not multiply its effect.
  • openWorldHint indicates that the tool interacts with entities outside the controlled domain, or brings their content back.

The test matrix must describe what to observe, not merely which JSON value is expected.

yaml 02-annotation-test-matrix.yml
checks:
read_only:
  before_after: [resource_etag, audit_events, queue_depth, outbound_calls]
  pass: no_state_change
non_destructive_write:
  before_after: [target_exists, prior_value, created_object_id]
  pass: existing_state_preserved
idempotent:
  attempts: 2
  same_arguments: true
  pass: one_business_effect_one_idempotency_record
closed_world:
  observe: [dns_destinations, http_hosts, data_sources, returned_content_origin]
  pass: destinations_match_approved_inventory

blocking:
- hidden_write_from_read_only_tool
- duplicate_effect_on_retry
- undeclared_external_destination
- approval_not_bound_to_exact_arguments

An idempotent tool is not necessarily a safe tool. Repeating disable_account with the same parameters may produce only one effect, but that effect is still destructive. Likewise, a read tool may expose sensitive data or return untrusted content. Annotations shape policy; no annotation replaces authorization, parameter validation and audit logging.

Verify behavior behind the wrapper

Test against a canary resource with the agent’s real identity. An administrator account hides RBAC boundaries; an oversimplified mock hides backend side effects.

For a call advertised as read-only, snapshot state before and after: Activity Log, application audit, queues, counters, database writes and outbound requests. A method named get may refresh a cache, acknowledge a message or create a durable session.

For a write advertised as idempotent, send two identical calls with the same idempotency key, then simulate a lost response on the first call. The expected result is not merely two compatible responses: there must be one business effect and a trace that reconciles the state.

json 03-idempotency-evidence.json
{
"tool": "jobs.restart",
"target": "job-canary-01",
"argumentsDigest": "<sha256>",
"idempotencyKey": "ann-test-20261013-001",
"calls": 2,
"acceptedExecutions": 1,
"businessEffects": 1,
"firstResult": "response-lost",
"secondResult": "reconciled-existing-operation",
"auditCorrelationComplete": true
}

If the tool protocol carries no stable key and the backend cannot reconcile an operation, keep approval enabled and forbid automatic retry even when idempotentHint is true.

Separate annotation, approval and authorization

Three layers must remain independent.

  1. The annotation describes the risk declared by the MCP server.
  2. The runtime policy decides whether the call requires human approval.
  3. The backend authorizes or rejects the action based on identity, scope and parameters.

In Microsoft Foundry, an approval configuration must be enforced by the runtime that pauses the call, presents the tool name and arguments, then resumes that exact call after a decision. Approval metadata alone is not a server-side barrier.

yaml 04-runtime-approval-policy.yml
default: always

bypass_candidates:
- tool: incidents.get
  conditions:
    - trusted_server_version
    - verified_read_only_behavior
    - closed_resource_scope
    - arguments_schema_valid
    - trace_complete

mandatory_approval:
- any_write
- destructive_or_unknown
- open_world
- missing_annotation
- identity_or_scope_change

server_side_controls:
- least_privilege_identity
- target_allowlist
- strict_schema_validation
- idempotency_record
- immutable_audit_event

The useful rule is therefore not “annotation true, approval removed.” It is “trusted server, frozen version, verified behavior, closed scope, least-privileged identity and complete trace: this canary read is eligible for a bounded exception.”

Detect drift before it changes policy

Descriptions, schemas and annotations are part of the production contract. On every tools/list, normalize the relevant fields and compare their digest with the qualified version. A new operation, modified annotation or broader description must return the tool to mandatory approval until it is validated again.

text 05-contract-drift-decision.txt
Digest unchanged
Continue the canary under the validated policy

Digest changed, proven cosmetic change only
Replay selection and negative tests before promotion

Schema, description, annotation, connection or identity changed
Return to approval=always
Disable automatic retries
Qualify a new version

Unknown tool or unapproved server
Do not expose it to the production agent

This rule prevents a server update from silently turning an approval-free read into a broader operation. The digest must contain no secret or token; it represents only the visible contract and its associated controls.

Canary automation on one narrow class

Do not remove approval from every read tool at once. Select one tool, one version, one identity and one agent group. Keep writes behind approval even when their annotations appear correct.

During the canary, measure unexpected calls, schema rejections, 401/403, outbound destinations, incomplete traces and differences between requested and executed actions. Add adversarial cases: an out-of-scope identifier, unknown argument, timeout after acceptance, server removing an annotation and external content containing instructions for the agent.

yaml 06-canary-gates.yml
scope:
agent: incident-reader-canary
tool: incidents.get
server_version: 2026.10.13-3
duration: 24h

promote_when:
contract_drift: 0
hidden_writes: 0
unexpected_destinations: 0
incomplete_traces: 0
out_of_scope_success: 0

rollback_when:
- digest_changed
- observed_effect_conflicts_with_annotation
- approval_bypass_reaches_write_tool
- identity_scope_broadened
- call_result_cannot_be_reconciled

Decide and roll back

Three decisions are enough.

  • Automate only the class of read calls whose server, version, identity, scope and behavior have been proven.
  • Keep approval when an annotation is missing, the world is open, the effect is sensitive or idempotency cannot be demonstrated.
  • Roll back as soon as the contract drifts or observed behavior contradicts an annotation.

Rollback restores approval=always, disables automatic retries, points back to the qualified MCP version where possible and preserves all traces. Reconcile calls with an unknown status before reopening a write tool: an agent-side timeout never proves that the backend had no effect.

Conclusion

MCP annotations provide a useful vocabulary for classifying tools, but they remain declarations. An AgentOps team can use them to reduce friction only after proving behavior, separating approval from authorization, detecting contract drift and testing an immediate return to the cautious posture.

The runbook should end with a bounded decision: automate one qualified read, keep humans on sensitive actions, or restore mandatory approval as soon as evidence no longer matches the contract.