Blazor.WebMcpKit
1.0.0-preview.1
dotnet add package Blazor.WebMcpKit --version 1.0.0-preview.1
NuGet\Install-Package Blazor.WebMcpKit -Version 1.0.0-preview.1
<PackageReference Include="Blazor.WebMcpKit" Version="1.0.0-preview.1" />
<PackageVersion Include="Blazor.WebMcpKit" Version="1.0.0-preview.1" />
<PackageReference Include="Blazor.WebMcpKit" />
paket add Blazor.WebMcpKit --version 1.0.0-preview.1
#r "nuget: Blazor.WebMcpKit, 1.0.0-preview.1"
#:package Blazor.WebMcpKit@1.0.0-preview.1
#addin nuget:?package=Blazor.WebMcpKit&version=1.0.0-preview.1&prerelease
#tool nuget:?package=Blazor.WebMcpKit&version=1.0.0-preview.1&prerelease
Blazor.WebMcpKit
Created by the Telerik UI for Blazor team, Blazor.WebMCPKit is an open-source library that enables any Blazor component to expose WebMCP tools and become agent-aware.
A lightweight library for exposing Blazor component methods as WebMCP tools that AI agents can discover and invoke directly in the browser.
Installation
dotnet add package Blazor.WebMcpKit
Setup
Register the WebMCP services in Program.cs:
using Blazor.WebMcpKit.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddWebMcp();
Namespaces
| Namespace | Contains |
|---|---|
Blazor.WebMcpKit |
Everything you need: WebMcpComponentBase, WebMcpToolAttribute, WebMcpParamAttribute, WebMcpIgnoreAttribute, IWebMcpRegistry, WebMcpToolDefinition, WebMcpToolAnnotations, WebMcpInputSchema |
Blazor.WebMcpKit.Extensions |
AddWebMcp() — the IServiceCollection extension used in Program.cs |
Add the following @using to your _Imports.razor (or per-component) to access all public types:
@using Blazor.WebMcpKit
For the DI registration helper add this once in Program.cs:
using Blazor.WebMcpKit.Extensions;
Attribute-based registration
Inherit from WebMcpComponentBase and decorate methods with [WebMcpTool]. Tools are registered automatically on first render and unregistered on disposal.
@page "/shop"
@inherits WebMcpComponentBase
@code {
[WebMcpTool("get_products",
Description = "Returns a list of available products.",
ReadOnly = true)]
public string GetProducts()
{
return JsonSerializer.Serialize(_products);
}
[WebMcpTool("add_to_cart",
Description = "Adds a product to the shopping cart.",
ReadOnly = false)]
public async Task<string> AddToCart(
[WebMcpParam("Product SKU", Required = true)] string sku,
[WebMcpParam("Quantity")] int qty = 1)
{
await CartService.AddAsync(sku, qty);
return $"Added {qty}x {sku} to cart.";
}
}
[WebMcpTool] options
| Property | Type | Description |
|---|---|---|
name (ctor) |
string |
Tool name in snake_case. Must be unique per page. |
Description |
string |
Natural-language description used by the agent to decide when to call the tool. |
ReadOnly |
bool |
true for read-only operations (search, list). Default false. |
UntrustedContent |
bool |
true when the tool returns user-generated or external data. Default false. |
ExposedTo |
string? |
Comma-separated HTTPS origins allowed to access this tool cross-origin. |
[WebMcpParam] options
| Property | Type | Description |
|---|---|---|
description (ctor) |
string |
Natural-language description of the parameter. |
Required |
bool |
Whether the agent must supply this parameter. Default false. |
Enum |
string[]? |
Restricts the parameter to a fixed set of string values. |
EnumTitles |
string[]? |
Human-readable label for each Enum value (must match length). |
[WebMcpIgnore]
Excludes a parameter from the generated JSON Schema entirely — use it for injected services, CancellationToken, or any framework type the agent should not see.
[WebMcpTool("export", Description = "Exports data.", ReadOnly = true)]
public string Export(
[WebMcpParam("Format", Enum = ["json", "csv"])] string format = "json",
[WebMcpIgnore] ILogger<MyComponent> logger = null!)
{
logger?.LogInformation("Exporting as {Format}", format);
// ...
}
Programmatic registration
Use IWebMcpRegistry directly when you need conditional or dynamic tool registration:
@inherits WebMcpComponentBase
@code {
private bool _clearRegistered;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
await SyncClearToolAsync();
}
private async Task SyncClearToolAsync()
{
var hasDone = _items.Any(i => i.Done);
if (hasDone && !_clearRegistered)
{
await WebMcpRegistry.RegisterToolAsync(new WebMcpToolDefinition
{
Name = "clear_completed",
Description = "Removes all completed items. Only available when at least one item is done.",
Annotations = new WebMcpToolAnnotations(ReadOnlyHint: false),
InputSchema = new WebMcpInputSchema { Type = "object" },
Execute = async _ =>
{
var count = _items.RemoveAll(i => i.Done);
StateHasChanged();
return $"Cleared {count} item(s).";
}
});
_clearRegistered = true;
}
else if (!hasDone && _clearRegistered)
{
await WebMcpRegistry.UnregisterToolAsync("clear_completed");
_clearRegistered = false;
}
}
}
Trying the tools with an agent
Open the playground page in the browser and connect a WebMCP-compatible agent. A quick way to do this is the Telerik WebMCP browser extension, which exposes the registered tools to any MCP-aware AI assistant.
Legal Notice
Progress reserves all rights in any Progress or Telerik trademarks displayed or used within any of the materials. Any future versions or updates of the Works may be licensed under different terms.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.WebAssembly (>= 10.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.1 | 54 | 7/7/2026 |