Expose MCP read-only hints in tool call items (#36055)

## What changed

- Propagate MCP tool `readOnlyHint` annotations through tool-call start and
  completion events.
- Include the optional hint in persisted thread history and app-server
  `mcpToolCall` items, preserving compatibility when the annotation is absent.
- Document that the hint describes tool capability, not the outcome of a
  particular invocation.

## Testing

- Cover read-only and write-capable tools in live events and persisted rollout
  data.
- Verify the hint survives thread reads and resumes for both in-progress and
  completed MCP calls.

GitOrigin-RevId: dddfe905146075e5137a1094da485b86b99807f0
This commit is contained in:
bear-oai authored and copyberry committed 2026-07-30 01:37:41 +00:00
1 parent 1c5f336c40
commit 406dc92394
38 files changed
+406 -2

No files matched your search

+6
View File
@@ -340,6 +340,7 @@ struct McpToolCallItemMetadata {
app_name: Option<String>,
action_name: Option<String>,
plugin_id: Option<String>,
read_only_hint: Option<bool>,
}
impl McpToolCallItemMetadata {
@@ -364,6 +365,9 @@ impl McpToolCallItemMetadata {
.filter(|action_name| !action_name.is_empty())
.map(str::to_string),
plugin_id: metadata.and_then(|metadata| metadata.plugin_id.clone()),
read_only_hint: metadata
.and_then(|metadata| metadata.annotations.as_ref())
.and_then(|annotations| annotations.read_only_hint),
}
}
}
@@ -918,6 +922,7 @@ async fn notify_mcp_tool_call_started(
app_name: item_metadata.app_name,
action_name: item_metadata.action_name,
plugin_id: item_metadata.plugin_id,
read_only_hint: item_metadata.read_only_hint,
status: McpToolCallStatus::InProgress,
result: None,
error: None,
@@ -962,6 +967,7 @@ async fn notify_mcp_tool_call_completed(
app_name: item_metadata.app_name,
action_name: item_metadata.action_name,
plugin_id: item_metadata.plugin_id,
read_only_hint: item_metadata.read_only_hint,
status,
result,
error,