# MentorServerUserContext class

> The MentorServerUserContext class of Novior.MentorAgent.Server.Auth: Scoped holder for the authenticated principal of a SignalR connection. Each connection…

- URL: https://docs.mentoragent.net/api/novior-mentoragent-server-auth/mentorserverusercontext
- Verified with: MentorAgent 1.2.0
- Last updated: 2026-10-27
- Packages: Novior.MentorAgent.Server

Scoped holder for the authenticated principal of a SignalR connection. Each connection has one DI scope of its own (`MentorHubScopes`), built on connect and reused for every hub method; SignalR's own scope per method call is not the one MentorAgent runs in. [`MentorHub`](https://docs.mentoragent.net/api/novior-mentoragent-server-hubs/mentorhub) writes `Context.User` into this holder at the start of each method (with the connection id), so the principal is the current one even if the connection's token was refreshed. `ServerAuthenticationStateProvider` then surfaces it to the MentorAgent core, which resolves the current user through the standard `AuthenticationStateProvider` abstraction.

## Definition

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

`public sealed class MentorServerUserContext`

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

## Constructors

`public MentorServerUserContext()`

## Properties

### `User`

`public ClaimsPrincipal? User { get; set; }`

The authenticated principal for the current hub invocation, if any.

---

- Previous: [UIActionInfo class](https://docs.mentoragent.net/api/novior-mentoragent-abstractions-models/uiactioninfo.md)
- Next: [MentorSseEndpoint class](https://docs.mentoragent.net/api/novior-mentoragent-server-endpoints/mentorsseendpoint.md)
