Skip to content

Commit 76b765a

Browse files
kblokclaude
andauthored
feat(webmcp): add UntrustedContent annotation support (#3442)
Ports upstream puppeteer PR #14901 which adds `untrustedContent` to WebMCPAnnotation, indicating tool output may contain untrusted content such as UGC or 3rd-party data. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent feb2b9a commit 76b765a

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

lib/PuppeteerSharp.Tests/WebMcpTests/PageWebMcpTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ await page.EvaluateFunctionAsync(@"() => {
3939
name: 'test-tool-1',
4040
description: 'A test tool 1',
4141
inputSchema: { type: 'object', properties: { text: { type: 'string' } }, required: ['text'] },
42-
execute: () => {},
43-
annotations: { readOnlyHint: true },
42+
execute: (params) => {
43+
return params.text;
44+
},
45+
annotations: { readOnlyHint: true, untrustedContentHint: true },
4446
});
4547
}");
4648

@@ -55,6 +57,9 @@ await page.EvaluateFunctionAsync(@"() => {
5557

5658
var tools = page.WebMcp.Tools();
5759
Assert.That(tools.Length, Is.GreaterThanOrEqualTo(2));
60+
Assert.That(tools[0].Annotations, Is.Not.Null);
61+
Assert.That(tools[0].Annotations!.ReadOnly, Is.True);
62+
Assert.That(tools[0].Annotations!.UntrustedContent, Is.True);
5863
}
5964

6065
[Test, PuppeteerTest("webmcp.spec", "Page.webmcp", "should fire toolsadded events")]

lib/PuppeteerSharp/Cdp/CdpWebMcp.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ private void OnToolsAdded(WebMcpToolsAddedProtocolEvent e)
164164
Annotations = tool.Annotations == null ? null : new WebMcpAnnotation
165165
{
166166
ReadOnly = tool.Annotations.ReadOnly,
167+
UntrustedContent = tool.Annotations.UntrustedContent,
167168
Autosubmit = tool.Annotations.Autosubmit,
168169
},
169170
Frame = frame,
@@ -306,6 +307,9 @@ private class WebMcpProtocolAnnotation
306307

307308
[JsonPropertyName("readOnly")]
308309
public bool? ReadOnly { get; set; }
310+
311+
[JsonPropertyName("untrustedContent")]
312+
public bool? UntrustedContent { get; set; }
309313
}
310314

311315
private class WebMcpProtocolRemovedTool

lib/PuppeteerSharp/Cdp/WebMcpAnnotation.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public class WebMcpAnnotation
3232
/// </summary>
3333
public bool? ReadOnly { get; set; }
3434

35+
/// <summary>
36+
/// A hint indicating that the tool output may contain untrusted content, ex: UGC, 3rd party data.
37+
/// </summary>
38+
public bool? UntrustedContent { get; set; }
39+
3540
/// <summary>
3641
/// If the declarative tool was declared with the autosubmit attribute.
3742
/// </summary>

0 commit comments

Comments
 (0)