The fastest way to lose control of a number is to let every consumer compute it. The dashboard team writes one query, the application team another, the agent team a third, and within a quarter the three disagree. A context layer exists to stop that: define the answer once, govern it once, and serve it to everything that needs it.
This post walks through what that means in practice in InsightCompose. One context, published once, reaches a REST API, the tools an agent sees over MCP, a dashboard tile, a panel inside an application your team already runs, and a person's home page. Every one of those paths goes through the same service, so the scope, the masking, the row cap and the audit are identical whichever door the caller came through.
The temptation to fork the answer
Every new consumer arrives with a good reason to have its own version. The dashboard needs a different grouping. The agent needs a smaller payload. The partner portal needs one customer's rows only. The easy answer each time is a new query, and each new query is a new place for the definition of premium, retention or open claim to drift.
The alternative is to make the context flexible enough that consumers do not need their own: typed parameters for the filters they pass, declared output columns for the shape they rely on, a scope rule that confines each caller to their rows, and a rollup for totals. With those four, the dashboard, the agent and the portal are calling the same thing with different arguments.
The consumers, one by one
REST for applications
Applications call the context by key over HTTP. The catalog of published contracts is at /api/dataapi/contracts; each one lists its parameters with types, defaults and allowed values, its output columns with labels and units, its freshness, its row scope and its row cap. A query posts parameter values and gets back the typed envelope: columns, rows, as_of, whether anything was truncated or masked.
MCP for agents
Published contexts appear as tools on the InsightCompose MCP server at /mcp, over Streamable HTTP or stdio. The tool's input schema is the context's parameter contract; its description includes the example phrasings the owner wrote, so an assistant picks the right context for a question. The server authenticates the caller with a bearer key or OAuth, applies the key's scopes and rate limit, and records the call. See serving context over MCP for the connection details.
Dashboard tiles
A tile is a context with a chart hint. The contract can say how it draws (bar, line, table, number, with its x and y columns), and the dashboard's filter bar binds to the context's parameters. When the ⓘ on a tile is opened, it names the context behind it, so a person reading the dashboard and an agent quoting the same number are pointing at the same definition.
Embedded panels
Applications that already have their own design system do not want an iframe. They take the layout once and then the rows whenever filters change, and draw them with their own components. The rows still come from the same context through the same service.
Home pages
A person's home is a set of contexts evaluated for them: their book, their accounts, their brokers, computed ahead of time and returned in one call. The scope is the person's own, resolved from who they are, not from anything the page sent.
Same rules on every path
The reason five consumers can share one context safely is that none of them holds any of the rules. They hold a key and some parameter values. Everything else happens in one place:
| Rule | Where it comes from | Can a consumer change it? |
|---|---|---|
| Row scope | The caller the product resolved: their book and their organisation | No. It is never read from the request. |
| Masking | The contract's masking rules and the caller's clearance roles | No. Uncleared callers get redacted, hashed, last-four or null values. |
| Allowed roles | The contract | No. A sensitive context names the roles that may call it. |
| Parameters | Declared types, bounds and allowed values | Only within the declaration; anything else is refused. |
| Row cap and timeout | The contract | A caller may ask for fewer rows, never more. |
| Audit | Every call, every path | No. |
Why scope never comes from the request. If the request could name the book it wanted, an agent that was told the wrong thing, or a prompt that was injected, could ask for someone else's rows. Because the scope is resolved from the authenticated caller and wrapped around the template by the service, there is nothing in the request to tamper with.
Totals without a second definition
The commonest reason teams fork a query is totals. The detail query returns one row per policy; the executive tile wants premium by line. Writing a second, aggregated query is exactly the drift a context layer exists to prevent.
A context can declare a rollup instead: group by these columns, sum these, count rows as that, order by this. The important part is when it runs: after the caller's scope is applied. An administrator's premium by line is one row per line for the whole company; an underwriter's is one row per line for their own book. Same context, same definition, different callers, correct totals for each.
Composing answers without a call per row
Consumers also fork queries to join in something extra: a company profile next to each account, a set of insights next to each broker. A context can declare enrich steps that run over its rows after the query, keyed by a column's values. The result arrives with an enriched section keyed the same way, so a page or an agent composes both without calling once per row, and still through one governed path. If a step fails, the rows still come back and the failure is reported beside them.
"enrich": [
{ "name": "public_entity", "column": "public_entity_guid",
"include": ["profile", "insights"] }
]
One ledger for every consumer
Because every path goes through one service, every call lands in one audit: which context, which version, who asked (a person, a key, an agent), the parameter values (hashed), how many rows, how long it took and whether it was refused. Usage per context, including calls, failures, distinct callers and median latency, is shown next to it in the catalog. When an owner wants to change a context, they can see exactly who depends on it, whether those callers are dashboards, applications or agents.
That ledger is also what makes retiring a context safe. A context nobody has called in ninety days can be retired with confidence; one that an agent calls hourly gets a conversation first. More on that in versioning and reviewing context like code.
Designing for many consumers
- Declare the parameters every consumer needs, with defaults that make the no-argument call useful, so nobody needs a variant.
- Label the output columns and give them units. A dashboard formats them, an agent quotes them, an application maps them, all from the same declaration.
- Write example phrasings. They are how an assistant finds the context before writing SQL of its own.
- Prefer a rollup to a second query for totals, and enrich steps to per-row calls.
The Contexts page shows how a context is defined and published, and the Data APIs page covers the REST side in detail.
Where people stay in charge
- The owner defines the answer once. Consumers ask with parameters; they do not redefine premium or retention.
- Identity decides whose rows. Your identity provider and the product's roles, not the agent, decide scope and clearance.
- Curators approve what is published. A new context or a new version reaches consumers only after review.
- The ledger shows who depends on what. Owners see every consumer before they change or retire a context.