Skip to main content
Glama

twining_add_entity

Add or update entities in a knowledge graph for development coordination, using upsert semantics to merge properties when entities already exist.

Instructions

Add or update a knowledge graph entity. Uses upsert semantics: if an entity with the same name and type exists, its properties are merged and updated. Returns the entity ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesEntity name (e.g., class name, file path, concept)
typeYesEntity type: "module", "function", "class", "file", "concept", "pattern", "dependency", "api_endpoint"
propertiesNoKey-value properties for this entity (max 50 entries, values ≤1000 chars)

Implementation Reference

  • The handler function for twining_add_entity that invokes the engine.addEntity method.
    async (args) => {
      try {
        const entity = await engine.addEntity({
          name: args.name,
          type: args.type as Parameters<typeof engine.addEntity>[0]["type"],
          properties: args.properties,
        });
        return toolResult({ id: entity.id });
      } catch (e) {
        if (e instanceof TwiningError) {
          return toolError(e.message, e.code);
        }
        return toolError(
          e instanceof Error ? e.message : "Unknown error",
          "INTERNAL_ERROR",
        );
      }
    },
  • The input schema definition for twining_add_entity.
    {
      description:
        "Add or update a knowledge graph entity. Uses upsert semantics: if an entity with the same name and type exists, its properties are merged and updated. Returns the entity ID.",
      inputSchema: {
        name: z.string().describe("Entity name (e.g., class name, file path, concept)"),
        type: z
          .string()
          .describe(
            'Entity type: "module", "function", "class", "file", "concept", "pattern", "dependency", "api_endpoint"',
          ),
        properties: z
          .record(z.string().max(1000))
          .optional()
          .refine(
            (obj) => obj === undefined || Object.keys(obj).length <= 50,
            { message: "Maximum 50 properties per entity" },
          )
          .describe("Key-value properties for this entity (max 50 entries, values ≤1000 chars)"),
      },
    },
  • Registration of the tool "twining_add_entity" in the MCP server.
    server.registerTool(
      "twining_add_entity",
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 key behavioral traits: upsert semantics (merge/update), return value (entity ID), and constraints (property merging). However, it lacks details on permissions, rate limits, error conditions, or side effects like whether this triggers notifications or indexing.

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?

Two sentences with zero waste: first defines purpose and behavior, second states return value. It's front-loaded with essential information and appropriately sized for the tool's complexity.

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

Completeness4/5

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

Given 3 parameters with full schema coverage and no output schema, the description is mostly complete: it explains the core operation and return value. However, for a mutation tool with no annotations, it could benefit from more behavioral context like idempotency guarantees or error handling.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/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 no additional parameter semantics beyond what's in the schema (e.g., no examples or edge cases). Baseline 3 is appropriate when schema does the heavy lifting.

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 verb ('add or update'), resource ('knowledge graph entity'), and mechanism ('upsert semantics') with specific details about merging properties. It distinguishes from siblings like twining_add_relation (which handles relationships) and twining_query (which reads entities).

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?

The description provides clear context for usage ('add or update a knowledge graph entity') and explains the upsert behavior, but it doesn't explicitly state when to use this tool versus alternatives like twining_archive or twining_prune_graph for deletion scenarios, or twining_read for read-only access.

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