A database belongs to a thunk and holds one or more named tables. You define each table's columns, fill it with rows, and the thunk gets tools to query and change those rows while it runs. Databases hold the reference data a workflow looks things up in: rate cards, routing tables, code lists, lists of records already seen, or state that a conversation keeps between turns.
A thunk's databases sit next to its content folders under Content in the thunk's left navigation. They are not the workflow. Adding a row does not start any work, rows have no plan, status, tests or AI cost, and the rows never show up as work items.
A thunk's own database is different from a database in another system. To reach a database your company already runs, such as a customer database, use a Custom Database tool.
When to use a database
You need | Use |
Units of work that move through the Workflow Plan | Work items |
Documents the agent searches by meaning | |
A table of values the workflow looks up or updates exactly | A table in one of the thunk's databases |
Reference data that people keep in a spreadsheet | |
A record that already lives in another system | A connection or a Custom Database tool to that system |
Before writing a lookup table into a custom code tool, or into AI instructions, put it in a table. The values stay editable without changing code, and every step uses the same copy.
Create a database
Databases are on the Databases tab of Content in the thunk's left navigation, which you can open once the thunk has a Workflow Plan. Owners and Admins create databases and tables and change their columns, settings and tools.
Open Content, then the Databases tab, and click Add Database.
Enter a Name and a Description, then click Create. The database opens.
Click Add table, enter the table's name and a description, then click Create.
Open the table. On its Schema tab, add the columns. Every table has a Name column. Add the others and choose each one's type, such as Text, Number, Yes/No, Date Time or Calendar Date.
On the Data tab, click Add and choose Add one item using a form to add a row.
The Databases tab lists every database with its number of tables and rows. A database has two tabs:
Tables: its tables. Open one to work with it.
Settings: Read-only for AI agents for every table in it, and Delete database, which is offered once the database has no tables.
Each table has three tabs:
Data: the rows. Open a row to see or change it. Owners and Admins can click Remove this table to delete the table, its rows and its tools; this cannot be undone.
Schema: the columns, the key and foreign keys, read-only, and the owner filter (see Row owners and the owner filter).
Tools: the tools the table adds, and which ones are turned on.
A table's name must not clash with the workflow, a content folder, a database or another table. Its tools are named after it, so their names must not clash with the thunk's custom tools or content-folder search tools either.
A table made before databases could hold several tables stands on its own. It opens straight to the table, and Add table on it asks for a name for the new database that will hold both tables.
The tools a table adds
Each table adds five tools to the thunk's This Thunk tools. For a table named "Rate Card":
Tool | What it does |
| Returns rows that match a filter, optionally only some columns |
| Adds a row. It does not start a workflow |
| Returns the one row that matches a filter. It fails if more than one row matches |
| Changes columns on every row that matches a filter, and says how many changed |
| Deletes every row that matches a filter, and says how many were deleted |
All five tools take the same filter (see Filters and paging). Because a filter can match many rows, update_ and delete_ refuse an empty filter unless the call also passes all: true. Pass expectedCount to make the call fail, without changing anything, when a different number of rows match.
A read-only table has only the query_ and get_ tools (see Keys and read-only tables).
Tables created before these tools changed also had update_rate_card_row and delete_rate_card_row, which take a row id. Custom code tools and other thunks that call those names keep working. The thunk's own AI agent sees only the five tools above.
The tools are on for every step when the table is created. Turn them off for a step, or make them conditional, in that step's tool settings like any other This Thunk tool. See Conditional tool availability.
A custom code tool calls a table's tools like any other tool:
const input = getTypedInput();
const { data } = await tools.query_rate_card({
filter: {
items: [
{ field: "Role", operator: "equals", value: input.role },
{ field: "Region", operator: "equals", value: input.region },
],
logicOperator: "and",
},
});
const rate = data[0]?.properties["Hourly Rate"];
Filters and paging
A query_ tool takes a filter: a list of items, each with a column name in field, an operator and a value, joined by logicOperator (and or or).
Column type | Operators |
Text |
|
Number |
|
Yes/No |
|
Date Time, Calendar Date |
|
An empty items list returns every row. A query_ tool returns { matchCount, hasMore, nextPageToken, data }, where each row in data is { id, name, properties } and properties is keyed by column name. matchCount is how many rows match in all, across every page. Rows come back oldest first, at most 256 per page. While hasMore is true, call again with nextPageToken as pageToken.
A custom spreadsheet lookup tool and a spreadsheet content folder's lookup tool take the same arguments and return the same result, with each row's number in the sheet.
Keys and read-only tables
A table can have a key: a column whose value every row must have, and no two rows may share. Text keys ignore upper and lower case and spaces at either end, so ACME and ` acme ` are the same key. A key column holds text, a number, a date or yes/no.
add_to_rate_cardrefuses a row with no key value, or with a key another row already has. Passupsert: trueto update the row that has that key instead.update_rate_card_rowsrefuses a change that would give two rows the same key. Change a key one row at a time.A table that already has repeated or empty values in a column cannot use that column as its key until you fix those rows.
With the owner filter on,
upsertnever updates another user's row: the call fails as a duplicate.
A table can also be read-only. The thunk's AI agents can then only read it: it has only the query_ and get_ tools. You can still change its rows on the Data tab and with the Builder MCP.
To make one table read-only, turn on Read-only for AI agents on its Schema tab. To make every table in a database read-only, turn it on on the database's Settings tab. You can also use the Builder MCP. A table's Schema tab also shows the database it belongs to.
To set the key, pick a column under Key on the table's Schema tab, or None to remove it. Foreign keys are set there too: under Add a foreign key, pick a column and the table whose key it must hold, then click Add; click Remove next to a foreign key to remove it. Each change first checks the rows the table already has, and is refused with the reason when a row breaks the rule. You can also set them with the Builder MCP (see With the Builder MCP).
Databases with several tables
A database can hold several related tables, such as products, price tiers and prices. Each table has its own columns, rows and tools, as described above. Tool names come from the table name, so table names must be unique across the thunk. Making the database read-only makes every table in it read-only. Add tables with Add table on the database, or with the Builder MCP.
Foreign keys
A table in a database can have foreign keys: columns whose values must be the key of another table in the same database. For example, Prices can have a sku column that must name a row of Products, whose key is sku.
The referenced table needs a key, and the column has the same type as that key.
Values match keys the way keys match each other: text ignores case and spaces at either end. An empty value is allowed.
add_to_andupdate_refuse a value that matches no key.A row cannot be deleted, or have its key changed, while other rows still refer to it. Change or delete those rows first.
query_andget_takeinclude, a list of foreign-key columns. Each returned row then hasincluded, holding the row each of those columns refers to (ornull).
Converting a spreadsheet content folder
A spreadsheet content folder can become a database: each tab's rows are copied into a table. Owners and Admins can do this from the app or with the Builder MCP.
Open the folder on the Content Folders tab of Content and click Convert to a database, or open the Databases tab, click Import spreadsheet folder and choose the folder.
Check what the conversion will make: each table, how many rows it gets, its columns and their types, and anything that stops it.
Click Convert. The folder becomes the database.
The rows are copied once. The spreadsheets themselves are not changed. Later edits to a spreadsheet do not reach the database, and changes the AI agents make stay in the database. To keep reading a spreadsheet that people go on editing, keep the folder or use a Spreadsheet Lookup tool.
Each tab becomes a table named after its old tools: the tab behind
suppliers_listbecomessuppliers, withquery_suppliersand the other table tools.Column types are guessed from the data. A column of plain numbers becomes Number, a column of yes/no, true/false or 1/0 becomes Yes/No, and anything else stays Text, including dates and numbers written with leading zeros, such as
00123, so no value changes. On a read-only table, a column with a few repeated values becomes a choice of those values. Change any type afterwards on the Schema tab.A tab from an uploaded file becomes a read-only table, because the AI agents could only read it before.
A tab with more than 5000 rows, or one the conversion cannot open, stops the conversion, and nothing changes.
The old tool names keep working for code tools and for other thunks that call them, with the same arguments. Their results now give each value as its column's type, such as a number instead of text.
If a step's directions name an old tool, AI agents keep seeing the old tools until you update the directions. The old lookup tool then takes the same arguments as
query_and returns every match.Tool settings carry over: a tool you turned off for the thunk or for a step stays off under its new name.
When you copy the thunk, the table's rows are copied the way any table's rows are, including the limit on how many (see Copying and publishing). A copy that does not copy rows has empty tables, where the folder would have kept reading the spreadsheet.
Checking a database
The tools refuse duplicate keys and values that match no key, but rows you change on the Data tab are not checked. The Builder MCP's check operation (batch_databases) lists, for each table, repeated key values, rows with no key value, and foreign-key values that match no key.
Row owners and the owner filter
Every row records the user who added it. When a work item was submitted by an end user, including a work item of another thunk that calls this thunk's tools, that end user is the owner. A work item with no end user, such as a scheduled or test work item, records one owner for all such work items, and rows you add on the Data tab belong to you.
By default, anyone who can call a table's tools sees every row. To keep users' rows apart, turn on Filter tool results to the invoking user's rows on the table's Schema tab. The query_ tool then returns only the calling user's rows, and the get_, update_ and delete_ tools report a row that belongs to someone else as not found. The Data tab still shows every row, and with the filter on it also shows who owns each row.
Use the filter for per-user data, such as a form that a user fills in over several conversations.
Turning the filter on also stops any report that runs over the table, until you turn it off again.
Copying and publishing
Copying a thunk always copies its databases, tables and columns. Rows (up to 500 per table) are copied only when the copy also copies work items or content-folder documents.
When you publish a thunk as an MCP server, its table tools are off by default. Turn one on in the export settings only when callers should use the table directly. It is usually better to publish a custom tool that does the job ("look up a rate") and calls the table tools itself. For patterns built this way (a mock of an external system, a store several workflows share, a service that processes and stores records), see Database patterns: mock systems and shared stores.
With the Builder MCP
An AI agent that builds thunks through the Builder MCP manages tables with batch_tables and databases with batch_databases. get_definition lists the thunk's databases in its databases section and their tables in its tables section. One batch_tables call can add, rename and delete tables and columns, and add, change, delete and query rows:
{
"thunkId": "",
"operations": [
{ "op": "add", "name": "Rate Card", "description": "Hourly rates by role and region" },
{ "op": "add_column", "table": "Rate Card", "name": "Role", "type": "TEXT" },
{ "op": "add_column", "table": "Rate Card", "name": "Region", "type": "TEXT" },
{ "op": "add_column", "table": "Rate Card", "name": "Hourly Rate", "type": "NUMBER" },
{ "op": "add_row", "table": "Rate Card", "values": { "Name": "Senior engineer EU", "Role": "Senior engineer", "Region": "EU", "Hourly Rate": 140 } },
{ "op": "query_rows", "table": "Rate Card", "filter": { "items": [{ "field": "Region", "operator": "equals", "value": "EU" }] } }
]
}
Column types are
TEXT,NUMBER,YES_OR_NO,DATE(Date Time) andCALENDAR_DATE.Row
valuesare keyed by column name.update_rowanddelete_rowtake the rowidreturned byadd_roworquery_rows. Use these row operations, notcreate_work_item, which starts a workflow.updaterenames a table or changes its description, andfilterRowsByOwner: trueonaddorupdateturns on the owner filter.deleteremoves the table, its tools and its rows.updatewithkeyColumnsets the key (""removes it), andreadOnly: truemakes the table read-only.add_rowtakesupsert: truelikeadd_to_does.add_row,update_rowanddelete_rowfollow the key and foreign-key rules; read-only does not stop row operations.updatewithforeignKeys, such as[{ "column": "sku", "references": "Products" }], sets a table's foreign keys ([]removes them). It is refused while existing rows hold values that match no key. A table that other tables refer to cannot be deleted or have its key changed until those foreign keys are removed.Renaming a table renames its tools and keeps whether they are on for the thunk. Each step's own settings for those tools, code tools that call the old names, and the thunk's MCP export settings for them are not updated: set or fix those again after a rename.
Operations run in order. A failed operation does not undo or skip the others, so read each result's status and retry only the failed ones.
A batch of only row operations does not repeat every table's columns in its reply. Pass
returnTables: "all"when you want them back.query_rowstakes the same filter as thequery_tools and, like the Data tab, returns every row whatever the owner filter.
batch_databases takes the operations for databases, converting a spreadsheet content folder, and the check. It takes the same thunkId, operations and returnTables, and its reply has the same shape. Sending one tool's operation to the other is refused with the name of the tool to use.
add_databasecreates a database,update_databaserenames it, changes its description or makes it read-only, anddelete_databaseremoves it once it holds no tables. Passdatabaseon a table'saddto put the new table in a database, or onupdateto move one (""takes it out). The reply lists each database indatabases, and each table's database, key and read-only state intables.checkwith a database or tablenamereturns the check described in Checking a database on the result'scheck.convert_spreadsheet_folder(folder, optionaldryRun) converts a spreadsheet content folder (see Converting a spreadsheet content folder) and returns onconversioneach table with its row count, columns and their types, and any problem. PassdryRun: truefirst to see that without changing anything.
