Architecture at a glance
Authentication
Templates resolve per-user, so the calling identity determines what’s visible. A User-scoped template authored by Alice is not visible to a Bob-authenticated MCP session, even within the same organization.
Template keys
Every template has a stable key — the string your agent uses to refer to it. Three conventions:
Keys are case-sensitive. Treat them as opaque identifiers in your code — Deal Brain may add new system keys over time, but existing ones won’t change.
The render contract
A call togenerate_template does six things:
- Resolves the template by key, applying User > Org > System precedence for the calling user.
- Verifies status is
Active. Draft templates return an error. - Binds context — opportunity ID, identity (user/org), and any additional variables you pass.
- Substitutes data variables with their resolved values; preserves missing values as empty strings.
- Emits the rendered body — markdown with
datavariables filled in andinstructionvariables flagged as model directives. - Returns the system prompt + rendered body in two text blocks, with cache hints for the model.
Tracing
Every Canvas render emits a Langfuse trace with these metadata fields:
Use these for usage analytics, debugging, and audit.
Next steps
MCP tool contract
The full
generate_template and list_templates reference — input schemas, output shapes, error modes, and integration patterns.
