Working memory for scripts and agents: typed records as one graph, in memory.
Your records, typed by JSON declarations, load from a directory or a bundle into an immutable graph held in your process. Search, walk and pack it into a token budget with retrieval pipelines that say why each item is there; publish a knowledge base as one versioned file; and serve it to an agent over MCP.
pip install forktex-data # the library
pip install "forktex-data[mcp]" # and forktex-data-mcp, the bundle server
import asyncio
from forktex_data import (
ConstrainedWalk, Graph, LexicalSeeds, Moves, Pack, Pipeline, RecordCodec, TextIndex, TypeCatalog,
)
types = TypeCatalog()
types.declare_all(
[
{
"$type": "TypeDeclaration",
"name": "Note",
"role": "Node",
"fields": {"title": {"type": "string"}, "body": {"type": ["string", "null"]}},
"required": ["title"],
"spec": {"levels": {"brief": ["title"], "full": ["title", "body"]}},
},
{"$type": "TypeDeclaration", "name": "cites", "role": "Edge"},
]
)
ASK = Pipeline(
steps=(
TextIndex(fields={"title": 3, "body": 1}),
LexicalSeeds(limit=2),
ConstrainedWalk(moves=Moves(follow={"cites": 1.0}), hops=2),
Pack(budget_tokens=200, levels=("brief", "full")),
)
)
async def main() -> None:
codec = RecordCodec(types)
graph = Graph(
types,
[
codec.decode({"$type": "Note", "$id": "tides", "title": "Tides", "body": "The sea rises with the moon."}),
codec.decode({"$type": "Note", "$id": "moon", "title": "The moon", "body": "It keeps its distance."}),
codec.decode({"$type": "cites", "$id": "c1", "source": "tides", "target": "moon"}),
],
)
result = await ASK.run(graph, "why does the sea rise")
for item in result.packed.items:
print(item.id, item.level, [hop.to for hop in item.path]) # tides full [] / moon full ['moon']
asyncio.run(main())
Requirements
| Python | 3.14, with or without the GIL |
| Event loop | asyncio |
| Dependencies | forktex and pydantic; the mcp extra adds the mcp SDK. No service of any kind |
| Data | JSON records of types you declare, each naming its $type and $id. Everything is held in memory |
What you can build
| You want to | Read |
|---|---|
| Declare record types as JSON documents — formats, patterns, inheritance, graph rules | Declare your types |
| Load a directory of records as one graph, strictly or leniently | Load a directory |
| Search, walk and pack a graph into a token budget, with provenance | Run a pipeline |
| Scope a walk by type, depth, place and fields, as data | Admit nodes with a graph filter |
| Store a pipeline as JSON and run it again identically | Store and send a pipeline |
| Publish a knowledge base as one pinned file a reader opens without your code | Publish a bundle |
| Let Claude, or any MCP client, query a bundle offline | Serve a bundle over MCP |
How it works
| Concept | What it is |
|---|---|
| Record | A frozen pydantic value with $type, $id and optionally $v: a Node, which may be owned by another node, or an Edge between two nodes |
| Type catalogue | The types you own, each declared at runtime by a TypeDeclaration document: its fields, text levels, sibling order and graph rules |
| Graph | Every record, built once and never changed: nodes by $id, who owns whom, and which edges join what |
| Pipeline | A closed list of steps, checked against the graph, then run: choose a text index, seed by BM25, walk weighted moves, pack into a budget. A typed JSON document |
| Graph filter | Which nodes a walk may enter — by type, depth, place and fields — as data |
| Bundle | A knowledge base as one JSON Lines file: declarations, records, text index, named pipelines, a content hash |
| Bundle server | forktex-data-mcp --bundle PATH: six read-only MCP tools over stdio, plus your own |
The ideas in ten minutes: concepts.
Things to know
| It is working memory, not storage | A graph lives in one process, and nothing is written back. Tables and durable, shared storage are forktex-grid's; workflows are forktex-flow's. Persist what you need as record JSON or a bundle |
| A graph is built once | There are no updates: build a new graph from the records you want. Any number of tasks may read and run over one at once without a lock |
| The API is async where it is data-sized | load, Pipeline.run, write_bundle and open_bundle compute on a worker thread, so the event loop is never blocked; lookups are plain calls |
| Every refusal names every problem | One DataError with details["problems"]; a node that is not there raises its subclass DataNotFoundError |
| Documents run no code | Pipelines, filters, templates and declarations are data; a pipeline names only the four shipped steps |
| Results are deterministic | The same records and query give the same bytes, whatever the file order |
Documentation
| Page | For |
|---|---|
| Concepts | How it thinks, in ten minutes |
| Guide | Runnable files for each way to use it |
| Reference | Every public name, document and refusal |
| Operating | Sizes, threads, memory, determinism, serving |
Stability
Pre-1.0. Semantic versioning covers every name in forktex_data.__all__ and
forktex_data.server.__all__, the JSON documents the library reads and
writes, the bundle format and the bundle server's tools; until 1.0 a minor
version may change them, and the CHANGELOG says how. Changes are listed in the
CHANGELOG.
Contributing
Working on forktex-data itself? Start with
docs/development.md.
Security issues go to the address in
SECURITY.md.
Licence
AGPL-3.0-or-later, or a commercial licence from FORKTEX S.R.L. (info@forktex.com). See LICENSE and NOTICE.
Metadata
Release files for forktex-data 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| forktex_data-0.1.0.tar.gz | 265.7 kB | Without provenance | Details for forktex_data-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| forktex_data-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for forktex_data-0.1.0-py3-none-any.whl |
Total release size: 311.4 kB
Release files / forktex_data-0.1.0.tar.gz
| Download URL | forktex_data-0.1.0.tar.gz |
|---|---|
| Size | 265.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e05e29a1ceb7354a2c51fef77dced2408a7ef7279da9311cf11b1f61ec803cfb
|
|
BLAKE2b-256 checksum How to use checksums |
425b0576acb2ba85ce75a1b801d187e44bf025d69c20eff6aa7114309efda005
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|
Release files / forktex_data-0.1.0-py3-none-any.whl
| Download URL | forktex_data-0.1.0-py3-none-any.whl |
|---|---|
| Size | 45.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
917700d7d626d004f6c06253b5535f8a3345793184e2f013366d11e6cfbd68bb
|
|
BLAKE2b-256 checksum How to use checksums |
f80809e4382bf025aa4a989646bad4cacb5c56dd9017baec834c20f52710dd60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|
Security for forktex-data 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.