Class GridWebMcpTool
Represents a WebMCP tool definition or customization entry associated with an SfGrid<TValue> instance.
Inherited Members
Namespace: Syncfusion.Blazor.Grids
Assembly: Syncfusion.Blazor.Grids.dll
Syntax
public class GridWebMcpTool : SfOwningComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Remarks
A tool can either customize a built-in WebMCP command by specifying a value from GridWebMcpToolCommand through the Command property, or define a fully custom tool by setting Command to Custom.
Built-in tools inherit their default behavior from the grid and can be customized by overriding properties such as name, description, input schema, and enabled state.
Custom tools do not provide built-in execution logic. Applications must handle tool invocations through the OnWebMcpExecute event and provide an appropriate execution result.
Tool names should be unique within a page. When multiple WebMCP-enabled grids
are present, use GridWebMcpSettings.Name to help avoid tool-name
collisions.
Examples
<SfGrid DataSource="@Orders" EnableWebMcp="true" AllowFiltering="true"> <GridWebMcpSettings Name="SalesGrid"> <GridWebMcpTools> <GridWebMcpTool Command="GridWebMcpToolCommand.FilterByColumn" Name="filterOrders" Description="Filter grid records by a column." />
<GridWebMcpTool
Command="GridWebMcpToolCommand.Custom"
Name="getTopCustomers"
Description="Returns the top customers."
InputSchema="@(new
{
type = "object",
properties = new { }
})" />
</GridWebMcpTools>
</GridWebMcpSettings>
<GridEvents TValue="OrderData" OnWebMcpExecute="HandleToolExecute" />
</SfGrid>
@code { private Task HandleToolExecute(GridWebMcpExecuteEventArgs args) { if (args.Name == "getTopCustomers") { args.Result = new { Customers = new[] { "Customer A", "Customer B" } }; }
return Task.CompletedTask;
}
}
Constructors
GridWebMcpTool()
Declaration
public GridWebMcpTool()
Properties
Command
Gets or sets the WebMCP command associated with this tool configuration.
Declaration
[Parameter]
public GridWebMcpToolCommand Command { get; set; }
Property Value
| Type | Description |
|---|---|
| GridWebMcpToolCommand | A GridWebMcpToolCommand that identifies the built-in tool to customize or specifies a custom tool through Custom. The default value is None. |
Remarks
For built-in commands, this property identifies the WebMCP tool whose metadata, schema, or availability can be customized through the current GridWebMcpTool configuration.
Set this property to Custom to register a custom tool that is not provided by the grid. Custom tools must define a unique Name, a Description, and an InputSchema.
Custom tool execution is not handled automatically by the grid. Applications must process tool invocations through the OnWebMcpExecute event and provide a result by setting Result. A custom tool cannot be configured unless this event has an assigned handler.
The value None is reserved as the default state and does not represent a valid configured tool. A tool entry should specify either a built-in command or Custom.
Description
Gets or sets the description exposed to browser-side agents for this tool.
Declaration
[Parameter]
public string? Description { get; set; }
Property Value
| Type | Description |
|---|---|
| string | A string containing the tool description. This parameter is optional for built-in tools, which use the catalog description when it is omitted. Custom tools must supply a non-empty description. |
Remarks
The description is included in the registered tool metadata and can be used by AI agents to understand the purpose and expected behavior of the tool. A non-empty description is validated when Command is Custom.
Enabled
Gets or sets a value indicating whether the targeted built-in tool is enabled.
Declaration
[Parameter]
public bool Enabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool | A bool indicating whether the tool should be included in the effective WebMCP tool catalog. The default value is true. |
Remarks
When set to false, the referenced built-in tool is excluded from registration and is not exposed to browser-side agents.
This property applies only to entries that target a built-in tool through Command. Custom tools are always included.
For custom tools, registration is controlled by the presence of a valid Name, Description, and InputSchema definition, together with the associated OnWebMcpExecute handler.
Setting Enabled for a custom tool has no effect on tool registration or execution behavior.
InputSchema
Gets or sets the JSON Schema that defines the input arguments accepted by this tool.
Declaration
[Parameter]
public object? InputSchema { get; set; }
Property Value
| Type | Description |
|---|---|
| object | An object representing a JSON Schema document. For built-in tools, the supplied schema replaces the default catalog schema. Custom tools must supply a valid object schema. |
Remarks
The schema is exposed during WebMCP tool registration and allows browser agents to discover the parameters accepted by the tool.
For built-in tools, this property overrides the catalog-defined schema. For custom tools, the schema is required and defines the supported input arguments and validation rules.
Invalid schema objects may prevent tool registration or cause runtime errors. Applications are responsible for supplying a valid JSON Schema document.
Name
Gets or sets the tool name exposed to browser-side agents.
Declaration
[Parameter]
public string? Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string | A string representing the public tool name. For built-in tools, when no value is specified, the default tool name defined by the grid is used. For custom tools, this property specifies the unique identifier exposed through WebMCP registration. The default value is null. |
Remarks
For built-in tools, this property can be used to override the default tool name exposed to AI agents. Renaming a built-in tool changes only the exposed name and does not affect the underlying implementation or execution behavior.
For custom tools, this property is required and uniquely identifies the tool during registration and execution.
During tool execution, the configured tool name is available through Name, allowing applications to identify the invoked tool and provide an appropriate result.
Tool names should be unique within the application. When multiple WebMCP-enabled grids are present on the same page, Name can be used to help avoid naming conflicts.
Methods
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
| Type | Name | Description |
|---|---|---|
| RenderTreeBuilder | __builder |
Overrides
OnInitializedAsync()
Initializes the tool entry and registers it with the parent
GridWebMcpSettings. Sets
BaseParent.HasWebMcpSettingsChanges so the grid invalidates
its cached effective-tools list on the next render.
Declaration
protected override Task OnInitializedAsync()
Returns
| Type |
|---|
| Task |
Overrides
OnParametersSetAsync()
Detects parameter mutations and flips the parent's
HasWebMcpSettingsChanges flag.
Declaration
protected override Task OnParametersSetAsync()
Returns
| Type |
|---|
| Task |