Skip to main content
Glama

Graph Compact

graph_compact
Read-onlyIdempotent

Shrink a memory to the part that still earns its place. PREMIUM (license).

Ranks entities by how connected they are and how much is recorded about them, keeps anything you name outright, and drops the rest along with the relations that pointed at them. Typical input {"graph": {...}, "max_entities": 50, "keep": ["Acme Corp"]} returns {"graph": {...}, "kept": 50, "dropped_entities": ["Old Note", ...], "dropped_relations": 12, "ranking": "degree, then observation count, then name"}.

Use when a graph has outgrown the context you can spend on it. Not for removing wrong facts - graph_lint finds those, and deleting them is a decision you should make deliberately rather than by ranking. Errors: on invalid, missing, or malformed input this tool never raises a protocol error; it returns {"error": ""}. Every call is read-only and idempotent, so after correcting the input it is always safe to retry.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "graph": "<graph>"
    },
    "name": "graph_compact"
  }
}

Input Schema

NameRequiredDescriptionDefault
keepNoEntity names to keep regardless of rank, e.g. ["Acme Corp"]. Matched case-insensitively.
graphYesThe graph document to compact.
max_entitiesNoHow many entities to keep. Default 50.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already cover read-only, idempotent, non-destructive, and closed-world, so the description earns credit for adding beyond them: it specifies that malformed input returns an {"error": ...} payload rather than a protocol error, and that retry after correction is safe. It also discloses the exact ranking rule and the shape of the result.

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?

It is front-loaded with purpose, then usage, then mechanics, and every block carries information. The opening metaphor ("the part that still earns its place") is slightly decorative, but it is immediately grounded and costs only one clause.

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?

Even with an output schema present, the description supplies the return shape, the error contract, and the ranking semantics an agent needs to predict behavior. For a nested-object, three-parameter compaction tool nothing material is missing.

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%, so the baseline is 3; the description goes further by showing a concrete input example and spelling out the tiebreak chain (degree, then observation count, then name) that governs max_entities and the keep list. The case-insensitivity of keep is already in the schema, so no extra credit there.

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 names a specific operation on a specific resource: rank entities by connectivity and observation count, retain explicitly named ones, drop the remainder plus their relations. It also distinguishes itself from graph_lint by role, so an agent can tell the two apart 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?

It states the trigger condition plainly ("Use when a graph has outgrown the context you can spend on it") and an explicit exclusion with the correct alternative ("Not for removing wrong facts - graph_lint finds those"). Both when and when-not are covered.

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.