Build Tables with Site Agent
Core Tables ships a skill for Site Agent, so an AI tool connected to your site can build tables for you. It can turn research or a pasted table into a dataset, update rows, import from other plugins and hand back the block markup.
Core Tables sends nothing to an AI service by itself. The AI tool works through Site Agent, as the WordPress user it’s connected as.
Before You Start
- Core Tables 1.0 or newer and Site Agent 0.4 or newer, both active.
- Site Agent’s PHP tool switched on. The skill runs its commands through it.
- A user with the
edit_core_tablescapability. Every command checks it. Administrators and editors have it.
Core Tables registers a skill named core-tables. MCP clients connected to Site Agent can read it with Site Agent’s list-skills and get-skill tools. Once the AI reads the skill, it knows the commands below and when to use them.
How Commands Run
Each command is a call to core_tables_agent( $command, $input ). It returns ['ok' => true, ...] on success or ['ok' => false, 'error' => '...'] with a message the AI can act on.
return core_tables_agent( 'dataset.create', [
'name' => 'Hosting plans',
'rows' => [
[ 'Plan' => 'Starter', 'Price' => '$2.99', 'Sites' => 1 ],
[ 'Plan' => 'Business', 'Price' => '$9.99', 'Sites' => 25 ],
],
] );
Commands run with the connected user’s permissions, the same checks as the admin screens. An editor can only touch their own datasets, and plugin imports need an administrator.
Commands
| Command | Input | What it does |
|---|---|---|
help | none | Lists the commands |
datasets.list | search, status (all, published, draft), page | Datasets you can edit, 50 per page |
dataset.get | id, offset, limit (1 to 500, default 100) | The draft’s columns, rows and version |
dataset.create | rows or format + content, plus name, private_columns, publish | Creates a draft. It publishes only with publish: true. |
dataset.update | id, expected_version, then name, rows, format + content, append_rows, columns, private_columns, public_columns, public_export, publish | Saves a new draft revision |
dataset.publish | id, expected_version | Publishes the current draft |
dataset.embed | id, type (table or chart), label_column, value_column, value_columns, value_axis_label, caption | Returns block markup and a shortcode |
dataset.export | id, format (csv, json, html, markdown), public_only | Returns the file name, type and content |
import.preview | format, content, first_row_header | Shows inferred columns and 5 rows. Saves nothing. |
import.sources | none | Tables in other table plugins. Administrators only. |
import.plugin | source, id, publish | Copies 1 plugin table into a new draft. Administrators only. |
The source for import.plugin is tablepress, ninja-tables, wpdatatables or wp-table-builder.
Giving Data
The AI can send data in 4 shapes:
- Row objects, best for data it put together:
"rows": [ { "Plan": "Starter", "Price": "$2.99" } ]. Keys become column labels. - Labels plus row lists:
"columns": [ "Plan", "Price" ], "rows": [ [ "Starter", "$2.99" ] ]. - Typed columns, to control types or privacy:
{ "label": "Price", "type": "currency", "currency": "USD" }or"public": false. - Pasted content:
"format": "markdown"with the table in"content". CSV, HTML and JSON work too, 1 table per call.
Without typed columns, types are detected from the values, the same way imports do it. A single value that doesn’t fit makes the column text, so units, ranges and footnote marks don’t belong in number columns. Dates go in as YYYY-MM-DD.
Versions Prevent Overwrites
dataset.update and dataset.publish need the expected_version the AI last read. If someone saved the dataset in between, the call fails instead of overwriting their work. The AI then reads the dataset again and retries.
Replacing a dataset’s content keeps its name, its CSV download setting and every column that was private under the same key.
Embedding
dataset.embed needs a published dataset. For a chart, pass a public category column as label_column and up to 6 public number or currency columns as value_columns.
return core_tables_agent( 'dataset.embed', [
'id' => 12,
'type' => 'chart',
'label_column' => 'year',
'value_columns' => [ 'wordpress', 'shopify' ],
'value_axis_label' => 'Share of websites (%)',
] );
The result holds block markup such as <!-- wp:core-tables/table {"datasetId":12} /--> and a matching [coretable] shortcode. The AI can add the markup to a post with Site Agent’s content tools.
Size Limits
Site Agent’s PHP tool takes about 64 KB of code and returns about 64 KB. For a big table, the AI should create it in batches with dataset.update and append_rows, and read it in pages with offset and limit. The dataset limits still apply: 10,000 rows, 30 columns and 2,000 bytes per cell.
Flags and Errors
publish,public_exportand the other flags accepttrue,false,1,0,"true","false","yes"and"no". Anything else fails rather than guessing.- If a create succeeds but publishing fails, the error names the draft: “Draft N was saved at version N, but it was not published: …” Publish that draft instead of creating another.
dataset.exportneeds theexport_core_tablescapability. Passpublic_only: truewhen the file leaves the site.
The same work is available to MCP clients through WordPress abilities, covered in WordPress Abilities and MCP. For a worked example, see How to Let AI Build Your Tables with Site Agent.