Skip to main content
Glama

Merge company

well_merge_company
Destructive

Merge a duplicate company into the company to keep, in the current workspace.

Use this tool when the user says a company is a duplicate of another, or asks to merge, fold or deduplicate two companies — also when they say "delete X, it's a duplicate (of Y)". Never use well_delete_company for a duplicate: a delete keeps the duplicate's invoices and contacts on a removed company, a merge moves them.

REQUIRED: company_id (the duplicate), into_company_id (the company to keep). Find both ids with well_query_records first. When the user names only the duplicate and several companies could be the one to keep, ask which one, once.

Nothing is deleted: the duplicate's invoices, contacts and other links move to the company to keep, and the duplicate stays as a removed record that points to it. Issued invoices stay on the duplicate: an issued document keeps the party it names. Two companies with different legal identifiers (SIREN, VAT) are never merged. When the duplicate is the workspace's own company, the own company is kept and the other one is merged into it: the confirmation and the result name that direction.

Returns { success: true, company_id, name, into_company_id, into_name, moved, locked_rows_kept } on success, where company_id is the company merged away and into_company_id the company kept, or { success: false, error } on failure.

Input Schema

NameRequiredDescriptionDefault
company_idYesUUID of the duplicate company, the one merged away
workspace_idNoTarget workspace. Omit when the token authorizes one workspace. Required when it authorizes several — a write lands in exactly one workspace and this call would not say which.
conversation_idNoThe conversation id returned by the previous Well result, in its meta under well/conversation_id, in its structuredContent, or in its JSON text block. Pass it back on every call in the same conversation, including a call a card makes, so the chosen workspace and the earlier answers still apply. It decides the conversation on its own: nothing the host states about the session replaces it. Omit it only on the first call of a conversation.
idempotency_keyNoOptional client-supplied key. A retried write with the same key returns the original result instead of re-applying the operation.
into_company_idYesUUID of the company to keep
workspace_scopeNoRestrict this call to the family: the token's primary workspace plus the company workspaces under it that you are a member of. Unrelated authorized workspaces drop out of the read; row reads merge across the family, while a per-workspace figure still reports exactly one workspace.

Output Schema

NameRequiredDescriptionDefault
codeNo
nameNo
errorNo
movedNo
successYes
into_nameNo
company_idNo
reply_linesNo
conversation_idNoThe conversation this result belongs to. Pass it back as the conversation_id argument on every later Well call in the same conversation.
into_company_idNo
near_candidatesNo
newly_connectedNoTools that connected to this workspace since the last result and that no session was told about yet, oldest first. Present only when at least one tool is new. The connected-line rule says when to tell an entry; when it does, one line per entry, in the person's language: "<name> is connected.". Never fold several entries into one sentence. Each entry comes back once, on one result only: never repeat its line later.
locked_rows_keptNo
conversation_id_noteNoPresent only when the server opened a fresh lane, stating that no choice recorded earlier was read.
conversation_id_sourceNoWhere the conversation id came from: the host's own request meta, the caller's argument, or a fresh lane the server opened.
near_candidates_truncatedNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • addedOutput schema / properties / code
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / near_candidates
      Added value: +{
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "company_id": {
      +        "type": "string"
      +      },
      +      "name": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "company_id",
      +      "name"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / near_candidates_truncated
      Added value: +{
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / reply_lines
      Added value: +{
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
  2. Added

TDQS

A4.9/5.0
Behavior5/5

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

Annotations declare destructiveHint=true, and the description adds exactly the context that hint cannot carry: what actually moves (invoices, contacts, links), what is retained (the duplicate survives as a removed record pointing at the survivor), and the counterintuitive exception that issued invoices stay on the duplicate. It also discloses the guardrails — never merge across differing SIREN/VAT, and own-company merges invert the direction — which an agent could not infer from the destructive flag alone.

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

Conciseness5/5

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

Front-loaded with the action, then the when/when-not, then required inputs, then consequences, then return shape — each block is short and scannable. The final returns sentence duplicates the output schema, but it is one compact line that reinforces which id means merged-away vs. kept, so it still carries directional value.

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?

For a destructive cross-record mutation this covers decision criteria, both required ids, side effects, data-integrity guards, edge-case direction inversion, and failure shape. With annotations and a full schema already present, no gap remains that would cause a wrong invocation.

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

Parameters4/5

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

Schema coverage is 100% and the two UUID properties are already labelled as duplicate vs. company to keep, so the description largely restates rather than extends. What it does add is operational: how to obtain the ids (well_query_records first) and how to behave when several companies could be the target. The other four parameters (workspace_id, conversation_id, idempotency_key, workspace_scope) are left entirely to their schema text.

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?

States a specific verb and resource with explicit direction semantics: merge a duplicate into the company to keep, in the current workspace. It also distinguishes itself from the nearest lookalike (well_delete_company) so an agent can separate the two without opening either schema.

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

Usage Guidelines5/5

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

Gives explicit triggers ('user says a company is a duplicate', 'merge, fold or deduplicate', including the 'delete X, it's a duplicate' phrasing) and an explicit exclusion with the reason (a delete leaves invoices/contacts on a removed company; a merge moves them). It also prescribes the disambiguation protocol ('ask which one, once') and the prerequisite lookup via well_query_records.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources