tablex

v0.1.11
io.github.tablex-org/tablex-mcp Checked 2 days ago Published 2 days ago

Governed AI agent access to saved database connections: off until enabled, risky changes ask you.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_connections

List the saved connections with their type and the access you have on each. A connection with access `off` is listed by name only and cannot be opened or used until the user enables agent access for it.

open_session

Connect to a saved connection. Other tools need an open session. Needs agent access `schema_only` or more. With `pinned` true it opens a PINNED SESSION instead: a connection of its own (never shared with the connection's other session, the app or another session), returned as `session_id`. Use one when a task needs state to last across calls: `USE database` (MySQL, MariaDB, ClickHouse), `SET search_path` (PostgreSQL), a time zone, a character set, a lock timeout, user variables (`SET @x = 1`). Run the statements with `session_id`; every other call still runs on the shared session, which keeps…

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
pinnedbooleanOpen a pinned session: a connection of its own that keeps `USE` and `SET`s between calls (default false). Needs access `read`.

close_session

Close the session of a connection. Give `connection_id` for the connection's shared session or `session_id` for one pinned session (exactly one of them). Closing a pinned session drops its connection: every `USE` and `SET` it held is gone.

ParameterTypeDescription
connection_idstringConnection id from list_connections.
session_idstringClose this pinned session (from open_session with `pinned` true) and drop its connection, instead of the connection's shared session.

list_namespaces

List databases (no `database` given) or the schemas of a database. Engines without schemas return an empty list for a database.

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
cursorstring`next_cursor` of the previous page.
databasestringList the schemas of this database; omit to list databases.
limitintegerItems per page (default 100, at most 500).

list_tables

List the tables and views of a namespace, sorted by name. `database` may be omitted when the connection has a single database; `schema` is needed for engines with schemas.

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
cursorstring`next_cursor` of the previous page.
databasestringDatabase name.
filterstringCase-insensitive substring of the table name.
limitintegerItems per page (default 100, at most 500).
schemastringSchema name.

describe_table

Describe a table: columns with type, nullability and comment, primary key, unique columns, indexes, foreign keys and (when the database provides it) the DDL. On a MongoDB connection `table` is the collection (with `database`): it returns its indexes (and the createIndex calls that rebuild them in `ddl`); a collection has no columns.

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
table *stringTable or view name.
databasestringDatabase name.
schemastringSchema name.

get_schema_context

A compact digest of every table of a namespace (columns, keys, foreign keys, comments) sized to `budget`. Stable between calls for the same schema. Over budget it drops comments, then non-key columns of the widest tables, then tables, and says what it omitted. `tables` picks the tables to describe and `max_tables` (1 to 20) caps how many. On a MongoDB connection it needs access `read`: a collection has no declared schema, so its fields and types are read from a sample of 20 documents of each (at most 20 collections).

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
budgetintegerSize limit in tokens (estimated; default 4000).
databasestringDatabase name.
max_tablesintegerDescribe at most this many tables, from 1 to 20 (clamped).
schemastringSchema name.
tablesarrayDescribe only these tables or collections, by exact name (at most 50).

execute_query

Run exactly one SQL statement. Needs access `read` or more; a statement that changes data needs `read_write` and may be put to the user for approval when the connection allows it. A refusal or a decline is final for this request: do not retry the statement or reword it to get around it, tell the user instead. Multi-statement scripts are refused. At most 1000 rows (default 200) and a total size limit are returned; check `truncated`. Adding structure (CREATE TABLE, INDEX, VIEW, SEQUENCE, SCHEMA, TYPE; ALTER TABLE ... ADD COLUMN, CONSTRAINT or INDEX; COMMENT ON) is an ordinary change, approved li…

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
statement *stringOne SQL statement, or one MongoDB shell command on a MongoDB connection.
cell_char_limitintegerCharacters of every string cell to return (default 2048 when only the offset is given, at most 4000). Larger or smaller values are clamped.
cell_char_offsetintegerCharacters to skip at the start of every string cell (default 0, at most 1000000): read a long value in pieces, following the `next cell_char_offset` its marker names; narrow the query to the one row…
dangerousbooleanAsk the user to approve a dangerous statement.
databasestringDatabase to run in.
lock_timeout_secsintegerSeconds (1 to 600, and below the connection's statement timeout, 30 by default) to wait for a lock another session holds before the call fails with a lock-timeout error you can retry later. tablex app…
row_limitintegerRows to return (default 200, at most 1000).
session_idstringRun on this pinned session (the `session_id` open_session returned with `pinned` true) instead of the connection's shared session: the `USE` and `SET`s of its earlier calls apply to this one, and noth…
transaction_idstringRun in this open transaction (from begin_transaction) instead of committing by itself; omit `database` then.

execute_batch

Run several SQL statements in order on one connection, in one call. Needs access `read` or more; the script is split into statements and each is judged like execute_query: if one changes data the connection needs `read_write` and the user is asked ONCE to approve all the changes of the script together, before anything runs. A script with a statement that is not allowed (a dangerous one, which a script never runs: DROP, TRUNCATE, ALTER ... DROP, DELETE or UPDATE without WHERE ...; adding structure such as CREATE TABLE or ALTER TABLE ... ADD COLUMN is an ordinary change; a blocked function; BEGI…

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
script *stringThe statements, separated by `;`.
cell_char_limitintegerCharacters of every string cell to return (default 2048 when only the offset is given, at most 4000). Larger or smaller values are clamped.
cell_char_offsetintegerCharacters to skip at the start of every string cell (default 0, at most 1000000): read a long value in pieces, following the `next cell_char_offset` its marker names; narrow the query to the one row…
continue_on_errorbooleanGo on with the next statement after one fails (default: stop at the first failure).
databasestringDatabase to run in.
lock_timeout_secsintegerSeconds (1 to 600, and below the connection's statement timeout, 30 by default) to wait for a lock another session holds before the call fails with a lock-timeout error you can retry later. tablex app…
row_limitintegerRows to return per statement (default 200, at most 1000).
session_idstringRun on this pinned session (the `session_id` open_session returned with `pinned` true) instead of the connection's shared session: the `USE` and `SET`s of its earlier calls apply to this one, and noth…
transaction_idstringRun the script inside this open transaction (from begin_transaction) instead of committing by itself; omit `database` then. Not with `use_transaction` or `continue_on_error`.
use_transactionbooleanRun the whole script in a transaction of its own: committed when every statement succeeds, rolled back when one fails. Not with `continue_on_error` or `transaction_id`.

explain_query

Show the execution plan of one SQL statement (EXPLAIN, never ANALYZE; the statement is not executed). Needs access `read` or more. Pass the statement without EXPLAIN. A call may name a pinned session (`session_id`) to run on a connection of its own, where USE and a few harmless SETs (search_path, time zone, character set, lock timeouts, user variables) persist between calls; see open_session.

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
statement *stringThe statement to explain, without EXPLAIN.
databasestringDatabase to run in.
session_idstringRun on this pinned session (the `session_id` open_session returned with `pinned` true) instead of the connection's shared session: the `USE` and `SET`s of its earlier calls apply to this one, and noth…

execute_redis_command

Run one Redis command line on a Redis connection. Reads need access `read`; a command that changes data needs `read_write` and may be put to the user for approval when the connection allows it. A refusal or a decline is final for this request: do not retry the command or reword it to get around it, tell the user instead. Some commands (KEYS, CONFIG, EVAL, FLUSHALL, ...) are never allowed. FLUSHDB is dangerous: see execute_query. A refusal says what to ask the user to change (a setting in tablex, or a client that supports MCP elicitation): tell the user, and never go around tablex by connecting…

ParameterTypeDescription
command *stringOne command, e.g. `GET user:1`.
connection_id *stringConnection id from list_connections.
dangerousbooleanAsk the user to approve a dangerous command.
databasestringRedis database index, e.g. 0.
row_limitintegerRows to return (default 200, at most 1000).
session_idstringRun on this pinned session (the `session_id` open_session returned with `pinned` true) instead of the connection's shared session: the `USE` and `SET`s of its earlier calls apply to this one, and noth…

mongo_find

Query a collection of a MongoDB connection (find). Read-only: it never changes data. Needs access `read` or more. `database` and `collection` are required (list_namespaces and list_tables name them). `filter`, `projection` and `sort` are JSON documents as in the MongoDB shell; typed values use Extended JSON, e.g. {"_id": {"$oid": "..."}} or {"created": {"$gte": {"$date": "2024-01-31T00:00:00Z"}}}. The key order of `sort` is kept. Documents come back as relaxed Extended JSON. At most 1000 documents (default 200) and a total size limit are returned; check `truncated`, and narrow the filter or th…

ParameterTypeDescription
collection *stringCollection name.
connection_id *stringConnection id from list_connections.
database *stringDatabase name.
filterobjectJSON as MongoDB takes it; typed values use Extended JSON, e.g. {"$oid": "..."}, {"$date": "2024-01-31T00:00:00Z"}, {"$numberLong": "123"}.
limitintegerDocuments to return (at least 1; default 200, at most 1000).
projectionobjectFields to return, e.g. {"name": 1, "_id": 0}.
session_idstringRun on this pinned session (the `session_id` open_session returned with `pinned` true) instead of the connection's shared session: the `USE` and `SET`s of its earlier calls apply to this one, and noth…
skipintegerDocuments to skip (default 0).
sortobjectSort order, e.g. {"created_at": -1}.

mongo_aggregate

Run an aggregation pipeline on a collection of a MongoDB connection. Read-only: a pipeline with a $out or $merge stage is refused, and nothing is ever written. Needs access `read` or more. `pipeline` is the stages in order, as JSON documents (typed values use Extended JSON, as in mongo_find). A final $limit is added, so at most 1000 documents (default 200) and a total size limit are returned; check `truncated`. A call may name a pinned session (`session_id`) to run on a connection of its own, where USE and a few harmless SETs (search_path, time zone, character set, lock timeouts, user variable…

ParameterTypeDescription
collection *stringCollection name.
connection_id *stringConnection id from list_connections.
database *stringDatabase name.
pipeline *arrayThe pipeline stages, in order.
limitintegerDocuments to return (at least 1; default 200, at most 1000).
session_idstringRun on this pinned session (the `session_id` open_session returned with `pinned` true) instead of the connection's shared session: the `USE` and `SET`s of its earlier calls apply to this one, and noth…

mongo_count

Count the documents of a collection of a MongoDB connection that match `filter` (all of them when it is omitted). Read-only. Needs access `read` or more. The filter is a JSON document, as in mongo_find. A call may name a pinned session (`session_id`) to run on a connection of its own, where USE and a few harmless SETs (search_path, time zone, character set, lock timeouts, user variables) persist between calls; see open_session.

ParameterTypeDescription
collection *stringCollection name.
connection_id *stringConnection id from list_connections.
database *stringDatabase name.
filterobjectJSON as MongoDB takes it; typed values use Extended JSON, e.g. {"$oid": "..."}, {"$date": "2024-01-31T00:00:00Z"}, {"$numberLong": "123"}.
session_idstringRun on this pinned session (the `session_id` open_session returned with `pinned` true) instead of the connection's shared session: the `USE` and `SET`s of its earlier calls apply to this one, and noth…

mongo_insert

Insert documents into a collection of a MongoDB connection. Needs access `read_write` and the user's permission to change data through this front end; the user is asked to approve the exact command before anything is sent. A refusal or a decline is final for this request: do not retry it or reword it to get around it, tell the user instead. At least 1 and at most 1000 documents, inserted in order (the first failure stops the rest). `documents` are JSON documents as in mongo_find; typed values use Extended JSON. Not available inside a transaction. The result has the number inserted (`n`) and an…

ParameterTypeDescription
collection *stringCollection name.
connection_id *stringConnection id from list_connections.
database *stringDatabase name.
documents *arrayThe documents to insert (1 to 1000).
session_idstringRun on this pinned session (the `session_id` open_session returned with `pinned` true) instead of the connection's shared session: the `USE` and `SET`s of its earlier calls apply to this one, and noth…

mongo_update

Update documents of a collection of a MongoDB connection. Needs access `read_write` and the user's permission to change data through this front end; the user is asked to approve the exact command before anything is sent. A refusal or a decline is final for this request: do not retry it or reword it to get around it, tell the user instead. `filter` selects the documents (required; one that matches every document or cannot be checked (empty, `_id: {$exists: true}`, `$where`, `$expr`, a complementary `$or`) is refused unless `allow_all` is true, and the MCP server refuses it then on a production…

ParameterTypeDescription
collection *stringCollection name.
connection_id *stringConnection id from list_connections.
database *stringDatabase name.
filter *objectJSON as MongoDB takes it; typed values use Extended JSON, e.g. {"$oid": "..."}, {"$date": "2024-01-31T00:00:00Z"}, {"$numberLong": "123"}.
allow_allbooleanAllow a `filter` that matches every document or cannot be checked (empty, `$where`, `$expr`, `_id: {$exists: true}`, a complementary `$or`).
manybooleanUpdate every matching document, not only the first (default false).
pipelinearrayAn update pipeline, instead of `update`.
session_idstringRun on this pinned session (the `session_id` open_session returned with `pinned` true) instead of the connection's shared session: the `USE` and `SET`s of its earlier calls apply to this one, and noth…
updateobjectUpdate operators, e.g. {"$set": {"status": "paid"}}.
upsertbooleanInsert a document when nothing matches (default false).

mongo_delete

Delete documents from a collection of a MongoDB connection. Needs access `read_write` and the user's permission to change data through this front end; the user is asked to approve the exact command before anything is sent. A refusal or a decline is final for this request: do not retry it or reword it to get around it, tell the user instead. `filter` selects the documents (required; one that matches every document or cannot be checked (empty, `_id: {$exists: true}`, `$where`, `$expr`, a complementary `$or`) is refused unless `allow_all` is true, and the MCP server refuses it then on a productio…

ParameterTypeDescription
collection *stringCollection name.
connection_id *stringConnection id from list_connections.
database *stringDatabase name.
filter *objectJSON as MongoDB takes it; typed values use Extended JSON, e.g. {"$oid": "..."}, {"$date": "2024-01-31T00:00:00Z"}, {"$numberLong": "123"}.
allow_allbooleanAllow a `filter` that matches every document or cannot be checked (empty, `$where`, `$expr`, `_id: {$exists: true}`, a complementary `$or`).
manybooleanDelete every matching document, not only the first (default false).
session_idstringRun on this pinned session (the `session_id` open_session returned with `pinned` true) instead of the connection's shared session: the `USE` and `SET`s of its earlier calls apply to this one, and noth…

list_routines

List the functions, procedures, triggers or events of a namespace, sorted by name. `database` may be omitted when the connection has a single database; `schema` is needed for engines with schemas. Each item has a `ref` to pass to get_routine_source. A database without objects of that kind returns an empty list. SQL databases only.

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
kind *stringWhich objects to list.
cursorstring`next_cursor` of the previous page.
databasestringDatabase name.
filterstringCase-insensitive substring of the name.
limitintegerItems per page (default 100, at most 500).
schemastringSchema name.

get_routine_source

The CREATE statement or source text of one function, procedure, trigger or event. Pass the `ref` from list_routines, or `kind` and `name` (with `database` and `schema` as for list_tables, `arguments` for a PostgreSQL overload, `table` for a trigger). The source is cut to a size limit. SQL databases only.

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
argumentsstringInput argument types of a PostgreSQL overload, e.g. `integer, text`.
databasestringDatabase name.
kindstringKind of object, when no `ref` is given.
namestringObject name, when no `ref` is given.
refobject
schemastringSchema name.
tablestringThe table of a trigger.

begin_transaction

Begin a transaction on a PostgreSQL, MySQL, MariaDB, SQLite or DuckDB connection, on a session of its own. Needs access `read_write` and the user's permission to change data through this front end. Run statements in it with execute_query and `transaction_id`; nothing a write does is committed until commit_transaction, and the user is asked to approve the commit with the list of changes. One open transaction per connection, a few in all. A transaction is rolled back after 5 minutes without a call on it, and when its connection's session is closed. Always end it with commit_transaction or rollba…

ParameterTypeDescription
connection_id *stringConnection id from list_connections.

commit_transaction

Commit an open transaction and close its session. When statements changed data the user is asked to approve the commit with the list of those statements; a decline is final: the transaction stays open, nothing is committed, roll it back. A transaction with no changes is committed without asking. A PostgreSQL transaction that hit an error cannot be committed: roll it back. A refusal says what to ask the user to change (a setting in tablex, or a client that supports MCP elicitation): tell the user, and never go around tablex by connecting to the database yourself.

ParameterTypeDescription
transaction_id *stringFrom begin_transaction.

rollback_transaction

Roll back an open transaction (undoing everything it changed) and close its session. No approval needed. A transaction that is already gone (rolled back after the idle timeout) answers `rolled_back` false.

ParameterTypeDescription
transaction_id *stringFrom begin_transaction.

open_table

Show a table, view or MongoDB collection to the user: tablex reveals it in its sidebar and opens it in a data tab, as a double click does. Nothing is read for you and no data is returned: use it when the user should look at the data. Needs access `schema_only` or more, and tablex has to be running; the connection is opened by tablex if needed. The answer means tablex took the request up, not that the table has loaded.

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
database *stringDatabase name (for MongoDB, the database of the collection).
object *stringTable, view or collection name.
schemastringSchema name; leave out for a database without schemas (MySQL, MariaDB, SQLite, MongoDB).

execute_and_show

Put a query in a new editor tab of tablex, where the user sees it, and run it there so the user sees the result. Needs access `read` or more, and tablex has to be running. A query that is run (`run` true, the default) must be a single read; it runs under tablex's own rules, which may ask the user to confirm first or refuse (production or read-only connections), and the user answers in tablex. A query that changes data, a script with several statements or a MongoDB script is not run from here: call with `run` false to only put it in the editor for the user to run, or use execute_query (a danger…

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
query *stringThe query text for the editor (SQL, a Redis command or a MongoDB script).
databasestringDatabase to open the tab on; leave out for the connection's own database.
runbooleanRun it now (default true); false only puts it in the editor.

add_connection

Add a saved connection to tablex. The user is asked to approve every call and sees the name, kind, address and connection type (never the password); a refusal or a decline is final: do not retry it, tell the user. Give either `uri` or the fields (`host`, `port`, `database`, `user`; SQLite and DuckDB: `path`, an absolute file path). The `uri` must not hold a password and only takes routing and TLS options (e.g. sslmode, authSource); give the password as `password`, which is saved in the credential store (without it the connection has none saved and tablex asks for it when connecting). SSH tunne…

ParameterTypeDescription
kind *stringDatabase engine.
name *stringDisplay name, at most 128 characters, one line; not used by another connection.
connection_typestringId or name of a connection type; default development.
databasestringDatabase name (Redis: the database number).
hoststringHost name or address (not SQLite or DuckDB).
optionsobject
passwordstringPassword to save in the credential store; never shown to the user or logged.
pathstringSQLite or DuckDB: absolute path of the database file.
portintegerPort, 1 to 65535; leave out for the engine's default.
sslbooleanEncrypt the connection with TLS (true: `require`, on MongoDB `verify_full`) or not (false: `disable`); not SQLite or DuckDB. For the finer choice use `options.tls`; the two must agree when both are gi…
uristringConnection URI without a password, instead of the fields (e.g. postgresql://app@db.local:5432/shop).
userstringUser name.

duplicate_connection

Copy a saved connection under a new name. The user is asked to approve every call; a refusal or a decline is final. The copy has the same address, options and type and its saved password (when the original has one); it does not get the original's own access setting, so what you may do on it follows its connection type, and the call is refused when that would be more than you may do on the original. The copy's SSH tunnel secrets are not copied. The name must not be in use (case-insensitive). A refusal says what to ask the user to change (a setting in tablex, or a client that supports MCP elicit…

ParameterTypeDescription
connection_id *stringConnection id from list_connections.
name *stringDisplay name of the copy, at most 128 characters, one line.

remove_connection

Remove a saved connection from tablex, with its saved passwords and pinned objects, and close your session on it. The user is asked to approve every call, and the question says when the connection is a production one; a refusal or a decline is final. It cannot be undone. A refusal says what to ask the user to change (a setting in tablex, or a client that supports MCP elicitation): tell the user, and never go around tablex by connecting to the database yourself.

ParameterTypeDescription
connection_id *stringConnection id from list_connections.