Skip to main content
Glama

twining_add_relation

Create connections between knowledge graph entities by specifying source, target, and relation type to build structured relationships for development task coordination.

Instructions

Add a relation between two knowledge graph entities. Source and target can be entity IDs or names. Returns an error for ambiguous name matches.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesSource entity ID or name
targetYesTarget entity ID or name
typeYesRelation type: "depends_on", "implements", "decided_by", "affects", "tested_by", "calls", "imports", "related_to"
propertiesNoKey-value properties for this relation (max 50 entries, values ≤1000 chars)

Implementation Reference

  • MCP tool registration for twining_add_relation which calls the graph engine's addRelation method.
    // twining_add_relation — Add a relation between two entities
    server.registerTool(
      "twining_add_relation",
      {
        description:
          "Add a relation between two knowledge graph entities. Source and target can be entity IDs or names. Returns an error for ambiguous name matches.",
        inputSchema: {
          source: z
            .string()
            .describe("Source entity ID or name"),
          target: z
            .string()
            .describe("Target entity ID or name"),
          type: z
            .string()
            .describe(
              'Relation type: "depends_on", "implements", "decided_by", "affects", "tested_by", "calls", "imports", "related_to"',
            ),
          properties: z
            .record(z.string().max(1000))
            .optional()
            .refine(
              (obj) => obj === undefined || Object.keys(obj).length <= 50,
              { message: "Maximum 50 properties per relation" },
            )
            .describe("Key-value properties for this relation (max 50 entries, values ≤1000 chars)"),
        },
      },
      async (args) => {
        try {
          const relation = await engine.addRelation({
            source: args.source,
            target: args.target,
            type: args.type as Parameters<typeof engine.addRelation>[0]["type"],
            properties: args.properties,
          });
          return toolResult({ id: relation.id });
        } catch (e) {
          if (e instanceof TwiningError) {
            return toolError(e.message, e.code);
          }
          return toolError(
            e instanceof Error ? e.message : "Unknown error",
            "INTERNAL_ERROR",
          );
        }
      },
    );
  • GraphEngine implementation of addRelation, which delegates to the graph store.
    /** Delegate relation creation to store. */
    async addRelation(input: {
      source: string;
      target: string;
      type: Relation["type"];
      properties?: Record<string, string>;
    }): Promise<Relation> {
      return this.graphStore.addRelation(input);
    }

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