Getting Started
Context-Fabric is a graph-based corpus engine for annotated text. It handles the kind of linguistic data that makes traditional databases weep: standoff annotation, overlapping hierarchies, millions of interconnected nodes. Built on the proven Text-Fabric data model, it uses memory-mapped storage for production deployments where performance actually matters.
Installation
Install the core library:
pip install context-fabric
For AI agent integration via the Model Context Protocol:
pip install context-fabric[mcp]
Python Version
Context-Fabric requires Python 3.10 or later.
What You Get
The core library provides:
- Fast Loading — Memory-mapped arrays mean instant corpus loads after initial compilation. No deserialization overhead.
- Graph Navigation — Traverse containment hierarchies, walk nodes in canonical order, locate slots within structures.
- Pattern Search — Query structural patterns across the entire corpus. Find all verses containing a specific verb form, or all clauses with a particular syntactic structure.
- Feature Access — Linguistic annotations (part of speech, morphology, syntactic roles) available as node and edge features.
The MCP server extends this to AI workflows:
- Agent-Friendly API — Ten tools designed for iterative, token-efficient exploration.
- Corpus Discovery — Let Claude or GPT-4 explore what features and node types exist before querying.
- Structured Results — Search returns references, not raw data dumps.
A Quick Taste
Here's what working with Context-Fabric looks like:
import cfabric
# Download a corpus (BHSA - the Hebrew Bible)
path = cfabric.download('bhsa')
# Load it
CF = cfabric.Fabric(locations=path)
api = CF.loadAll()
# Find all words with lexeme "MLK" (king)
results = api.S.search('''
word lex=MLK
''')
# How many?
print(f"Found {len(list(results))} occurrences")
That's the entire Hebrew Bible—426,555 words, each one tagged with morphology, syntax, and discourse features by scholars who probably needed a vacation afterward. Context-Fabric queries all of it in milliseconds.
Next Steps
- Loading Your First Corpus — Download BHSA and understand the API structure
- Exploring Corpus Structure — Discover node types, features, and annotation layers