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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Entity name (e.g., class name, file path, concept) | |
| type | Yes | Entity type: "module", "function", "class", "file", "concept", "pattern", "dependency", "api_endpoint" | |
| properties | No | Key-value properties for this entity (max 50 entries, values ≤1000 chars) |
Implementation Reference
- src/tools/graph-tools.ts:37-54 (handler)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", ); } }, - src/tools/graph-tools.ts:17-36 (schema)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)"), }, }, - src/tools/graph-tools.ts:15-16 (registration)Registration of the tool "twining_add_entity" in the MCP server.
server.registerTool( "twining_add_entity",