# Intelligent module composition

> How an assistant picks, adds, moves and removes the sections of an email from your library, using what each module is for, inside the library's rules.

Source: https://stensul.com/developers/concepts/module-composition/ · Last reviewed 2026-10-07

A template gives an email its starting shape. **Module composition** is what happens after: the assistant decides which sections the brief needs, adds them from the library, puts them in order and removes what doesn't belong. It works only with modules your library already has, so every section is still an approved, governed one.

## How the assistant knows what each module is for

`stensul-get-libraries`, called with a library key, returns the library's module inventory in library order. For each module it gives the key, the name, a **category** and a **rationale** saying what the module is for, and the styling variations it supports. The assistant matches the brief against those descriptions rather than guessing from module names alone.

## What it can do

| To | The assistant uses |
| --- | --- |
| Start from an approved shape | [`stensul-build-email`](https://stensul.com/developers/reference/stensul-build-email/) with a template or an existing email |
| Add a section by name ("add a testimonial block above the button") | [`stensul-add-email-module`](https://stensul.com/developers/reference/stensul-add-email-module/) |
| Reorder sections | `new_order` on [`stensul-update-email-content`](https://stensul.com/developers/reference/stensul-update-email-content/) |
| Remove a section | [`stensul-delete-email-module`](https://stensul.com/developers/reference/stensul-delete-email-module/) |
| Restyle a section or the whole email | [`stensul-apply-email-variation`](https://stensul.com/developers/reference/stensul-apply-email-variation/) |

## The rules still apply

- **Only library modules.** The assistant can't invent a section or write markup. If nothing in the library matches what you asked for, it says so.
- **Fixed headers and footers stay put.** A library can fix modules at the top or bottom of every email. They can't be added, and new sections always land above a fixed footer.
- **Ambiguity goes back to you.** When more than one module matches a name, the tool returns a numbered list and the assistant asks which one you meant.
- **Guardrails and locked content** apply to every added section, as they do anywhere else. See [Guardrails](https://stensul.com/developers/concepts/guardrails/).

## Not yet

Today an assistant composes by starting from a template or an existing email, then adding, moving and removing modules. Building a whole email from module descriptions alone, with no starting template or email, isn't available through the MCP yet.

## Try it

```text
In the Stensul draft "<email name>", add a customer testimonial section above
the main button, then move the event details to the top. Ask me if more than
one testimonial module fits.
```
