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",
          );
        }
      },
    );

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