12. Additional tools

Every tool of this chapter is documented in detail in the MCP reference (agent tools) and interactive tools.

Besides the core tools of chapter 11, SmartFBX offers two sets of additional tools for AI agents: agent tools, for controlled changes to PSQL code and data, and interactive tools, to drive the SmartFBX interface (portable edition only).

12.1 Agent tools: editing PSQL safely

These tools change procedures, functions and triggers with strict checks, so that an agent cannot overwrite code it has not read or change something else by mistake. connection_name is required and must be a name returned by sfb_db_connections: there is no fallback to the connection selected in the interface.

Tool Arguments Description
sfb_source_search connection_namereq, textreq, object_type, limit (≤200), offset Case-insensitive search in the bodies of standalone procedures, functions and triggers; object, line and text
sfb_source_get connection_namereq, object_namereq, object_type (procedure, function, trigger) Source with numbered lines, signature, ALTER DDL and SHA-256 hash
sfb_source_patch connection_namereq, object_namereq, object_type, expected_hashreq, expected_textreq, replacementreq, start_line, end_line Prepares a change of the body without touching the database. expected_hash must match the current source; expected_text must be unique or match the line range. Signature and SQL SECURITY are kept. Returns change_id, DDL and diff; the plan expires after one hour
sfb_change_validate connection_namereq, change_idreq Checks hash and target, runs the ALTER in a transaction and rolls it back. Returns diff and dependencies, or a structured error with engine code and position
sfb_change_apply connection_namereq, change_idreq Re-checks hash and database, compiles the ALTER, saves the previous definition in the changes folder before the commit, commits. Returns previous/current and the backup file
sfb_change_discard connection_namereq, change_idreq Discards a pending plan

Workflow: sfb_source_search → sfb_source_get → sfb_source_patch → sfb_change_validate → (user approval) → sfb_change_apply.

12.2 Agent tools: data and procedures

Tool Arguments Description
sfb_row_get connection_namereq, table_namereq, keyreq (all and only the PK columns) Reads exactly one row with an opaque hash that includes RDB$RECORD_VERSION (Firebird 3+)
sfb_row_update connection_namereq, table_namereq, keyreq, expected_hashreq, valuesreq, dry_run (default true) Updates one row with lock and hash check; PK and computed columns cannot change; returns previous/current
sfb_row_delete connection_namereq, table_namereq, keyreq, expected_hashreq, dry_run (default true) Deletes one row with lock and hash check; returns the previous row. Triggers and cascades still apply on commit
sfb_procedure_execute connection_namereq, procedure_namereq, params (by name, typed), limit (≤1000), dry_run (default true) Runs a selectable or executable procedure with typed binds. With dry_run = false a truncated result rolls back, to avoid partial commits

Typed values in params and key can be plain JSON values or {"type": "...", "value": ...} with type integer, decimal, boolean, string, date, time, timestamp. Rows with binary BLOBs are excluded from the row tools.

12.3 Interactive tools (MCP Interactive Mode)

Available only in the portable edition. With File > Settings > MCP Interactive Mode turned on (and the MCP server running), an agent can see and drive the SmartFBX window: open menus, fill dialogs, run SQL and take screenshots, for examples, documentation and UX reviews. The window title ends with "- MCP Interactive Mode" while it is active. An optional Interactive token must then be sent by the agent in the X-Interactive-Token header.

The screenshots of this guide were taken with these tools.

Tool Main arguments Description
ui_forms — Open windows with name, caption, active/main flag and size. Start here
ui_controls form, root, depth, visible_only Control tree of a window, contents of the active tab and of scroll boxes included: id (usable as target), class, name, text, position, value, items. Password fields report password: true and never their text
ui_menu action (list, click), path, form Lists or runs menu items, by path (File/Settings) or name (mmFileSettings); popup menus act on the selected tree node
ui_click target or x/y, button, double, use_mouse, force Clicks a control (id, name, Frame.Control or text:Caption) or a point
ui_set targetreq, valuereq, force Sets edits, memos, check boxes, combo and list boxes, tabs, number boxes
ui_key keys (Ctrl+W, F5, Esc), text, target, force Sends keys and characters (not to code editors)
ui_tree action (list, select, expand, collapse, open), path, depth Works on the connection tree with paths like MyDB/Tables/CUSTOMERS; open = double-click; select on a category answers at once with loading: true while the objects are read
ui_editor action (list, get, set, insert, focus), index, text Reads and writes the Monaco code editors
ui_wait condition (control, no_control, enabled, text, form, no_form, tree_item, tree_loaded, editor_ready, sleep), timeout_ms Waits for a condition (tree_loaded: the node at path has its children)
ui_window form, width, height, left, top, state Size and state of a window, for repeatable screenshots
ui_screenshot form, target, padding, highlight, include_frame, mode (window, screen), output_dir, file_name PNG of a window or a control, with optional highlight boxes; saved in the screenshots folder of the data folder or in output_dir. mode=screen (Windows) brings the window to front and extends the image to the open popup menus
ui_native_dialogs action (list, press), hwnd, button Windows message boxes: read text and buttons, press yes, no, ok, cancel...

Every action is queued to the interface thread and waits at most wait_ms: an action that opens a modal window returns completed: false and the agent continues with ui_forms or ui_native_dialogs.

Targets. A component name must match exactly one visible control. The same frame opened in several tabs repeats its names: SmartFBX then answers ambiguous target "btnRun" with the ids of the candidates instead of choosing one. Use an id from ui_controls, or Frame.Control (for example fraSFBXDBCompare.btnRun) to look inside one frame. Controls that are not visible (inactive tabs, hidden windows) are refused unless force: true is passed.