textrawl
byJeff Green

build_knowledge

Store multiple facts and relations in a single batch call

Store multiple entity facts and relations in a single call, reducing round-trips compared to separate remember_fact and relate_entities calls. Facts are processed first (creating entities as needed), then relations are created between them.

Parameters

ParameterTypeRequiredDefaultDescription
factsarrayOPTIONAL[]Facts to store (max 50)
facts[].entityNamestringREQUIRED-Entity name (1-200 chars)
facts[].entityTypeenumREQUIRED-Type: person, concept, project, preference, fact, location, organization
facts[].observationstringREQUIRED-Fact to remember (1-2000 chars)
facts[].sourceenumOPTIONALconversationSource: conversation, note, document, manual
relationsarrayOPTIONAL[]Relations to create (max 50)
relations[].fromEntitystringREQUIRED-Source entity name
relations[].relationstringREQUIRED-Relationship type (1-100 chars)
relations[].toEntitystringREQUIRED-Target entity name
relations[].fromEntityTypeenumOPTIONAL-Type of source entity
relations[].toEntityTypeenumOPTIONAL-Type of target entity

Example Request

{
  "facts": [
    {
      "entityName": "Jeff",
      "entityType": "person",
      "observation": "leads the backend team"
    },
    {
      "entityName": "Project Alpha",
      "entityType": "project",
      "observation": "uses PostgreSQL for the database layer"
    },
    {
      "entityName": "Sarah",
      "entityType": "person",
      "observation": "frontend lead, specializes in React"
    }
  ],
  "relations": [
    {
      "fromEntity": "Jeff",
      "relation": "works on",
      "toEntity": "Project Alpha"
    },
    {
      "fromEntity": "Sarah",
      "relation": "works on",
      "toEntity": "Project Alpha"
    }
  ]
}

Response

Compact Mode (Default)

When COMPACT_RESPONSES=true (default):

{"ok":true,"facts":{"new":3,"dup":0},"rel":2}

Verbose Mode

When COMPACT_RESPONSES=false:

{
  "success": true,
  "factsCreated": 3,
  "factsDuplicate": 0,
  "relationsCreated": 2
}

Use Cases

Building a project knowledge graph

{
  "facts": [
    {
      "entityName": "Textrawl",
      "entityType": "project",
      "observation": "personal knowledge base MCP server"
    },
    {
      "entityName": "Supabase",
      "entityType": "organization",
      "observation": "provides PostgreSQL hosting with pgvector support"
    }
  ],
  "relations": [
    {
      "fromEntity": "Textrawl",
      "relation": "hosted on",
      "toEntity": "Supabase"
    }
  ]
}

Recording meeting notes

{
  "facts": [
    {
      "entityName": "Sprint 46",
      "entityType": "project",
      "observation": "focus is on performance optimization",
      "source": "note"
    },
    {
      "entityName": "Jeff",
      "entityType": "person",
      "observation": "assigned to database query optimization",
      "source": "note"
    }
  ],
  "relations": [
    {
      "fromEntity": "Jeff",
      "relation": "assigned to",
      "toEntity": "Sprint 46"
    }
  ]
}

Relations only

{
  "relations": [
    {
      "fromEntity": "Jeff",
      "relation": "manages",
      "toEntity": "Sarah",
      "fromEntityType": "person",
      "toEntityType": "person"
    }
  ]
}

Duplicate Detection

Facts that are semantically similar to existing observations on the same entity are detected as duplicates and not stored again. The response includes a count of duplicates.

Errors

ErrorCauseFix
No facts or relations providedBoth arrays empty or missingProvide at least one fact or relation
Embedding service not configuredMissing OPENAI_API_KEY or Ollama configSet OPENAI_API_KEY or configure OLLAMA_BASE_URL
Database not configuredMissing Supabase credentialsSet SUPABASE_URL and SUPABASE_SERVICE_KEY
Memory not enabledENABLE_MEMORY feature flag is falseSet ENABLE_MEMORY=true
Array exceeds max sizeMore than 50 facts or 50 relationsSplit into multiple calls
  • remember_fact - Store a single fact (use build_knowledge for batch operations)
  • relate_entities - Create a single relation (use build_knowledge for batch operations)
  • query_memory - Search memories (mode="search") or get entity context (mode="entity")

On this page