SmartFBX MCP server — detailed reference

This page documents every tool of the SmartFBX MCP server: arguments with type and default, result, errors and the equivalent REST endpoint. It complements chapters 11 and 12 of the user guide. The REST endpoints are documented in the API reference.

Results shown are illustrative (demo database of the guide); their structure follows the source code.

Protocol

Endpoint

Item Value
URL http://<MCP listen address>:<MCP port>/mcp — default 127.0.0.1, port 8092
Transport JSON-RPC 2.0 over HTTP POST (MCP Streamable HTTP)
Address Set in Settings > MCP listen address: 127.0.0.1 (default) = only programs on this computer; 0.0.0.0 or a network address = AI agents on other computers too, protected by the API access token
Start MCP switch under the tree, or Settings > Run the MCP server with the API. Starting MCP starts the REST API too
Interactive tools Only with MCP Interactive Mode on (portable edition); optional header X-Interactive-Token

Client configuration example:

{ "mcpServers": { "smartfbx": { "type": "http", "url": "http://127.0.0.1:8092/mcp" } } }

Calling a tool

{"jsonrpc":"2.0","id":7,"method":"tools/call",
 "params":{"name":"sfb_meta_tables","arguments":{"connection_name":"prova locale","filter":"ORD"}}}

Arguments

Result

Case Content of the MCP result
Success content[0].text = result as JSON text; structuredContent = the same JSON object (when the result is an object)
Error content[0].text = ERRORE [<tool>]: <message>. Validation and "not found" messages are passed as they are; database and connection errors are reported as connection failed or operation failed: check SmartFB database access (details stay in SmartFBX, credentials are never exposed). Agent tools also put {ok:false, operation, error:{code,message}, diagnostics} in structuredContent

In the current version error results are not flagged with isError: recognise them by the ERRORE [ prefix of the text.

Annotations

Read-only tools are announced with readOnlyHint: true and idempotentHint: true. Write tools have readOnlyHint: false; destructiveHint: true except sfb_source_patch, sfb_change_validate, sfb_change_discard (which never change the database). Clients use these hints to ask for confirmation.

Write tools
sfb_sql_execute, sfb_ddl_execute, sfb_describe, sfb_nq_execute, sfb_nq_register, sfb_nq_update, sfb_script_upload, sfb_script_execute, sfb_script_delete, sfb_source_patch, sfb_change_validate, sfb_change_apply, sfb_change_discard, sfb_procedure_execute, sfb_row_update, sfb_row_delete

Database tools

sfb_db_connections

Names of the configured connections. Call it first.

Arguments: none (connection_name accepted and ignored). Result: array of strings. REST: GET /api/fb/db/connections.

["prova locale","prova locale - copy","prova2","prova3"]

sfb_db_info

Argument Type Default
connection_name string selected

Result: { connected, database, server, driver, fb_version }. REST: GET /api/fb/db/info.

sfb_schema_summary

Overview of the database; call it before analysing a schema.

Argument Type Default
connection_name string selected

Result: { fb_version, database, server, default_charset, page_size, dialect, counts:{tables, views, procedures, functions, triggers, generators, domains, exceptions, fk_total} }. REST: GET /api/fb/meta/schema/summary.

Metadata tools

sfb_meta_tables

Argument Type Default Notes
connection_name string selected
filter string — Substring of the name
system_tables boolean false Include system tables

Result: [{ name, description }]. REST: GET /api/fb/meta/tables.

sfb_meta_table

Argument Type Default
connection_name string selected
table_name string required
with_fields boolean true
with_indexes boolean true
with_fk boolean true
with_triggers boolean true

Result: { table, description, fields, indexes, fk, triggers } (see REST). The table name is checked against the table list first.

sfb_meta_views

Argument Type Default
connection_name string selected

Result: rows from the catalog. REST: GET /api/fb/meta/views.

sfb_meta_procedures

Argument Type Default
connection_name string selected
filter string —
with_params boolean false

Result: [{ name, params? }]. REST: GET /api/fb/meta/procedures.

sfb_meta_functions

Argument Type Default Notes
connection_name string selected
filter string —
exclude_udf boolean false Excludes legacy UDFs

Result: [{ name }]. REST: GET /api/fb/meta/functions.

sfb_meta_generators

Argument Type Default
connection_name string selected
filter string —
with_value boolean false

Result: [{ name, current_value? }]. REST: GET /api/fb/meta/generators.

sfb_meta_domains

Use before proposing DDL, to reuse the existing domains.

Argument Type Default Notes
connection_name string selected
filter string —
user_defined_only boolean true Excludes RDB$, MON$, SEC$ names

Result: [{ name, type, size, precision, scale, not_null, default_value, check_expr, charset }]. REST: GET /api/fb/meta/domains.

sfb_meta_check_constraints

CHECK constraints: business rules encoded in the database. MCP only.

Argument Type Default
connection_name string selected
table_name string — (all tables)

Result: [{ table, constraint_name, check_source }].

[{"table":"ORDERS","constraint_name":"INTEG_13","check_source":"CHECK (STATUS IN ('NEW','PAID','SHIPPED','CANCELLED'))"}]

sfb_meta_fk_graph

Argument Type Default Values
connection_name string selected
table_name string — Pivot table
direction string "" from, to, ""

Result: { nodes:[{name, description}], edges:[{from_table, to_table, constraint, update_rule, delete_rule, from_fields, to_fields}] }. REST: GET /api/fb/meta/fk-graph.

sfb_meta_dependencies

Argument Type Default Values
connection_name string selected
object_name string required
direction string both uses, used_by, both

Result: rows { OBJECT_NAME, DEPENDS_ON, RDB$DEPENDENT_TYPE, RDB$DEPENDED_ON_TYPE }. REST: GET /api/fb/meta/dependencies (type codes there).

sfb_meta_ddl

Argument Type Default Values
connection_name string selected
object_name string required
object_type string table table, procedure, function, view, trigger

Result: DDL as a JSON string. REST: GET /api/fb/meta/ddl.

sfb_describe

Writes the description (RDB$DESCRIPTION) of a table or field, to annotate the database with what has been understood. MCP only. Writes to the database.

Argument Type Default Notes
connection_name string selected
table_name string required
description string required Text to write
object_type string table table or field
field_name string — Required with object_type = field

Result: { updated: true, object_type, table_name, field_name, description }. Errors: TableName required, FieldName required when ObjectType=field.

SQL and DDL tools

sfb_sql_execute

Argument Type Default Notes
connection_name string selected
sql string required
max_rows integer 200
read_only boolean true false allows DML (committed)

Result: rows for a SELECT; { rows_affected } for DML. Errors: ReadOnly: only SELECT allowed. REST: POST /api/fb/sql/execute. For parameterised, paged, read-only queries prefer sfb_sql_query.

sfb_sql_explain

Argument Type Default
connection_name string selected
sql string required

Result: { plan }. REST: POST /api/fb/sql/explain.

sfb_ddl_diff

Compares the current structure of a table with a proposed CREATE TABLE and returns the ALTER TABLE statements needed. Use it before sfb_ddl_execute. MCP only. Reads only.

Argument Type Default
connection_name string selected
table_name string required
proposed_ddl string required — CREATE TABLE ... (field type, ...)

Result:

Field Content
table Table name
alters [{ action: "ADD" / "MODIFY" / "DROP", field, type, sql, warning? }] — warning on operations that lose data
unchanged Fields already as proposed
summary { add, modify, drop, unchanged }
{"table":"CUSTOMERS","alters":[{"action":"ADD","field":"PHONE","type":"VARCHAR(30)","sql":"ALTER TABLE CUSTOMERS ADD PHONE VARCHAR(30)"}],
 "unchanged":["CUSTOMER_ID","COMPANY_NAME","CONTACT_NAME","EMAIL","CITY","COUNTRY","CREATED_AT"],"summary":{"add":1,"modify":0,"drop":0,"unchanged":7}}

Errors: TableName required, ProposedDDL required, proposed DDL without fields.

sfb_ddl_execute

Argument Type Default Notes
connection_name string selected
sql string required One DDL statement
dry_run boolean true false applies it

Result: { executed, dry_run, ddl_type, statement, rows_affected, message }. REST: POST /api/fb/ddl/execute.

Script tools

Workflow: sfb_script_upload → the user reviews the script (in SmartFBX or the /scripts page) → sfb_script_execute only after explicit approval.

sfb_script_upload

Argument Type Default
sql string required
title string required
connection_name string selected (stored as target)
author string ClaudeCode

Result: { script_id, title, author, created_at, status: "pending", size_bytes }.

sfb_script_list

Argument Type Default Values
status string "" "", pending, executed, failed

Result: array of metadata { script_id, title, author, connection_name, created_at, status, executed_at, error, size_bytes }.

sfb_script_get

Argument Type
script_id string, required

Result: metadata + sql. Errors: Script not found.

sfb_script_execute

Argument Type Default
script_id string required
connection_name string selected

Result: { script_id, status, statements:[{index, sql, ok, error}], executed_count, failed_count }.

sfb_script_delete

Argument Type
script_id string, required

Result: { deleted: true, script_id }.

Xtumble named query tools

For databases with the Xtumble schema only. entity_groups must be a list of integers separated by commas (1,2,5), otherwise invalid parameter: entity_groups must contain comma-separated integer IDs.

sfb_nq_groups

Arguments: connection_name. Result: [{ id, name, nq_count }].

sfb_nq_list

Argument Type Default
connection_name string selected
entity_groups string "" (global only)
filter string —
with_sql boolean false

Result: [{ name, description, group_id, read_only, generator, has_count_query, sql? }].

sfb_nq_detail

Argument Type Default
connection_name string selected
name string required
entity_groups string ""

Result: { name, description, read_only, generator, sql, sql_count, fields:[{name,type,size}], params:[{name,type}] }.

sfb_nq_execute

Argument Type Default
connection_name string selected
name string required
entity_groups string ""
params string (JSON) {} — e.g. {"ID_CLIENTE":"42"}
max_rows integer 200

Result: { rows, count }.

sfb_nq_validate

Dry run; writes nothing. Checks name, lengths, the :NAME parameters against params (system XTTB_* parameters are tolerated), whether the name exists, and asks Firebird to prepare SELECT FIRST 0 * FROM (sql) in a read-only transaction.

Argument Type Default
connection_name string selected
sql_text string required
name string —
params array / string / null — (names or {name,type,required,default,description})
query_count string —
group integer —

Result: { valid, name, kind, fields, params, exists, existing, errors:[{code,message}], warnings:[{code,message}] }.

sfb_nq_register

Inserts one row in CUSTOM_FR_DYN_DATASET after all the checks of sfb_nq_validate plus "name not existing". Writes nothing if a check fails.

Argument Type Default Notes
connection_name string selected
name string required Letters, digits, _, max 50
sql_text string required Saved as written
description string — Max 255
params array / string / null — Must match the :NAME in the SQL
query_count string —
group integer 500000000 Global
read_only boolean true
generator_name string — Writable queries only

Result: { registered, group_id, pk_id, read_only, validation } or { registered: false, name, validation }.

sfb_nq_update

Updates an existing named query (only the fields passed). If the name exists in several groups, group is required.

Argument Type Notes
connection_name string
name string required
sql_text string New SQL
description string
query_count string "" clears it
params array / string / null
group integer To disambiguate

Result: { updated, group_id, pk_id, changed, previous:{sql, sql_count, description, read_only, generator}, validation }.

Agent tools

Controlled changes to PSQL code and data. Common rules:

Error code HTTP (REST) Meaning
source_conflict 409 The object changed: read it again
patch_conflict 409 expected_text not found or different at the given lines
ambiguous_patch 409 expected_text occurs more than once: give start_line/end_line
change_not_found 404 Plan unknown, discarded, applied or expired
change_expired 409 Plan older than one hour
target_conflict 409 Plan prepared on another database or connection
plan_limit 429 Too many pending plans
read_only_query 400 sfb_sql_query accepts only SELECT/WITH
procedure_not_found 404
procedure_truncated 409 Output over limit with dry_run = false: rolled back
row_not_found 404
row_conflict 409 Row changed or deleted after sfb_row_get, or invalid hash
row_count 409 The operation would affect more or less than one row
database_error 422 Engine error (message, engine_code, line and column when available)
operation_failed 500 Unexpected failure (no details)

Typed values (params of sfb_sql_query / sfb_procedure_execute, key and values of the row tools): plain JSON scalar or null, or { "type": "...", "value": ... } with type = integer, decimal, boolean, string, date, time, timestamp.

Argument Type Default Notes
connection_name string required
text string required Case-insensitive
object_type string "" procedure, function, trigger, "" = all
limit integer 50 1–200
offset integer 0

Result: { matches:[{object_type, object_name, line, text}], total, offset, has_more }.

sfb_source_get

Argument Type Default
connection_name string required
object_name string required
object_type string procedure (procedure, function, trigger)

Standalone objects only (no package members, no external routines).

Result:

Field Content
object_type, object_name
header Signature (CREATE OR ALTER ... AS)
source Body
ddl header + source
parameters [{ name, definition, output }]
trigger_relation, trigger_type, trigger_sequence, trigger_inactive Triggers only
hash SHA-256 of the definition: pass it as expected_hash to sfb_source_patch
lines [{ line, text }], numbered from 1

sfb_source_patch

Prepares a change of the body; the database is not touched.

Argument Type Notes
connection_name string required
object_name string required
object_type string default procedure
expected_hash string required — hash from sfb_source_get
expected_text string required — text to replace; must be unique, or match the line range
replacement string required
start_line, end_line integer ≥ 1 Optional range (1-based)

Signature and SQL SECURITY are kept. Result: { change_id, applied: false, expires_in_seconds: 3600, expected_hash, ddl, diff }.

{"change_id":"c-4b1e...","applied":false,"expires_in_seconds":3600,"expected_hash":"9f2c...","ddl":"create or alter procedure ...",
 "diff":"-  IF (V_STOCK < A_QTY) THEN EXCEPTION EX_OUT_OF_STOCK;\n+  IF (COALESCE(V_STOCK, 0) < A_QTY) THEN EXCEPTION EX_OUT_OF_STOCK;"}

sfb_change_validate

Argument Type
connection_name string, required
change_id string, required

Re-checks hash and target, runs the ALTER in a transaction and rolls it back. Result: { change_id, valid: true, applied: false, dependencies:[{name, type}], diff, diagnostics: [] }; compilation errors come back as database_error with line and column.

sfb_change_apply

Argument Type
connection_name string, required
change_id string, required

Re-checks, compiles the ALTER, saves the previous definition in the changes folder of the data folder before the commit, commits. The plan is consumed only after the commit. Result: { change_id, applied: true, previous, current, backup_file }.

sfb_change_discard

Argument Type
connection_name string, required
change_id string, required

Result: { discarded: true }.

sfb_sql_query

Parameterised read-only query with paging.

Argument Type Default Notes
connection_name string required
sql string required Must start with SELECT or WITH
params object — By exact parameter name (:NAME in the SQL), typed values
limit integer 200 1–1000
offset integer 0 Use a stable ORDER BY; each page is a new read

Result: { rows, columns:[{name, type, size}], count, offset, has_more, next_offset }. Binary BLOBs are returned as { "encoding": "omitted", "reason": "binary value" }.

{"connection_name":"prova locale","sql":"select ORDER_ID, TOTAL from ORDERS where STATUS = :S order by ORDER_ID","params":{"S":"PAID"},"limit":10}
{"rows":[{"ORDER_ID":2,"TOTAL":749.6},{"ORDER_ID":5,"TOTAL":528.8}],"columns":[{"name":"ORDER_ID","type":"ftLargeint","size":0},{"name":"TOTAL","type":"ftFMTBcd","size":2}],
 "count":2,"offset":0,"has_more":false,"next_offset":null}

sfb_procedure_execute

Argument Type Default Notes
connection_name string required
procedure_name string required Standalone procedure (no packages)
params object — By name; only trailing parameters with a default may be omitted
limit integer 200 1–1000
dry_run boolean true true = executes and rolls back; false = commits

Selectable and executable procedures are both supported. Result: { rows, dry_run, committed }. With dry_run = false, an output longer than limit rolls back with procedure_truncated.

sfb_row_get

Argument Type Notes
connection_name string required
table_name string required, exact name; system tables excluded
key object required — all and only the primary-key columns, not null

Firebird 3 or later. Result: { row, hash }; hash (v1:<record version>:<digest>) is the token for update and delete.

sfb_row_update

Argument Type Default Notes
connection_name string required
table_name string required
key object required
expected_hash string required From sfb_row_get
values object required Columns to change (not PK, not computed)
dry_run boolean true

Locks the row, compares the hash, checks that exactly one row changes. Rows with binary BLOBs are excluded. Result: { rows_affected: 1, dry_run, committed, previous, current, hash }.

sfb_row_delete

Argument Type Default
connection_name string required
table_name string required
key object required
expected_hash string required
dry_run boolean true

Result: { rows_affected: 1, dry_run, committed, previous, hash }. Triggers and cascades still apply on commit.

Interactive tools

Available only in the portable edition with MCP Interactive Mode on.

Targets (target): a control id from ui_controls (#0/3/1), a component name, Frame.Control (e.g. fraSFBXDBCompare.btnRun, to look inside one frame) or text:Caption. A name must match exactly one visible control: frames opened in several tabs repeat their names, and SmartFBX answers ambiguous target "btnRun" with the ids of the candidates instead of choosing one. Controls that are not visible (inactive tabs, hidden windows) are refused unless force: true is passed (ui_click, ui_set, ui_key). Password fields are never read: they report password: true. Every action runs on the interface thread and waits at most wait_ms (default 3000): an action that opens a modal window returns { "completed": false, "note": ... } and the agent continues with ui_forms / ui_native_dialogs. settle_ms (default 300) is the pause after the action.

ui_forms

Arguments: none. Result: { forms:[{ name, class, caption, visible, active, main, left, top, client_width, client_height }] }.

ui_controls

Argument Type Default
form string active form (modal dialog if open), else main
root string whole form
depth integer 8
visible_only boolean true

Result: { form, client_width, client_height, controls:[{ id, cls, name, text, password, x, y, w, h, checked, value, items, item_index, active_tab, children, more }] }. The content of the active tab and of scroll boxes is included; lists, trees and inactive tabs are not expanded.

ui_menu

Argument Type Notes
action string list (default), click
path string File/Settings, popTable/Browse data, or item name mmFileSettings
form, wait_ms, settle_ms

Popup items act on the node selected in the tree. Result: list → { menus:[{ name, kind, items }] }; click → { completed }.

ui_click

Argument Type Notes
target string Control; without x/y its Click is called directly
x, y integer Form coordinates (relative to target if given)
button string left (default), right
double boolean Double click
use_mouse boolean Simulate mouse down/up
force boolean Allow a control that is not visible
form, wait_ms, settle_ms

Result: { completed }. Errors: control disabled: <name>, ambiguous target, control not found.

ui_set

Argument Type Notes
target string required
value string required — text, true/false, item text or index, tab text or index, number
force boolean Allow a control that is not visible
form, wait_ms, settle_ms

Result: { completed }.

ui_key

Argument Type Notes
keys string Ctrl+W, F5, Esc, Ctrl+Shift+F (modifiers Ctrl, Shift, Alt, Cmd)
text string Characters typed before keys
target string Control to focus first
force boolean Allow a target that is not visible
form, wait_ms, settle_ms

With Ctrl/Alt/Cmd no character is sent, and the key-up is not sent when the key-down was handled (a shortcut runs once). Keys do not reach the code editors: use ui_editor and the SQL menu.

ui_tree

Argument Type Notes
action string list (default), select, expand, collapse, open (= double click)
path string Group/Connection/Tables/CUSTOMERS; Tables also matches Tables (34)
depth integer For list, default 1
wait_ms, settle_ms

Result: list → { path, selected, items:[{ text, count, expanded, selected, items }] }; other actions → { completed }. select on a category answers at once with loading: true while the objects are read; wait with ui_wait condition=tree_loaded.

ui_editor

Argument Type Notes
action string list, get, set, insert, focus
index integer From list; default the first visible editor
text string For set / insert

Result: list → { editors:[{ index, ready, visible, location, id, text_length }] }; get → text.

ui_wait

Argument Type Notes
condition string required — control, no_control, enabled, text, form, no_form, tree_item, tree_loaded (node at path has its children), editor_ready, sleep
target, text, form, path string Depending on the condition
timeout_ms integer Default 10000, max 120000

Result: { condition, met, elapsed_ms }.

ui_window

Argument Type Notes
form string Default main
width, height integer Client size in logical pixels
left, top integer
state string normal, maximized, minimized
activate boolean Default true

ui_screenshot

Argument Type Notes
form string Default active form
target string Crop to a control
padding integer Pixels around target
highlight array of strings Controls to outline
include_frame boolean Title bar and borders
mode string window (default, captures even when covered, code editors included) or screen (Windows: brings the window to front and copies the screen, extended to the open popup menus)
output_dir, file_name string Default: screenshots folder of the data folder, shot_<timestamp>.png
return_base64 boolean Also return the PNG
hwnd integer Windows: capture a native dialog

Result: { file, width, height, scale, method, form }.

ui_native_dialogs

Argument Type Notes
action string list (default), press
hwnd integer Dialog (default the first)
button string ok, cancel, yes, no, retry, abort, ignore, close or an id

Result: list → { dialogs:[{ hwnd, caption, task_dialog, texts, buttons }] }; press → { pressed, hwnd }.