External Tools

The Tier 4 tools run the SchemaSmith Community tools for you: deploy a package, extract a schema or its reference data, or carve a patch. By default a deployment is a dry run; your own settings file can change that.

By the SchemaSmith Team · Last reviewed

Ask Forge external tools

The same tools your CI/CD pipeline runs, triggered from a conversation.

The Deploy Tools

The Deploy tools run SchemaQuench, SchemaTongs, DataTongs and SchemaShears as subprocesses. Each one writes the settings file its tool reads, from your parameters and a stored connection, or hands the tool a settings file of your own. It then runs the tool and returns what the tool reported: whether it succeeded, how long it took, and where its logs are.

The tools themselves ship separately, as the SchemaSmith Community tools, and must be installed before you use these. SchemaSmith Community Tools says where Ask Forge looks for them.

A Deploy tool is confirmed before it runs, and a dry run is no exception. Over MCP, every Deploy tool is in the server's tool list, and each call needs confirm: true. On the CLI, each command asks first unless you pass --yes, at every agent.confirmationLevel except never. In the REPL, the conversational agent needs the operator trust level, and it asks before each run while confirmTier4 is on, as it is by default. Confirmation covers each surface.

On the CLI, each tool is a kebab-case subcommand and each parameter a kebab-case option, so dry_run becomes --dry-run. A true-or-false option given on its own means true, and --dry-run false turns the dry run off. Add --help to any command for its full list of options.

Connections

A Deploy tool reaches the database in one of two ways:

  • A stored connection. Without config_file, the tool builds its settings from the connection stored for the platform: the loaded package's platform, unless you pass platform. Store one with schemasmith_manage_connection, described under Connection Management. MariaDB has its own connection, separate from MySQL's. With no connection stored, the call stops before anything runs and says how to add one.
  • Your own settings file. With config_file, the tool runs an existing settings file, such as a SchemaQuench.settings.json, and the file supplies every setting, its connection included. For SchemaQuench that also means the file decides whether the run is a dry run. Only log_path goes with it, and for SchemaQuench also resume and the switches that say what to run: validate, test_connection, preview_targets, report and what_if_detail. A relative path is found from the working directory schemasmith_navigate_context set, or, when none is set, from the folder Ask Forge started in.

Some runs need no connection at all. SchemaShears works from files, and a SchemaQuench validate run or a SchemaTongs write_schemas_only run reads the package from disk.

Deploying a Package

Bring a target database in line with your package, or check that it can be, without changing anything.

schemasmith_run_schema_quench

Runs SchemaQuench against the target database. The run is a dry run unless you pass dry_run: false. With config_file, the settings file decides. SchemaQuench works out every change and reports it without applying any. The run deploys exactly the templates it names and touches no other. Each pre-flight switch makes the whole run a check that changes no schema: validate lints the package from disk and needs no connection, test_connection checks the connection to every configured server and the product's MinimumVersion floor, and preview_targets reports each template's targets.

ParameterRequiredDescription
dry_runNoPreview the changes without applying them. Defaults to true
templatesNoThe templates to deploy, as one name, a comma-separated list or a JSON array. Defaults to the selected template. A name the product's TemplateOrder does not list stops the run
templateNoAn alias for a single name in templates. Giving both is an error
validateNoLint the package from disk and stop. Needs no connection. Combines with none of the switches that run more
test_connectionNoCheck the connection to every configured server and the MinimumVersion floor, and stop
preview_targetsNoReport each template's deployment targets, with the connection check, and stop
resumeNoContinue from the last checkpoint instead of starting fresh
reportNoThe base path of a machine-readable report, written as <basepath>.json and <basepath>.md
what_if_detailNoconcise, normal (the default) or verbose: how much a dry run prints for each script. Console only
exit_non_zero_on_warningNoExit 1 instead of 0 when the run logged a warning
databasesNoDeploy only to these of the databases the identification scripts discover
schemasNoSchema templates only. Deploy only to these of the discovered schemas
template_targetsNoFor each template named, replace the targets its identification script would discover, for this run only
script_tokensNoToken values that override the package's, as a JSON object
prevent_dropNoRefuse every drop the deployment would make, and report what was held back
unsupported_feature_policyNowarn, the default, deploys an object without a feature the target version lacks and records the downgrade; fail stops the run
online_applyNoOff (the default), Prefer or Require: whether index and column changes on existing tables use the engine's lower-lock form
online_apply_max_durationNoSQL Server 2019 and later. The minutes a new index's online build may run before it pauses as a resumable build
skip_unchanged_objectsNoSkip view, function, procedure and trigger scripts that have not changed. On by default
optionsNoAdvanced settings as a JSON object, such as max_threads, deliver_data and the drop_removed_* flags. The command's help lists every member
log_hygieneNoWhat the logs mask, as a JSON object of ScrubTokens, ScrubPatterns, AllowTokens and LogTokens
platformNoThe platform, when it is not the loaded package's
log_pathNoWhere the logs go. Defaults to the package's Logs folder
config_fileNoRun your own settings file, as described under Connections
ask-forge run-schema-quench --templates Main

Extracting Schema and Data

Bring an existing database's schema, or its reference data, into a package.

schemasmith_run_schema_tongs

Runs SchemaTongs to extract a live database's schema into package JSON and scripts. It is how you bring an existing database into SchemaSmith, or refresh a package after changes made directly in the database. output_path does not have to exist: extracting into a new folder is the normal way to start, and needs product_name as well. A run that leaves an object out of the package, such as a script that failed validation, finishes as incomplete and names each object it left out.

ParameterRequiredDescription
databaseNoThe database to extract. Defaults to the stored connection's
output_pathNoWhere the package is written. Defaults to the loaded package, or else the working directory. Created if it does not exist
product_nameNoThe new product's name. Required when extracting into a new folder
template_nameNoThe new template's name. Defaults to the database name
object_filterNoExtract only these objects, comma-separated
exclude_typesNoSkip these object types, comma-separated
source_schemaNoSQL Server and PostgreSQL. Extract one schema as the body of a schema template
schema_identification_scriptNoSQL Server and PostgreSQL. The discovery query to write into the new Template.json, with source_schema
write_schemas_onlyNoRegenerate the package's .json-schemas validation files and stop. Needs no connection
folder_mappingNoWhere each object type is written, as a JSON object, for a package whose folders were renamed
orphan_handlingNoDetect (the default) logs scripts whose objects no longer exist; DetectWithCleanupScripts also writes DROP scripts into the log folder; DetectDeleteAndCleanup also deletes the orphaned files
validate_scriptsNoTest each extracted script against the source in a rolled-back transaction
save_invalid_scriptsNoKeep a script that failed that test as a .sqlerror file. On by default
check_constraint_styleNoSQL Server and PostgreSQL. ColumnLevel or TableLevel; the setting in Product.json wins
object_orderNoName (the default) or Physical: how a table's column list is ordered when there is no existing order to keep
preserve_existing_orderNoKeep an existing file's member order on re-extraction. On by default
module_syntaxNoSQL Server. CreateOrAlter (the default) or Legacy, for a package that must deploy below SQL Server 2016 SP1
script_dynamic_dependency_removalNoSQL Server. Script the removal of dynamic dependencies before a function is updated
compat_encodingNoauto (the default), legacy or modern. Only for a version-detection problem
exit_non_zero_on_warningNoExit 1 instead of 0 when the run logged a warning
log_hygieneNoWhat the logs mask, as for SchemaQuench
platformNoThe platform, when it is not the loaded package's
log_pathNoWhere the logs go. Defaults to the Logs folder under the output path
config_fileNoRun your own settings file
ask-forge run-schema-tongs --output-path ./Shop --product-name Shop

schemasmith_run_data_tongs

Runs DataTongs to extract table data into content files and MERGE scripts, so the package can deliver that reference data at deployment. With configure_data_delivery, it then sets up data delivery on each table's JSON after the extraction. An option you leave out takes DataTongs' own default, so a run writes .tabledata content files and merge scripts that refer to them by token. A run that skips a table, a column or a script finishes as incomplete and names what it skipped.

ParameterRequiredDescription
tablesNoThe tables to extract, as a JSON array. Each entry needs a name, and can add keyColumns, selectColumns, filter and mergeType. Required unless you use config_file
databaseNoThe database to extract from. Defaults to the stored connection's
script_pathNoWhere the MERGE scripts go. Defaults to the loaded product's folder, or else the working directory; created if missing
content_pathNoWhere the content files go. Defaults to the loaded product's folder, or else the working directory; created if missing
configure_data_deliveryNoSet up data delivery on each table's JSON after the extraction
template_pathNoThe template that setup writes to, when the content lands outside the template
merge_typeNoThe run's default merge type: Insert, Insert/Update or Insert/Update/Delete. A table's own mergeType wins
delivery_encodingNoJson (the default) or Xml. It must match the encoding the table's data delivery declares
source_schemaNoSQL Server and PostgreSQL. Extract from one schema
optionsNoAdvanced settings as a JSON object, such as output_content_files, tokenize_scripts and disable_triggers
compat_encodingNoauto (the default), legacy or modern. Only for a version-detection problem
exit_non_zero_on_warningNoExit 1 instead of 0 when the run logged a warning
log_hygieneNoWhat the logs mask, as for SchemaQuench
platformNoThe platform, when it is not the loaded package's
log_pathNoWhere the logs go. Defaults to the Logs folder under the script path
config_fileNoRun your own settings file
ask-forge run-data-tongs --tables <json> --configure-data-delivery

Building a Patch

Deliver only the objects that changed, rather than the whole product.

schemasmith_run_schema_shears

Runs SchemaShears to carve a patch package out of a full product: only the files a manifest or an always_include file lists, plus the Product.json and Template.json files they need. SchemaShears works from files, so it needs no connection. By default the patch turns off every drop, so nothing missing from the patch is dropped from the target; allow_drops turns chosen categories back on. It writes patch-build-report.txt into the patch, listing every file it included and why. Review the report, preview the patch with a schemasmith_run_schema_quench dry run, and then deploy it: it updates the objects in the patch and leaves every other object in place.

ParameterRequiredDescription
manifestNoA file listing the product-relative paths to include, one per line, such as a list of changed files from source control. Required unless you use config_file
outputNoThe folder the patch is written to. It must be empty or not exist yet. Required unless you use config_file
sourceNoThe product to carve from. Defaults to the loaded product, and must already exist
always_includeNoA file listing paths to include whatever the manifest says
zipNoAlso write the patch as <output>.zip
allow_dropsNoThe drop categories to leave on, comma-separated, such as Columns,Indexes
exit_non_zero_on_warningNoExit 1 instead of 0 when the build logged a warning
log_hygieneNoWhat the logs mask, as for SchemaQuench
log_pathNoWhere the logs go. Defaults to a temporary folder; one you give must not be inside the output folder
config_fileNoRun your own settings file. Only log_path combines with it
ask-forge run-schema-shears --manifest changed.txt --output patch --zip

Exit Codes

The result of each run reports the exit code its tool returned:

Exit code What it means
0 Success.
1 Finished but incomplete, which is neither a success nor a failure. SchemaQuench downgraded a feature the target lacks, SchemaTongs left an object out of the package, or DataTongs skipped a table, a column or a script. With exit_non_zero_on_warning on, any of these tools also returns 1 for a logged warning. The result names each thing left out or downgraded.
2 A failure you can fix: a setting, the package, the target, or a refused step. The tool's output and error log say which.
3 A defect in the tool itself, not something the settings or the package caused. It is worth reporting, with the error log.

The result of a failed run quotes the end of the tool's output and names the full progress log, which schemasmith_view_log can show.

Cancelling a Run

In the MCP server, cancelling a run from your client stops the tool and every process it started. Shutting the server down does the same, and so does your client closing the server's input, after which the server exits. A call that the cancel stopped gets no reply, as the MCP specification asks, and what it would have said goes to the server's log. A call whose tool had already finished when the cancel arrived is answered with its result.

Because closing the server's input is how a client shuts the server down, keep the input open until you have your answers: closing it cancels every call still running.

A Deployment, Step by Step

From an AI assistant over MCP, a deployment follows four steps:

  1. Preview. Ask: "Preview what SchemaQuench would do against my dev database." The AI calls schemasmith_run_schema_quench with confirm: true and leaves dry_run at its default, so SchemaQuench reports every change it would make without making any.
  2. Review. Read the plan. To deploy one tenant of a schema template, the AI can name it in schemas; to replace a template's discovered targets for one run, it can use template_targets.
  3. Apply. Ask it to apply the changes. The AI calls the tool again with dry_run: false and confirm: true.
  4. Check. Read the result. An exit code of 1 means the run finished but is incomplete, and the result names what was left out or downgraded.

From the command line, the same preview and apply, with your package's path:

# Preview: a dry run is the default
ask-forge --product C:\src\my-product run-schema-quench --templates Main

# Apply
ask-forge --product C:\src\my-product run-schema-quench --templates Main `
  --dry-run false
# Preview: a dry run is the default
ask-forge --product /src/my-product run-schema-quench --templates Main

# Apply
ask-forge --product /src/my-product run-schema-quench --templates Main \
  --dry-run false

Each command asks you to confirm before it runs, unless agent.confirmationLevel is never. In a script, where no one is there to answer, --yes answers for you.

Shape. Strengthen. Succeed.

Free schema-as-code for SQL Server, PostgreSQL, MySQL, and MariaDB.

The source is on GitHub for anyone to read.

Get Started on GitHub