# Declarative.ServiceCollectionExtensions

> The ServiceCollectionExtensions class of Novior.MentorAgent.Declarative: Registers YAML-defined Level-2 specialists (roadmap #23).

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

Registers YAML-defined Level-2 specialists (roadmap \#23).

## Definition

Namespace: `Novior.MentorAgent.Declarative`. Package: `Novior.MentorAgent.Declarative`.

`public static class ServiceCollectionExtensions`

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

## Methods

### `AddMentorAgentDeclarative`

`public static IServiceCollection AddMentorAgentDeclarative(this IServiceCollection services, Action<MentorDeclarativeOptions> configure)`

Loads agent definitions from YAML and adds them to MentorAgent's handoff graph, alongside the ones declared with `[MentorAgent]`.

```text title="Example"
builder.Services.AddMentorAgentDeclarative(o => o.Directory = "Agents");
builder.Services.AddMentorAgent(o => { /* … */ });   // order does not matter
```

A definition looks like this — note that `tools`**names** tools, it does not define them; each name must match a tool your application already exposes:

```text title="Example"
kind: Prompt
name: ShippingAgent
description: Answers questions about deliveries and shipping costs
instructions: |
  You handle shipping questions only. Use the available tools to look up real orders;
  never invent a tracking number. If the question is not about shipping, say so.
model:
  options:
    temperature: 0.2
tools:
  - kind: function          # required on every entry; `function` is the only kind kept
    name: get_order_status
  - kind: function
    name: get_all_orders
```

**Treat definition files as code.** They choose the model, write the system instructions and name the callable tools, so load them only from a location that ships with the application. What they cannot do is grant themselves anything new: a named tool is resolved from the ones already registered and arrives already wrapped in MentorAgent's gate, keeping `RequiredRoles` and human approval in force. The provider-hosted kinds the Agent Framework also reads (`webSearch`, `codeInterpreter`, `fileSearch`, `mcp`) are removed with a warning: those capabilities are the host's to configure.

---

- Previous: [MentorDeclarativeOptions class](https://docs.mentoragent.net/api/novior-mentoragent-declarative/mentordeclarativeoptions.md)
- Next: [IMentorSessionManager interface](https://docs.mentoragent.net/api/global/imentorsessionmanager.md)
