Skip to main content
Glama

Graph Upsert

graph_upsert
Read-onlyIdempotent

Fold new facts into a memory graph and get the whole graph back. FREE.

Idempotent by construction: re-adding the same entity, observation or relation changes nothing, so an agent that replays its own history does not end up with a graph full of duplicates. Typical input {"graph": {"entities": [], "relations": []}, "entities": [{"name": "Acme Corp", "type": "company", "observations": ["renewed in March"]}]} returns {"graph": {...}, "added": {"entities": 1, "observations": 1, "relations": 0}, "merged": 0}.

Use as the single write path for memory. Not for reading it back selectively - that is graph_search - and not for finding out what a write changed, which graph_diff answers precisely. Errors: on invalid, missing, or malformed input this tool never raises a protocol error; it returns {"error": ""} (for example {"error": "graph exceeds entities; split it"}). Every call is read-only and idempotent, so after correcting the input it is always safe to retry.

Input Schema

NameRequiredDescriptionDefault
graphNoThe existing graph document, or omitted to start a new one. Shape: {"entities": [...], "relations": [...]}.
entitiesNoEntities to add or extend, each {"name": ..., "type": ..., "observations": [...]}. Observations are appended and deduplicated; an existing entity keeps its type unless a new one is supplied.
relationsNoRelations to add, each {"from": ..., "to": ..., "type": ..., and optionally "since", "until", "confidence"}. Dates are ISO 8601 (YYYY-MM-DD); confidence is 0 to 1.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint and destructiveHint=false, but the description earns credit by adding the duplicate-suppression semantics, a concrete size-limit failure ("graph exceeds <value> entities; split it"), and the contract that errors are returned in-band rather than raised as protocol errors, making retry-after-correction safe. It also pre-empts the apparent tension between "write path" language and readOnlyHint by stating every call is read-only and idempotent.

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 key claim and the free/idempotent framing are front-loaded, and paragraphs are organized as purpose, behavior, alternatives, errors. Mild redundancy remains: the example return payload duplicates what the output schema already provides, and idempotency is stated twice.

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 3-parameter tool with an output schema, annotations, and complete schema coverage, nothing an agent needs is missing: purpose, sibling routing, example input/output, idempotency guarantees, size limits, and the error envelope are all covered.

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 100%, so the baseline is 3, but the description adds a worked input example showing how pre-existing graph state composes with new entities, plus the merge/append behavior on observations. That gives an agent a concrete call shape the schema alone does not illustrate; only the relations parameter is left entirely to the schema.

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?

"Fold new facts into a memory graph and get the whole graph back" names a specific verb (fold/upsert) and resource (memory graph), and immediately states the whole-graph return behavior that distinguishes it from an incremental writer. An agent can separate it from graph_search and graph_diff from the description alone.

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?

Explicitly designates itself "the single write path for memory" and rules out two alternatives by name: graph_search for selective reads and graph_diff for finding what a write changed. Both the when-to-use and the when-not-to-use are stated.

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.