MCP row tools

The arguments of the two MCP tools that read and write the rows of an item's table, their limits, and how an agent reads an answer that didn't fit.

Every MCP endpoint serves marfa_read_rows to a credential that may read a type, and marfa_write_rows to one that may write a type. Each works on one table of one item, named in id and table. A call is the API call it names, so a refusal carries the code the API answers. marfa_get lists an item's tables without their rows. The rules are in the contract's tables chapter.

Read rows

marfa_read_rows answers rows as List table rows does, in the same order, with a next_cursor or null.

ArgumentWhat it does
limitHow many rows at most, from 1 to 1,000. 50 when left out
cursorThe next_cursor of the answer before, for the rows that follow
filterWhich rows, such as values.amount gt 10. A column is values.<column>, and id and updated_at are the row's own
sort, directionid, updated_at or values.<column>, and asc or desc. The table's own order when left out
columnsA list of up to 64 column names. Each row's values and withheld then hold only those. id and updated_at always come back
totalstrue adds row_count and totals, as Get table totals answers them for the filter
group, time_zoneOne or two groupings of by and an optional bucket. Adds row_count, totals and groups, as Get table totals by group answers them
row, column, offsetReads one row's text in one column from offset, in characters

filter and sort may name a column that columns leaves out. Without totals or group, the answer holds no row_count or totals.

A read that doesn't fit

marfa_read_rows keeps every answer within 40,000 characters, whatever limit says, so a page of long rows holds fewer rows than it asked for.

WhenThe answerTo read the rest
The rows don't all fitFewer rows, a next_cursor after the last of them, and a hint that the answer stopped earlySend next_cursor as cursor
The first row doesn't fit aloneThat row alone, its longest text values cut. cut names each by id, column and next_offsetCall with row, column and offset set to next_offset, until next_offset is null
The groups leave no room for a rowThe groups with no rows, the call's own cursor as next_cursor, and a hintRead the rows without group
The groups alone don't fitA tool error. Groups are never cutNarrow the filter, or group by less

Name columns to fit more rows in one answer.

Write rows

marfa_write_rows takes operations, a list of 1 to 200, and applies them in order as Write table rows applies a batch: all of them or none. It answers the batch, last_activity_at and each operation's outcome in results.

OperationWhat it does
{ "op": "put", "id"?, "values" }Creates a row, or replaces the whole row its id names
{ "op": "patch", "id", "values", "expect"? }Sets the columns named and keeps the rest. null clears a column
{ "op": "delete", "id", "expect"? }Removes a row
  • expect holds the values the agent read, keyed by column. If the row holds another value, the batch is refused row_changed and nothing is written. The error's details.row holds the row's values now.
  • A row's values are at most 64 KiB as JSON. The refusal says to keep a long text in a file item and name it in an item column.
  • More than 200 operations is a validation_error naming operations.

Write a table's rows explains each rule.

On this page