# MentorEndpointActionExtensions class

> Story 1287 — an endpoint of the application as an action of the coordinator, without writing it again:

- URL: https://docs.mentoragent.net/api/novior-mentoragent-server-extensions/mentorendpointactionextensions
- Verified with: MentorAgent 1.4.0
- Last updated: 2026-11-18
- Packages: Novior.MentorAgent.Server

```text title="Example"
app.MapPost("/orders/{id}/cancel", CancelOrder)
   .WithName("CancelOrder")
   .WithMentorAction(a => a.Describe("Cancels an order").RequireRoles("Manager"));
```

The action runs the endpoint itself, in the process, as the user of the turn: its authorization first, then its filters, its binding and its validation. A controller's action is declared with `[MentorAction]` on its method. Needs `AddMentorAgentServer()`.

## Definition

Namespace: `Novior.MentorAgent.Server.Extensions`. Package: `Novior.MentorAgent.Server`.

`public static class MentorEndpointActionExtensions`

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

## Methods

### `WithMentorAction`

`public static TBuilder WithMentorAction<TBuilder>(this TBuilder builder, Action<MentorActionBuilder> configure)`

Declares the endpoint as an action of the coordinator, named after the endpoint's name (`WithName`) or its handler's method, in snake\_case. A lambda without `WithName` needs [`MentorEndpointActionExtensions.WithMentorAction`](https://docs.mentoragent.net/api/novior-mentoragent-server-extensions/mentorendpointactionextensions#withmentoraction).

`public static TBuilder WithMentorAction<TBuilder>(this TBuilder builder, string name, Action<MentorActionBuilder> configure)`

Declares the endpoint as an action of the coordinator named `name`, as a model's tool name: letters, digits, `_` and `-`, up to 64.

---

- Previous: [MentorSseEndpoint.ChatRequest record](https://docs.mentoragent.net/api/novior-mentoragent-server-endpoints/mentorsseendpoint-chatrequest.md)
- Next: [ServerEndpointExtensions class](https://docs.mentoragent.net/api/novior-mentoragent-server-extensions/serverendpointextensions.md)
