Interface IWebMCP
[Experimental("BIDICDP001")]
public interface IWebMCP
Properties
ToolInvoked
Event fired when a tool invocation starts.
IEventSource<ToolInvokedEventArgs> ToolInvoked { get; }
Property Value
- IEventSource<ToolInvokedEventArgs>
Remarks
Event args (ToolInvokedEventArgs):
- ToolName - Name of the tool to invoke.
- FrameId - Frame id
- InvocationId - Invocation identifier.
- Input - The input parameters used for the invocation.
ToolResponded
Event fired when a tool invocation completes or fails.
IEventSource<ToolRespondedEventArgs> ToolResponded { get; }
Property Value
- IEventSource<ToolRespondedEventArgs>
Remarks
Event args (ToolRespondedEventArgs):
- InvocationId - Invocation identifier.
- Status - Status of the invocation.
- Output - 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.
- ErrorText - Error text for protocol users.
- Exception - The exception object, if the javascript tool threw an error>
ToolsAdded
Event fired when new tools are added.
IEventSource<ToolsAddedEventArgs> ToolsAdded { get; }
Property Value
- IEventSource<ToolsAddedEventArgs>
Remarks
Event args (ToolsAddedEventArgs):
- Tools - Array of tools that were added.
ToolsRemoved
Event fired when tools are removed.
IEventSource<ToolsRemovedEventArgs> ToolsRemoved { get; }
Property Value
- IEventSource<ToolsRemovedEventArgs>
Remarks
Event args (ToolsRemovedEventArgs):
- Tools - Array of tools that were removed.
Methods
CancelInvocationAsync(string, string?, CancellationToken)
Cancels a pending tool invocation.
Task<CancelInvocationResult> CancelInvocationAsync(string invocationId, string? session = null, CancellationToken cancellationToken = default)
Parameters
invocationIdstringInvocation identifier to cancel.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<CancelInvocationResult>
A task representing the asynchronous operation, containing a CancelInvocationResult.
DisableAsync(string?, CancellationToken)
Disables the WebMCP domain.
Task<DisableResult> DisableAsync(string? session = null, CancellationToken cancellationToken = default)
Parameters
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<DisableResult>
A task representing the asynchronous operation, containing a DisableResult.
EnableAsync(string?, CancellationToken)
Enables the WebMCP domain, allowing events to be sent. Enabling the domain will trigger a toolsAdded event for all currently registered tools.
Task<EnableResult> EnableAsync(string? session = null, CancellationToken cancellationToken = default)
Parameters
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<EnableResult>
A task representing the asynchronous operation, containing a EnableResult.
InvokeToolAsync(FrameId, string, JsonElement, string?, CancellationToken)
Invokes a registered tool.
Task<InvokeToolResult> InvokeToolAsync(FrameId frameId, string toolName, JsonElement input, string? session = null, CancellationToken cancellationToken = default)
Parameters
frameIdFrameIdFrame in which to invoke the tool.
toolNamestringName of the tool to invoke.
inputJsonElementInput parameters for the tool, matching the tool's inputSchema.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<InvokeToolResult>
A task representing the asynchronous operation, containing a InvokeToolResult.