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",

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