# ProtocolServiceCollectionExtensions class

> Registers the MCP server and the A2A agent that EndpointRouteBuilderExtensions.MapMentorAgentMcp and EndpointRouteBuilderExtensions.MapMentorAgentA2A map.

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

Until 1.0.0-rc.15 `AddMentorAgent` registered both itself. They moved to this package with the endpoints (story 105) because their transports need ASP.NET Core, which `MentorAgent` no longer references — that is what lets a MAUI app reference it on Android, iOS and Mac Catalyst. `AddMentorAgentServer()` calls both, so a headless host needs nothing more; a Blazor Server host that serves MCP or A2A without the hub calls the one it needs after `AddMentorAgent`.

## Definition

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

`public static class ProtocolServiceCollectionExtensions`

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

## Methods

### `AddMentorAgentA2A`

`public static IServiceCollection AddMentorAgentA2A(this IServiceCollection services)`

Registers the A2A agent when [`MentorOptions.A2AServerEnabled`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions#a2aserverenabled) is true, so that `app.MapMentorAgentA2A()` can map it. Call it after `AddMentorAgent()`:

```text title="Example"
builder.Services.AddMentorAgent(options => { options.A2AServerEnabled = true; /* ... */ });
builder.Services.AddMentorAgentA2A();
// ...
app.MapMentorAgentA2A();
```

The flag is read as `AddMentorAgent` read it, at registration time. Calling this twice, or together with `AddMentorAgentServer()`, which calls it, registers the agent once. Called before `AddMentorAgent()` it registers nothing, and the host stops at start-up saying so; the same when `A2AServerEnabled` is turned on after `AddMentorAgent()` read it, in a `Configure` or `PostConfigure` of [`MentorOptions`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions).

### `AddMentorAgentMcp`

`public static IServiceCollection AddMentorAgentMcp(this IServiceCollection services)`

Registers the MCP server when [`MentorOptions.McpServerEnabled`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions#mcpserverenabled) is true, so that `app.MapMentorAgentMcp()` can map it. Call it after `AddMentorAgent()`:

```text title="Example"
builder.Services.AddMentorAgent(options => { options.McpServerEnabled = true; /* ... */ });
builder.Services.AddMentorAgentMcp();
// ...
app.MapMentorAgentMcp();
```

The flag is read as `AddMentorAgent` read it, at registration time. Calling this twice, or together with `AddMentorAgentServer()`, which calls it, registers the server once. Called before `AddMentorAgent()` it registers nothing, and the host stops at start-up saying so; the same when `McpServerEnabled` is turned on after `AddMentorAgent()` read it, in a `Configure` or `PostConfigure` of [`MentorOptions`](https://docs.mentoragent.net/api/novior-mentoragent-options/mentoroptions).

---

- Previous: [EndpointRouteBuilderExtensions class](https://docs.mentoragent.net/api/novior-mentoragent-extensions/endpointroutebuilderextensions.md)
- Next: [Extensions.ServiceCollectionExtensions](https://docs.mentoragent.net/api/novior-mentoragent-extensions/servicecollectionextensions.md)
