# MentorActionRegistrations class

> The MentorActionRegistrations class of Novior.MentorAgent.Options: The actions the application registers in code, without attributes: MentorOptions.Actions…

- URL: https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionregistrations
- Verified with: MentorAgent 1.4.0
- Last updated: 2026-11-18
- Packages: Novior.MentorAgent

The actions the application registers in code, without attributes: [`MentorOptions.Actions`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions#actions). Each one is a public instance method of a class the application registers in its services, with what `[MentorAction]` would declare.

A registered action is one of the coordinator's actions, like a `[MentorAction]` method found in [`MentorOptions.ScanAssemblies`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions#scanassemblies): it is named after its method, and the same roles, confirmations, `IMentorActionGovernor`, MCP server and A2A card apply. The registrations are read once, when MentorAgent first discovers the actions. A mistake — a method that is not there, a registration without a description, a method that is already an action by its attributes — stops the application when it starts, naming the method.

```text title="Example"
options.Actions.Add<OrderActions>(nameof(OrderActions.CancelOrderAsync), action => action
    .Describe("Cancels an order that has not shipped yet")
    .RequireRoles("Manager")
    .RequireConfirmation());
```

A command or a query is registered the same way, as a type of its own with its handler: [`MentorActionRegistrations.AddCommand`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionregistrations#addcommand) and [`MentorActionRegistrations.AddQuery`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionregistrations#addquery).

## Definition

Namespace: `Novior.MentorAgent.Options`. Package: `Novior.MentorAgent`.

`public sealed class MentorActionRegistrations`

```shell
dotnet add package Novior.MentorAgent
```

## Properties

### `Count`

`public int Count { get; }`

How many actions are registered.

## Methods

### `Add`

`public MentorActionRegistrations Add<T>(string method, Action<MentorActionBuilder> configure)`

Registers `method` of `T` as an action of the coordinator.

**Parameters**

- `method`: The name of a public instance method declared on `T` itself, not generic and the only one with that name — written with `nameof`, it follows a rename.
- `configure`: What the action declares; [`MentorActionBuilder.Describe`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionbuilder#describe) is required.

**Returns:** These registrations, to add the next one.

**Exceptions**

- `ArgumentException`: `T` is not a concrete class, it has no such method or more than one, the method is static or generic, or the action has no description.

`public MentorActionRegistrations Add(Type type, string method, Action<MentorActionBuilder> configure)`

Registers `method` of `type` as an action of the coordinator: the form for code that is generated, where the type is known by name.

**Parameters**

- `type`: A class the application registers in its services: MentorAgent asks them for the instance.
- `method`: The name of a public instance method declared on `type` itself, not generic and the only one with that name.
- `configure`: What the action declares; [`MentorActionBuilder.Describe`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionbuilder#describe) is required.

**Returns:** These registrations, to add the next one.

**Exceptions**

- `ArgumentException`: `type` is not a concrete class, it has no such method or more than one, the method is static or generic, or the action has no description.

### `AddCommand`

`public MentorActionRegistrations AddCommand<TCommand, THandler>(Action<MentorActionBuilder> configure)`

Story 1286 — registers the command `TCommand` as an action of the coordinator, run by `THandler`: a request that changes data, written as a type of its own. The action is named after the type in snake\_case (`CancelOrder` is `cancel_order`) unless [`MentorActionBuilder.Name`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionbuilder#name) names it; its parameters are the type's public properties, which the model gives; it is a write, so the default confirmation for writes applies, and the same roles, governor, policies, MCP server, A2A card and teams apply as to a method registered with [`MentorActionRegistrations.Add`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionregistrations#add).

```text title="Example"
public sealed record CancelOrder(int OrderId, string Reason);
public sealed class CancelOrderHandler(OrderStore store) : IMentorCommandHandler<CancelOrder>
{
    public Task HandleAsync(CancelOrder command, CancellationToken ct) => store.CancelAsync(command.OrderId, command.Reason, ct);
}

builder.Services.AddScoped<CancelOrderHandler>();
options.Actions.AddCommand<CancelOrder, CancelOrderHandler>(a => a.Describe("Cancels an order that has not shipped"));
```

**Parameters**

- `configure`: What the action declares; [`MentorActionBuilder.Describe`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionbuilder#describe) is required.

**Returns:** These registrations, to add the next one.

**Exceptions**

- `ArgumentException`: `TCommand` is not an object with properties, `THandler` is not a concrete class or does not handle the command once, the action has no description, its name is not a tool name, or it is declared [`MentorActionBuilder.ReadOnly`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionbuilder#readonly).

### `AddQuery`

`public MentorActionRegistrations AddQuery<TQuery, THandler>(Action<MentorActionBuilder> configure)`

Story 1286 — registers the query `TQuery` as an action of the coordinator, answered by `THandler`: a request that only reads, written as a type of its own. The action is named after the type in snake\_case unless [`MentorActionBuilder.Name`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionbuilder#name) names it; its parameters are the type's public properties; it is always read-only, and the model reads what the handler returns. The same roles, confirmation, governor, policies, MCP server, A2A card and teams apply as to a method registered with [`MentorActionRegistrations.Add`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionregistrations#add).

```text title="Example"
public sealed record FindOrder(int OrderId);
public sealed class FindOrderHandler(OrderStore store) : IMentorQueryHandler<FindOrder, OrderView?>
{
    public Task<OrderView?> HandleAsync(FindOrder query, CancellationToken ct) => store.FindAsync(query.OrderId, ct);
}

builder.Services.AddScoped<FindOrderHandler>();
options.Actions.AddQuery<FindOrder, FindOrderHandler>(a => a.Describe("Reads one order"));
```

**Parameters**

- `configure`: What the action declares; [`MentorActionBuilder.Describe`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionbuilder#describe) is required.

**Returns:** These registrations, to add the next one.

**Exceptions**

- `ArgumentException`: `TQuery` is not an object with properties, `THandler` is not a concrete class or does not answer the query once, the action has no description, or its name is not a tool name.

---

- Previous: [MentorActionBuilder class](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoractionbuilder.md)
- Next: [MentorAnonymousIdentity enum](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoranonymousidentity.md)
