Skip to main content

Overview

The link() method creates directional relations between resources, enabling you to build a knowledge graph of connected contexts. Relations help organize information and improve retrieval.
Relations are directional: linking A → B does not automatically create B → A.

Method Signature

Parameters

string
required
Source URI to link from
string | List[string]
required
Target URI(s) to link to. Can be a single string or list of URIs.
string
default:""
Human-readable explanation of why resources are related

Examples

Build Knowledge Graph

Response

Use Cases

  1. Code-to-Docs Mapping - Link implementation files to their documentation
  2. Citation Networks - Connect papers, articles, and references
  3. Example Organization - Link tutorials to their example code
  4. Concept Graphs - Build semantic networks between ideas
  5. Navigation Hints - Create “see also” or “related” connections

Best Practices

Use descriptive reasons to make relations self-documenting and easier to understand.

Notes

  • Relations are directional: A → B ≠ B → A
  • Relations are stored persistently in the context database
  • Relations improve retrieval: related resources can be discovered during semantic search
  • Use relations() to query existing links
  • Use unlink() to remove relations