Skip to content
Overview

Overview

A semantic bridge that lets AI agents read and operate Klyroo forms, dashboards and spreadsheet imports from .NET code.

On this page

An agent that drives a UI through CSS selectors breaks whenever the markup changes. Klyroo.Agent skips the markup: you register the controllers behind your UI, and the agent works with their labels, values and named actions. The bridge is plain C# with no JavaScript interop, so it behaves the same in every Blazor render mode, in .NET MAUI and in a console app.

Prerequisites

To use the library in an app:

  • The .NET 11 SDK, and an app that targets net11.0. The packages are prereleases, so every dotnet add package command needs --prerelease.
  • The controllers you expose: Klyroo.Agent references the Klyroo.Form.Core, Klyroo.Dashboard.Core and Klyroo.Spreadsheet.Core packages, so the bridge works with any app that builds a FormController<TModel> (or a DynamicFormController), a DashboardController or a SpreadsheetImporter<TRow>, rendered or not. Register it with AddKlyrooAgent().
  • An AI host that calls your code: the bridge exposes snapshot, query and act as methods and tool definitions; your MCP server, chat endpoint or tool loop calls them. The library does not call a model itself.
  • For the browser runtime (klyroo-agent.js): a browser with ES modules, the static web assets of the app served (MapStaticAssets or UseStaticFiles), and, for registerWebMcp, a browser that exposes the WebMCP modelContext API, which is still experimental.

To build this repository you need the .NET 11 SDK (a newer SDK works too, see global.json) and clones of klyroo-dashboard, klyroo-form and klyroo-spreadsheet in the same parent folder: some projects reference them by relative path (../klyroo-dashboard/...). See Contributing.

Installation

Shell
dotnet add package Klyroo.Agent --prerelease

Register the bridge in Program.cs (Blazor) or MauiProgram.cs (.NET MAUI Blazor Hybrid):

C#
using Klyroo.Agent;

builder.Services.AddKlyrooAgent();

AgentBridgeService is registered as a scoped service. The package has no stylesheet. If you only need the data types, install Klyroo.Agent.Core instead.

Quick start

Register a form, then let a caller inspect it and change it:

C#
using Klyroo.Agent;
using Klyroo.Form;

var agent = new AgentBridgeService();

var schema = FormSchema.For<Project>(s =>
{
    s.FormKey = "project-settings";
    s.Title = "Project settings";
    s.Field(p => p.Name, f => f.Label("Project name"));
    s.Field(p => p.Region, f => f.Options(
    [
        new FormOption<string>("us-east", "US East"),
        new FormOption<string>("eu-west", "Europe West"),
    ]));
});
var form = new FormController<Project>(schema, new Project());

agent.RegisterForm(form);

foreach (var component in agent.Snapshot())
{
    Console.WriteLine($"{component.Ref} {component.Component} \"{component.Label}\" = {component.Value?.ToDisplayString()}");
}
// c1 input "Project name" = Apollo
// c2 select "Region" = us-east
// c3 form "Project settings" = clean

var matches = agent.Query(new AgentQueryRequest { Within = "region", Text = "europe" });
Console.WriteLine(matches[0].Items[0].Value); // eu-west

var result = await agent.ActAsync(
[
    new AgentActStep("Project name", "setValue", ["Atlas"]),
    new AgentActStep("Region", "setValue", ["eu-west"]),
]);
Console.WriteLine(result.Ok ? "done" : result.Error);
Console.WriteLine(form.Get(schema.Field(p => p.Name))); // Atlas

public sealed class Project
{
    public string Name { get; set; } = "Apollo";

    public string Region { get; set; } = "us-east";
}

In a Blazor component, inject the scoped service instead of creating one, as shown in Getting started.

Documentation

Getting started Step-by-step first integration
Guides Task-oriented recipes
Concepts How the library works
Platforms Render modes, .NET MAUI, NativeAOT
API reference Every public type and member
FAQ Troubleshooting and limitations

Compatibility

  • .NET 11 SDK.
  • Klyroo.Agent.Core declares IsAotCompatible and IsTrimmable, so it works in NativeAOT and trimmed apps.
  • Klyroo.Agent declares IsTrimmable and the supported platforms browser, ios, android, maccatalyst and windows. It does not declare IsAotCompatible.
  • AgentBridgeService has no dependency on a render mode: it works in Static SSR, Interactive Server, WebAssembly, Auto, .NET MAUI Blazor Hybrid and non-UI hosts.
  • The browser runtime needs a browser; WebMCP registration is skipped when the browser has no modelContext API.

Contributing

Contributions are welcome. Read CONTRIBUTING.md before opening a pull request, and follow the code of conduct. Report security issues privately as described in SECURITY.md.

License

MIT