# MentorActionAttribute class

> The MentorActionAttribute class of Novior.MentorAgent.Attributes: Advanced Level 1 — Decorates a method to expose it as an AI action with additional…

- URL: https://docs.mentoragent.net/api/novior-mentoragent-attributes/mentoractionattribute
- Verified with: MentorAgent 1.2.0
- Last updated: 2026-10-27
- Packages: Novior.MentorAgent

Advanced Level 1 — Decorates a method to expose it as an AI action with additional metadata. For simple cases, the native .NET `[Description("...")]` is sufficient — zero dependencies. Use `[MentorAction]` when you need confirmation dialogs, categories, or proactive hints.

```text title="Example"
// Simple
[MentorAction(Description = "Cancels an existing order")]
public async Task<bool> CancelOrder(int orderId, string reason) { }

// Advanced
[MentorAction(
    Description = "Cancels an existing order",
    Category = "Orders",
    RequiresConfirmation = true,
    ProactiveHint = "Suggest checking active orders first")]
public async Task<bool> CancelOrder(int orderId, string reason) { }
```

## Definition

Namespace: `Novior.MentorAgent.Attributes`. Package: `Novior.MentorAgent`.

`public sealed class MentorActionAttribute : Attribute`

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

## Constructors

`public MentorActionAttribute()`

## Properties

### `Category`

`public string? Category { get; init; }`

Free-form category, published as the skill's tag on the A2A agent card. It does not change what the assistant sees or does. Example: "Orders", "Customers", "Reports"

### `Description`

`public required string Description { get; init; }`

Natural language description used as the AI tool description.

### `NavigateTo`

`public string? NavigateTo { get; init; }`

Automatic navigation URL after tool execution (only on success). MentorAgent navigates automatically if the user is on a different page. Example: NavigateTo = "/products"

### `ProactiveHint`

`public string? ProactiveHint { get; init; }`

Guidance for the assistant about what to suggest to the user before or after this action. Appended to the tool's description as "Guidance: …" — so the model reads it when it considers the tool — without changing how the tool is matched by semantic filtering. Example: "Suggest checking active orders first"

### `ReadOnly`

`public bool ReadOnly { get; init; }`

The action only reads: it changes no data. MentorAgent does not check this; it takes your word, the way an MCP client takes a server's `readOnlyHint`. It is published to MCP clients as `readOnlyHint`, and with [`MentorOptions.RequireLookupForRecordQuestions`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions#requirelookupforrecordquestions) on such an action is one the assistant may be required to call before it answers a question about a value of your records. Ignored when the action also needs confirmation: confirmation is the mark of an action that changes data, and it wins. To declare actions by name instead — for example those marked only with `[Description]` — use [`MentorOptions.IsReadOnlyAction`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions#isreadonlyaction). Default: false

### `RequiredRoles`

`public string[] RequiredRoles { get; init; }`

Roles allowed to run the action: the user needs **any one** of them and must be authenticated. The user is the caller of the hub, of `/mentor/chat` or of A2A (Novior.MentorAgent.Server), and in a Blazor circuit the host's AuthenticationStateProvider's; with neither, nobody can run it. Tested with `ClaimsPrincipal.IsInRole` — the identity's own `RoleClaimType`, so roles in a `roles` claim (Entra ID) work too; names are case-sensitive. The same test decides the MCP surface when `McpCallerPrincipal` is set. Empty (default) = no role check at all, for signed-in and anonymous users alike.

### `RequiresConfirmation`

`public bool RequiresConfirmation { get; init; }`

If true, the widget shows a confirmation dialog before executing the action. Use for destructive or irreversible operations.

Left out, the action follows [`MentorOptions.RequireConfirmationForWrites`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions#requireconfirmationforwrites): on by default, so an action that is not [`MentorActionAttribute.ReadOnly`](https://docs.mentoragent.net/api/novior-mentoragent-attributes/mentoractionattribute#readonly) asks for confirmation. Write `RequiresConfirmation = false` to opt one action out — the declaration itself is what counts, which is why leaving it out and writing `false` are not the same.

### `RequiresConfirmationDeclared`

`public bool RequiresConfirmationDeclared { get; }`

Whether [`MentorActionAttribute.RequiresConfirmation`](https://docs.mentoragent.net/api/novior-mentoragent-attributes/mentoractionattribute#requiresconfirmation) was written in the attribute, true or false. An attribute argument cannot be a `bool?`, so the setter records it.

Read it to tell the two actions [`MentorActionAttribute.RequiresConfirmation`](https://docs.mentoragent.net/api/novior-mentoragent-attributes/mentoractionattribute#requiresconfirmation) alone cannot: with [`MentorOptions.RequireConfirmationForWrites`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions#requireconfirmationforwrites) on, an action that declares nothing asks for confirmation, and one that declares `RequiresConfirmation = false` does not, while [`MentorActionAttribute.RequiresConfirmation`](https://docs.mentoragent.net/api/novior-mentoragent-attributes/mentoractionattribute#requiresconfirmation) reads false for both. This is only what the attribute says: the confirmation an action gets also depends on [`MentorActionAttribute.ReadOnly`](https://docs.mentoragent.net/api/novior-mentoragent-attributes/mentoractionattribute#readonly) and on [`MentorOptions.IsReadOnlyAction`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions#isreadonlyaction) and [`MentorOptions.RequiresApproval`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions#requiresapproval).

---

- Previous: [Known issues](https://docs.mentoragent.net/reference/known-issues.md)
- Next: [MentorAgentAttribute class](https://docs.mentoragent.net/api/novior-mentoragent-attributes/mentoragentattribute.md)
