Class SpreadsheetWebMcpTool
Represents a WebMCP tool definition or customization entry associated with an SfSpreadsheet instance.
Inherited Members
Namespace: Syncfusion.Blazor.Spreadsheet
Assembly: Syncfusion.Blazor.Spreadsheet.dll
Syntax
public class SpreadsheetWebMcpTool : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Remarks
A tool can target a built-in WebMCP command through Command or define a custom tool when Command is Custom.
Custom tool execution is supplied by the host's OnWebMcpExecute event handler. The handler can inspect Name and assign Result to return a result to the AI agent.
Examples
<SfSpreadsheet EnableWebMcp="true" OnWebMcpExecute="OnWebMcpExecute"> <SpreadsheetWebMcpSettings> <SpreadsheetWebMcpTools> <SpreadsheetWebMcpTool Command="SpreadsheetWebMcpToolCommand.GetSelection" Name="readCurrentSelection" /> <SpreadsheetWebMcpTool Command="SpreadsheetWebMcpToolCommand.Custom" Name="getSalesSummary" Description="Returns a summary of sales." InputSchema="@SalesSummarySchema" /> </SpreadsheetWebMcpTools> </SpreadsheetWebMcpSettings> </SfSpreadsheet>
@code { private const string SalesSummarySchema = "{"type":"object","properties":{}}";
private void OnWebMcpExecute(SpreadsheetWebMcpExecuteEventArgs args)
{
if (args.Name == "getSalesSummary")
{
// Result is a string. Serialize complex payloads so the
// browser can forward the JSON to the AI agent verbatim.
args.Result = System.Text.Json.JsonSerializer.Serialize(
new { totalSales = 12500 });
}
}
}
Constructors
SpreadsheetWebMcpTool()
Declaration
public SpreadsheetWebMcpTool()
Properties
Command
Gets or sets the built-in WebMCP tool that this configuration entry targets, or Custom to define a custom tool.
Declaration
[Parameter]
public SpreadsheetWebMcpToolCommand Command { get; set; }
Property Value
| Type | Description |
|---|---|
| SpreadsheetWebMcpToolCommand | A SpreadsheetWebMcpToolCommand value identifying the built-in tool to customize, or Custom for a custom tool. The default value is None, which is treated as invalid configuration and the entry is skipped from registration. |
Remarks
For a built-in command, this entry can disable the tool or override its description. The Name property is ignored for built-in commands because they are identified by Command; only Custom honors the supplied Name as the tool identifier.
For a custom command, Name is required and InputSchema is recommended. The host supplies the custom tool's execution result through OnWebMcpExecute.
Description
Gets or sets the description exposed to browser-side AI agents for this tool.
Declaration
[Parameter]
public string? Description { get; set; }
Property Value
| Type | Description |
|---|---|
| string | A string describing the tool. When omitted, built-in tools retain their catalog description and custom tools use an empty description. The default value is null. |
Remarks
The description is included in the registered tool metadata and helps AI agents understand the tool's purpose.
AI agents decide when to invoke a custom tool based on its description, so a missing description is logged as a hint to the host during configuration validation. The entry is still registered.
Enabled
Gets or sets a value indicating whether this tool is included in the effective WebMCP tool catalog.
Declaration
[Parameter]
public bool Enabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool | true to include the tool; otherwise, false. The default value is true. |
Remarks
When set to false, the tool is excluded from registration. This applies to both built-in and custom tool entries.
GetRangeData is opt-in: enable it explicitly by setting this property to true.
InputSchema
Gets or sets the JSON Schema that defines the input arguments accepted by a custom tool.
Declaration
[Parameter]
public string? InputSchema { get; set; }
Property Value
| Type | Description |
|---|---|
| string | A JSON string representing a JSON Schema document. This value is only honored for Custom and is ignored for built-in commands (a debug hint is logged if the value is supplied alongside a built-in command). The default value is null. |
Remarks
The schema is included in WebMCP registration so browser-side AI agents can discover the custom tool's accepted arguments. Supply a valid JSON object as a string.
Missing or invalid InputSchema on a custom tool is logged but
does not prevent registration. The host is responsible for ensuring the
agent has the schema it needs to construct arguments.
Name
Gets or sets the tool name exposed to browser-side AI agents.
Declaration
[Parameter]
public string? Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string | A string containing the tool name. This value identifies a custom tool (when Command is Custom) and is required in that case. For built-in commands, Name is ignored because the catalog name (derived from Command) is the authoritative identifier. The default value is null. |
Remarks
A custom tool name must be unique among the tools registered for the spreadsheet. The name received by Name is the logical tool name without the browser registration prefix.
Methods
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
| Type | Name | Description |
|---|---|---|
| RenderTreeBuilder | __builder |
Overrides
Dispose()
Releases the tool entry's registration with its parent settings.
Declaration
public void Dispose()
Dispose(bool)
Releases managed resources owned by this component.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
OnInitializedAsync()
Validates and registers this tool entry with its settings container during initialization.
Declaration
protected override Task OnInitializedAsync()
Returns
| Type |
|---|
| Task |
Overrides
OnParametersSetAsync()
Detects parameter changes and notifies the parent spreadsheet to refresh its tool catalog.
Declaration
protected override Task OnParametersSetAsync()
Returns
| Type |
|---|
| Task |