1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
// @generated by `just generate-methods` from protocol/*.json.
// Do not edit by hand; edit xtask/ and regenerate.
//! The `WebMCP` domain.
//!
//! Types, command parameters and event payloads for the `WebMCP`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].
//!
//! This domain is experimental and may change without notice.
use serde::{Deserialize, Serialize};
/// Tool annotations
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Annotation {
/// A hint indicating that the tool does not modify any state.
#[serde(rename = "readOnly", default, skip_serializing_if = "Option::is_none")]
pub read_only: Option<bool>,
/// A hint indicating that the tool output may contain untrusted content, ex:
/// UGC, 3rd party data.
#[serde(
rename = "untrustedContent",
default,
skip_serializing_if = "Option::is_none"
)]
pub untrusted_content: Option<bool>,
/// A hint indicating that executing the tool will result in consequential
/// actions, ex: booking a flight, transferring money.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub consequential: Option<bool>,
/// If true, indicates that the tool is intended for debugging and developer
/// tooling rather than end-user interactions.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub debugging: Option<bool>,
/// If the declarative tool was declared with the autosubmit attribute.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub autosubmit: Option<bool>,
}
/// Represents the status of a tool invocation.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum InvocationStatus {
/// `Completed`
Completed,
/// `Canceled`
Canceled,
/// `Error`
Error,
/// A value this vendored schema does not list. Chrome adds values ahead of
/// the published protocol, so an unrecognised one is kept as it arrived
/// rather than failing the payload it came in.
#[serde(untagged)]
Unrecognized(String),
}
/// Unique identifier of a registered tool. A new identifier is created every
/// time a tool is registered, so a tool that is unregistered and then
/// registered again under the same name gets a different identifier. Clients
/// should treat it as an opaque string.
pub type ToolId = String;
/// Definition of a tool that can be invoked.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Tool {
/// Tool identifier.
#[serde(rename = "toolId")]
pub tool_id: ToolId,
/// Tool name.
pub name: String,
/// Tool description.
pub description: String,
/// Schema for the tool's input parameters.
#[serde(
rename = "inputSchema",
default,
skip_serializing_if = "Option::is_none"
)]
pub input_schema: Option<serde_json::Value>,
/// Schema for the tool's output structure.
#[serde(
rename = "outputSchema",
default,
skip_serializing_if = "Option::is_none"
)]
pub output_schema: Option<serde_json::Value>,
/// Optional annotations for the tool.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotations: Option<Annotation>,
/// Frame identifier associated with the tool registration.
#[serde(rename = "frameId")]
pub frame_id: crate::protocol::page::FrameId,
/// Optional node ID for declarative tools.
#[serde(
rename = "backendNodeId",
default,
skip_serializing_if = "Option::is_none"
)]
pub backend_node_id: Option<crate::protocol::dom::BackendNodeId>,
/// The stack trace at the time of the registration.
#[serde(
rename = "stackTrace",
default,
skip_serializing_if = "Option::is_none"
)]
pub stack_trace: Option<crate::protocol::runtime::StackTrace>,
}
/// Definition of a tool that was removed.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RemovedTool {
/// Identifier of the removed tool.
#[serde(rename = "toolId")]
pub tool_id: ToolId,
/// Tool name.
pub name: String,
/// Frame identifier associated with the tool registration.
#[serde(rename = "frameId")]
pub frame_id: crate::protocol::page::FrameId,
}
/// Enables the WebMCP domain, allowing events to be sent. Enabling the domain
/// will trigger a toolsAdded event for all currently registered tools.
///
/// Parameters of `WebMCP.enable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {}
impl crate::typed::Command for EnableParams {
const METHOD: &'static str = "WebMCP.enable";
type Returns = crate::typed::NoReturns;
}
/// Disables the WebMCP domain.
///
/// Parameters of `WebMCP.disable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}
impl crate::typed::Command for DisableParams {
const METHOD: &'static str = "WebMCP.disable";
type Returns = crate::typed::NoReturns;
}
/// Invokes a registered tool.
///
/// Parameters of `WebMCP.invokeTool`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct InvokeToolParams {
/// Frame in which to invoke the tool.
#[serde(rename = "frameId")]
pub frame_id: crate::protocol::page::FrameId,
/// Name of the tool to invoke.
#[serde(rename = "toolName")]
pub tool_name: String,
/// Input parameters for the tool, matching the tool's inputSchema.
pub input: serde_json::Value,
}
/// What `WebMCP.invokeTool` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct InvokeToolReturns {
/// Unique identifier for this invocation. Response is sent before tool
/// events.
#[serde(rename = "invocationId")]
pub invocation_id: String,
}
impl crate::typed::Command for InvokeToolParams {
const METHOD: &'static str = "WebMCP.invokeTool";
type Returns = InvokeToolReturns;
}
/// Cancels a pending tool invocation.
///
/// Parameters of `WebMCP.cancelInvocation`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CancelInvocationParams {
/// Invocation identifier to cancel.
#[serde(rename = "invocationId")]
pub invocation_id: String,
}
impl crate::typed::Command for CancelInvocationParams {
const METHOD: &'static str = "WebMCP.cancelInvocation";
type Returns = crate::typed::NoReturns;
}
/// Event fired when new tools are added.
///
/// Payload of the `WebMCP.toolsAdded` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ToolsAddedEvent {
/// Array of tools that were added.
pub tools: Vec<Tool>,
}
impl crate::typed::Event for ToolsAddedEvent {
const METHOD: &'static str = "WebMCP.toolsAdded";
}
/// Event fired when tools are removed.
///
/// Payload of the `WebMCP.toolsRemoved` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ToolsRemovedEvent {
/// Array of tools that were removed.
pub tools: Vec<RemovedTool>,
}
impl crate::typed::Event for ToolsRemovedEvent {
const METHOD: &'static str = "WebMCP.toolsRemoved";
}
/// Event fired when a tool invocation starts.
///
/// Payload of the `WebMCP.toolInvoked` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ToolInvokedEvent {
/// Frame id
#[serde(rename = "frameId")]
pub frame_id: crate::protocol::page::FrameId,
/// Invocation identifier.
#[serde(rename = "invocationId")]
pub invocation_id: String,
/// The input parameters used for the invocation.
pub input: String,
/// Name of the tool to invoke. Missing if the tool was invoked by its
/// identifier, but could not be found (e.g., it was already unregistered), so
/// its name could not be recovered.
#[serde(rename = "toolName", default, skip_serializing_if = "Option::is_none")]
pub tool_name: Option<String>,
/// Identifier of the tool to invoke. Missing if the tool was invoked by name,
/// but could not be found, so its identifier could not be recovered.
#[serde(rename = "toolId", default, skip_serializing_if = "Option::is_none")]
pub tool_id: Option<ToolId>,
}
impl crate::typed::Event for ToolInvokedEvent {
const METHOD: &'static str = "WebMCP.toolInvoked";
}
/// Event fired when a tool invocation completes or fails.
///
/// Payload of the `WebMCP.toolResponded` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ToolRespondedEvent {
/// Invocation identifier.
#[serde(rename = "invocationId")]
pub invocation_id: String,
/// Status of the invocation.
pub status: InvocationStatus,
/// Output or error delivered as delivered to the agent. Missing if `status`
/// is anything other than Completed. Note: The output is untrusted and poses
/// a prompt injection risk. Clients should treat this as potentially
/// malicious user input.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub output: Option<serde_json::Value>,
/// Error text for protocol users.
#[serde(rename = "errorText", default, skip_serializing_if = "Option::is_none")]
pub error_text: Option<String>,
/// The exception object, if the javascript tool threw an error\>
#[serde(default, skip_serializing_if = "Option::is_none")]
pub exception: Option<crate::protocol::runtime::RemoteObject>,
}
impl crate::typed::Event for ToolRespondedEvent {
const METHOD: &'static str = "WebMCP.toolResponded";
}