---
name: tukiassistant-data-store
description: Read and add rows in a TukiAssistant agent's data tables (data store) through the TukiAssistant MCP server — job postings, candidates, evaluations, leads, tickets or any custom table. Use when the user asks to look up records, find a record id, load or record data (for example a candidate evaluation), or review captured data in TukiAssistant.
---

# TukiAssistant data store over MCP

Each agent can have data tables (its "data store"). Some are filled by the
agent during conversations (**capture** tables, e.g. leads); others are
loaded by the team (e.g. job postings, candidates). Rows often contain
**personal data**: read only what the task needs and never paste full tables
into the chat when a summary answers the question.

Required permissions on the API key: *Read agent data* (`data:read`) to read,
*Add data and shorten retention* (`data:write`) to add rows. Both need an
editor or admin workspace role.

## 1. Discover the schema first

`tukiassistant_list_data_tables` (`agentId`) returns every table with its
columns (`name`, `type`, `required`, `semantic`, `defaultValue`), `rowCount`
and `captureEnabled`. Use the real table and column names from this result;
never guess them.

## 2. Read rows

`tukiassistant_query_data_rows`:

- `tableName`
- `filters` — exact match per column: `{ "email": "ana@example.com" }`,
  `{ "status": "active" }`. Emails captured by agents are stored lowercase.
- `search` — partial text match over text columns.
- `orderBy`, `orderDirection` (`asc` / `desc`), `limit` (max 100, default 20),
  `offset` for the next page. The result is `{ rows, total, limit, offset }`.

Every row has an `id`. **Other tables reference rows by that id**: a
`candidate_id` column holds the `id` of a row in the candidates table.

### Resolving an id (e.g. `candidate_id`)
1. Query the referenced table with an exact filter on a unique field (email,
   phone, national id): `filters: { "email": "ana@example.com" }, limit: 1`.
2. If `total` is 0, try `search` with the name, then ask the user. If it is
   more than 1, show the matches (name + one distinguishing field) and ask
   which one. Never pick one silently.

Capture tables can also be read with `tukiassistant_list_capture_tables` and
`tukiassistant_read_captured_rows` (adds `complete`, `channel`, `uid`).

## 3. Add rows

`tukiassistant_insert_data_rows` (`tableName`, `rows`: 1–50 objects).

- Rows are validated **before** anything is written: unknown columns, missing
  required columns and non-numeric values in number columns reject the whole
  call with a list of problems. Fix them and call again.
- Leave out columns that have a `defaultValue` (e.g. a `review_status` that
  starts as `pending`): the team manages them.
- Inserts are not undoable from MCP. Show the user the rows you are about to
  add and get confirmation, especially for more than one row.
- The result includes `insertedIds`; mention them so the user can find the rows.

## Example: record a candidate evaluation

Tables from the "RRHH - Reclutamiento" template: `candidates`, `job_postings`,
`evaluations` (`candidate_id`, `job_posting_id`, `score`, `classification`,
`rationale`, `criteria_results_json`, `review_status`). A workspace may use
its own candidates table instead of `candidates`; check the schema.

1. `tukiassistant_list_data_tables` → confirm names and required columns
   (`candidate_id`, `classification`).
2. `tukiassistant_query_data_rows` on `job_postings` with
   `filters: { "status": "active" }` → pick the posting; read its
   `required_criteria_json` / `desired_criteria_json` / `scoring_config_json`.
3. Resolve `candidate_id` in the candidates table (section 2).
4. Evaluate against the posting's criteria only. Explain the score in
   `rationale` and per criterion in `criteria_results_json`.
5. After the user confirms, `tukiassistant_insert_data_rows` on `evaluations`:
   `{ "candidate_id": 7, "job_posting_id": 2, "score": 8.5, "classification": "apto", "rationale": "..." }`.

A new evaluation of the same candidate is a new row: the history is kept.

## Errors

| Error | Meaning |
|---|---|
| `Missing required scope: data:write` | The key cannot add rows: edit its permissions in **Organization → API keys** |
| `Invalid rows: ...` | Fix the listed columns and retry |
| `Table not found` | Wrong table name: re-run `tukiassistant_list_data_tables` |
| `Unknown filter column` | Filter on a column that exists in the schema |
| `Agent data store size limit exceeded` | The agent's storage is full; the user must free space or upgrade |
