Skip to main content
Glama

twining_prune_graph

Clean up a knowledge graph by removing orphaned entities that have no relations. Optionally filter by entity type or run in dry-run mode to preview changes.

Instructions

Remove orphaned knowledge graph entities that have no relations. Use this to clean up stale or disconnected entities. Optionally filter by entity type to only prune certain kinds.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entity_typesNoOnly prune orphans of these types (e.g., ["concept", "file"]). If omitted, prunes all orphan types.
dry_runNoIf true, report orphans without removing them (default: false)

Implementation Reference

  • The handler for the twining_prune_graph tool, which delegates to the engine's prune method.
    // twining_prune_graph — Remove orphaned graph entities
    server.registerTool(
      "twining_prune_graph",
      {
        description:
          "Remove orphaned knowledge graph entities that have no relations. Use this to clean up stale or disconnected entities. Optionally filter by entity type to only prune certain kinds.",
        inputSchema: {
          entity_types: z
            .array(z.string())
            .optional()
            .describe(
              'Only prune orphans of these types (e.g., ["concept", "file"]). If omitted, prunes all orphan types.',
            ),
          dry_run: z
            .boolean()
            .optional()
            .describe(
              "If true, report orphans without removing them (default: false)",
            ),
        },
      },
      async (args) => {
        try {
          const result = await engine.prune(
            args.entity_types,
            args.dry_run ?? false,
          );
          return toolResult(result);
        } catch (e) {
          if (e instanceof TwiningError) {
            return toolError(e.message, e.code);
          }
          return toolError(
            e instanceof Error ? e.message : "Unknown error",
            "INTERNAL_ERROR",
          );
        }
      },
    );
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the tool's destructive nature ('Remove') and optional filtering, but lacks details on permissions needed, rate limits, or what happens to removed entities (e.g., irreversible deletion). This leaves behavioral gaps for a mutation tool.

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 front-loaded with the core purpose in the first sentence, followed by usage context and optional features, with no wasted words. Every sentence contributes directly to tool understanding, 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?

For a destructive tool with no annotations and no output schema, the description is adequate but incomplete. It covers the what and why, but lacks details on outcomes (e.g., confirmation messages, error handling) and safety considerations, which are crucial given the tool's potential impact.

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 schema fully documents parameters. The description adds value by explaining the purpose of 'entity_types' ('only prune certain kinds') and implying 'dry_run' functionality ('report orphans without removing'), enhancing understanding beyond the schema's technical details.

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 specific action ('Remove orphaned knowledge graph entities') and resource ('knowledge graph entities'), distinguishing it from siblings like 'twining_add_entity' or 'twining_graph_query' by focusing on cleanup of disconnected data rather than creation or querying.

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 the tool ('to clean up stale or disconnected entities'), but does not explicitly mention when not to use it or name specific alternatives among the many sibling tools, such as 'twining_archive' or 'twining_dismiss', which might serve related purposes.

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/daveangulo/twining-mcp'

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