A plugin may tell Futurity what kinds of records its system holds, and how those records refer to each other, so Futurity can draw them on the Atlas map.
- A data set is one kind of record, such as orders or customers, with a title and the fields each record has.
- A link says that a field of one data set holds the id of a record in
another, such as an order's
customer_idpointing at a customer'sid.
This is optional. A plugin that serves no data sets is unchanged.
Data sets are never in the manifest. The manifest is public, and the data sets of a connected system can depend on that organization's own setup. A plugin serves them as an MCP resource on its MCP endpoint:
- URI:
futurity://data-sets(exported asDATA_SETS_URI) - MIME type:
application/json - Contents: one declaration, in the shape below
The resource is read like any other MCP request, so the SDK verifies the
Futurity identity token and delivers the connection's credentials first. A
request without a valid token is refused with 401. Only a connected system can
be read. An app built with futurity: false verifies no caller and serves the
resource to anyone, so use that only in development.
A plugin that serves no data sets does not list futurity://data-sets in
resources/list. A plugin with no resources at all answers resources/list
with "method not found"; a host treats both as "no data sets".
The Futurity platform does not read this resource yet. The plan: Futurity reads it when an organization connects the system, and again when an administrator asks for a re-read. It draws the data sets and links on the Atlas map before it reads any data, and its discovery starts from them.
Use a fixed declaration when your system has the same record types for every
organization. The SDK checks it when app.dataSets() runs, so a broken
declaration fails at startup.
import { mcp } from "@futurity/plugins";
const app = mcp({ manifest, futurity: { issuers } });
app.dataSets({
dataSets: [
{
id: "orders",
title: "Orders",
description: "Sales orders taken at the order desk",
fields: [
{ name: "id", type: "string", description: "Order number" },
{ name: "customer_id", type: "string" },
{ name: "placed_at", type: "datetime" },
{ name: "total", type: "decimal" },
],
},
{
id: "customers",
title: "Customers",
fields: [
{ name: "id", type: "string" },
{ name: "name", type: "string" },
],
},
],
links: [{ from: { dataSet: "orders", field: "customer_id" }, to: { dataSet: "customers", field: "id" } }],
});Use a function when the data sets depend on the connection, such as a database gateway that reads the schema it can see. The function receives the same context as a tool handler: the org, the user, the holder, the credentials and the abort signal. The SDK checks what it returns on every read and answers the read with an MCP error that names each broken rule.
app.dataSets(async ({ credentials, signal }) => {
const tables = await listTables(credentials.connection_string, signal);
return {
dataSets: tables.map((table) => ({
id: `${table.schema}_${table.name}`.replace(/[^A-Za-z0-9_]/g, "_"),
title: `${table.schema}.${table.name}`,
fields: table.columns.map((column) => ({ name: column.name, type: fieldType(column.sqlType) })),
})),
links: tables.flatMap((table) => table.foreignKeys.map((key) => ({
from: { dataSet: `${table.schema}_${table.name}`, field: key.column },
to: { dataSet: `${key.refSchema}_${key.refTable}`, field: key.refColumn },
}))),
};
});Two rules apply to dynamic data sets only:
- Return names and types only. Do not copy a description, comment or label
from the customer's system into
description. People type those as free text, and Futurity shows data sets to everyone in the organization who can see the map. The SDK cannot tell where a string came from, so this is up to you. A description you wrote yourself, such as one for a system table every install has, is fine. - Serve dynamic data sets only where an administrator controls the structure, such as database schemas, ERP metadata, or CRM custom objects. Do not serve them where any user can create tables, such as collaborative bases; those change with every user and are not a map of the system.
An empty dataSets list is valid and means the connection holds none.
type DataDeclaration = {
dataSets: {
id: string; // a letter, then letters, digits or underscores; at most 64; unique ignoring case
title: string;
description?: string;
fields: { name: string; type: FieldType; description?: string }[]; // at least one
}[];
links?: {
from: { dataSet: string; field: string };
to: { dataSet: string; field: string };
description?: string;
}[];
};
type FieldType = "string" | "integer" | "decimal" | "boolean" | "date" | "datetime" | "json";DataDeclarationSchema from @futurity/plugin-manifest checks these. The SDK
applies it to every declaration it serves, and a host applies it to every
declaration it reads.
- A data set id starts with a letter and holds only letters, digits and
underscores, at most 64 characters, so a vendor's own name such as
invoiceInstallmentsorCustomersV3fits. Ids are unique ignoring case. A dynamic source maps a name with dots, spaces or dashes onto an id by replacing each such character with_, and keeps the original name intitle. Field names have no such limit, so keep them as the system names them. - A data set has at least one field, and field names are unique within it.
- A field's type is one of
string,integer,decimal,boolean,date,datetime,json. - Each link joins two different fields, each a declared field of a declared data set, and no link is declared twice.
- The declaration takes no other keys, so a typo inside it fails loudly.
import { DATA_SETS_URI, type DataSetsSource } from "@futurity/plugins";
import { DataDeclarationSchema, type DataDeclaration } from "@futurity/plugin-manifest";