Skip to main content
Glama
Coalesce-Software-Inc

coalesce-transform-mcp

Official

Apply SQL Edits to Workspace Node

apply_sql_to_workspace_node

Applies user edits from rendered DDL/DML SQL back to the corresponding cloud workspace node, parsing columns and updating metadata via diff.

Instructions

Round-trip a user's edits on a rendered DDL/DML SQL document back to the cloud workspace node it came from. Parses the SQL's column list, diffs it against the node's current metadata.columns[], and updates the node via set_workspace_node (unless dryRun: true). Both DDL and DML inputs feed the same node metadata — a DDL edit and a DML edit on the same node update the same metadata.columns[].

Column-level diff (structural changes — joins, CTEs, WHERE/GROUP BY, custom expressions on the join itself — are NOT reverse-engineered; those live in the node YAML):

  • Removed columns (in YAML, missing in SQL) → dropped

  • Type changes (matching name, different dataType) → updated in place; existing sources / columnReferences / lineage metadata is preserved

  • Renamed columns (DML only — same transform, new AS alias) → renamed in place, lineage preserved (column id stays stable so downstream refs keep working). Detection requires unambiguous transform pairing; ambiguous cases fall back to drop+add.

  • Expression-changed columns (DML only — same name, edited transform) → sources[].transform is updated and source-mapping inference is re-run to refresh columnReferences if the new transform references different upstream columns.

  • New columns → for DML inputs, source-mapping inference resolves the column's transform against upstream predecessors (alias-prefix match, all-pred name fallback, multi-source COALESCE/GREATEST). For DDL inputs, new columns are added with empty columnReferences[] (DDL doesn't carry transforms); fill them in via the cloud UI.

Block-level diff (DML only — single-sourceMapping nodes):

  • WHERE / ON-condition edits → written to sourceMapping[0].join.joinCondition with table refs rewritten to {{ ref('LOC', 'NAME') }} form.

  • Adding or removing a predecessor source via SQL is REJECTED — add/remove the predecessor in the cloud UI first, then re-render.

Tail-clause diff (DML only):

  • GROUP BY presence toggle → flips config.groupByAll. Coalesce derives the actual GROUP BY column list from non-aggregate columns at render time.

  • ORDER BY adds / changes / removes → config.orderby flag and config.orderbycolumn.items[] array of {sortColName, sortOrder}.

  • LIMIT adds / changes / removes → appended to / stripped from the trailing position of sourceMapping[0].join.joinCondition. Coalesce has no native limit config field for typical SQL nodes; the apply path warns when groupByAll/orderby is set (the auto-rendered tail clauses would land AFTER LIMIT, producing invalid SQL).

INSERT header diff (DML only — INSERT-shaped inputs):

  • Target identifier change (INSERT INTO "DB"."LOC"."NAME") → updates the cloud node's top-level database / locationName / name fields. Renames/relocates the node; downstream references are unaffected (they use the node id, not the name).

  • INSERT column list out-of-sync with the SELECT projection → REJECTED. Coalesce auto-generates the INSERT list from metadata.columns[]; edit the SELECT (using AS aliases) to add/rename/reorder columns.

Args:

  • workspaceID (string, required)

  • nodeID (string, required)

  • sql (string, required): Either a CREATE [OR REPLACE] TABLE statement (DDL, from coa_dry_run_create) OR a SELECT/INSERT statement (DML, from coa_dry_run_run). The shape is auto-detected.

  • dryRun (boolean, optional): If true, return the diff without writing.

Returns: { applied, dryRun, inputKind, diff: { unchanged, typeChanged, renamed, expressionChanged, removed, added }, joinDiff: { kind: 'identical' | 'whereOrJoinEdit' | 'newSource' | 'removedSource' | 'unsupported', ... }, tailDiff: { groupBy: { kind: 'identical' | 'added' | 'removed', ... }, orderBy: { kind: 'identical' | 'added' | 'changed' | 'removed', ... } }, limitDiff: { kind: 'identical' | 'added' | 'changed' | 'removed' | 'unsupported', ... }, insertHeaderDiff: { kind: 'identical' | 'targetChanged' | 'columnListMismatch' | 'notApplicable', ... }, body?, warnings?, error? }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesThe edited SQL to apply. Accepts either: (a) a CREATE [OR REPLACE] TABLE statement (`coa_dry_run_create` output) — name + dataType per column, no transforms; or (b) a SELECT/INSERT/MERGE statement (`coa_dry_run_run` output) — name + expression per column, dataType inferred from the expression. For MERGE shapes (Coalesce dim / Type-2 SCD nodes) only the inner SELECT inside USING (...) is editable; the MERGE envelope (target, ON, WHEN MATCHED / WHEN NOT MATCHED) is Coalesce-managed and ignored by the apply path. The tool extracts the column list and diffs it against the node's current metadata.columns[].
dryRunNoWhen true, returns the diff and updated metadata.columns[] without writing to the workspace. Useful for previewing what would change before pushing.
nodeIDYesThe node ID to update.
workspaceIDYesThe workspace ID containing the node.
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description provides extensive behavioral details beyond annotations: diff logic, what is not reverse-engineered, block-level diff, tail-clause diff, INSERT header diff, and specific rejection cases. This far exceeds the readOnlyHint and destructiveHint provided.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is quite long but well-structured with sections and bullet points. The core purpose is front-loaded. While every sentence contributes value, the verbosity could be streamlined for quicker parsing.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 parameters, no output schema), the description is exceptionally complete. It covers edge cases, detailed return structure, and diffing logic comprehensively, making it sufficient for an agent to invoke correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning to each parameter beyond the input schema. For 'sql', it explains accepted forms, auto-detection, and limitations. For 'dryRun', it clarifies preview behavior. The schema coverage is 100%, yet the description still enriches understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Round-trip a user's edits on a rendered DDL/DML SQL document back to the cloud workspace node it came from.' It distinguishes itself from sibling tools by focusing on applying SQL edits diffs, not generic node updates.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implicitly guides usage by detailing the inputs from coa_dry_run_create and coa_dry_run_run. However, it lacks explicit alternatives or when-not-to-use guidance. It is clear but not perfectly explicit about when to choose this over other tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Coalesce-Software-Inc/coalesce-transform-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server