Skip to main content
Glama

upsert_relationship

Create or update ERD relationships between entities, specifying cardinality, foreign key referential actions, and constraint names.

Instructions

Creates a relationship (no relationshipId, source/targetEntityId required — FKs derived automatically) or updates one (relationshipId given). On update, sourceEnd/targetEnd take precedence; otherwise ends are re-derived from cardinality. onDelete/onUpdate set the FK referential actions ('noAction' reverts to the DB default); constraintName sets the FK constraint name (empty string reverts to auto-generation).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesTarget ERD — exactly one of a local file ({file}) or a server ERD ({erdId})
onDeleteNo
onUpdateNo
sourceEndNo
targetEndNo
cardinalityNo
constraintNameNo
relationshipIdNo
sourceEntityIdNo
targetEntityIdNo
relationshipTypeNo
Behavior4/5

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

With no annotations provided, the description carries the full burden and discloses key behaviors: automatic FK derivation, precedence of sourceEnd/targetEnd over cardinality, referential action semantics including the 'noAction' revert, and constraintName auto-generation on empty string. It does not mention failure scenarios but covers the main side effects.

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?

The description is three sentences long, front-loaded with the primary purpose, and every clause adds essential detail about precedence and parameter behavior. There is no fluff or repetition of schema information, making it efficient and well-structured.

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

Completeness3/5

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

Given 11 parameters, no annotations, and no output schema, the description covers the main operational flows but misses important context such as what sourceEntityId/targetEntityId expect (names or IDs), the meaning of cardinality values, and what happens on invalid input. It is adequate for basic selection but leaves significant gaps for a complex tool.

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 description coverage is only 9%, so the description must compensate. It adds meaning to relationshipId (create vs update), sourceEnd/targetEnd precedence, onDelete/onUpdate referential actions, and constraintName behavior. However, it leaves sourceEntityId, targetEntityId, cardinality values, and relationshipType unexplained, which is a minor gap.

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 creates a relationship when no relationshipId is provided and updates one when relationshipId is given. This specific verb+resource view distinguishes it from sibling tools like list_relationships and delete_relationship, and also outlines the two distinct modes.

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?

It provides clear context for when to use create vs update by explicitly tying the presence of relationshipId to the operation. While it doesn't explicitly name alternative tools, the conditions for using this tool versus creating/updating entities or deleting relationships are implied and practical.

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/sqemo/sqemo-mcp'

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