results
Rich result types for Context Fabric API.
These classes wrap raw node IDs with contextual information, making them suitable for serialization and agent interaction via MCP.
Classes
CorpusInfo
Information about a loaded corpus.
Attributes
| Name | Type | Description |
|---|---|---|
| edge_features | list[str] | — |
| max_node | int | — |
| max_slot | int | — |
| name | str | — |
| node_features | list[str] | — |
| node_types | list[dict[(str, Any)]] | — |
| path | str | — |
| section_types | list[str] | — |
| slot_type | str | — |
Methods
__init__(self, name: str, path: str, node_types: list[dict[(str, Any)]] = {'arguments': [], 'cls': 'ExprCall', 'function': {'cls': 'ExprName', 'member': None, 'name': 'list'}}, node_features: list[str] = {'arguments': [], 'cls': 'ExprCall', 'function': {'cls': 'ExprName', 'member': None, 'name': 'list'}}, edge_features: list[str] = {'arguments': [], 'cls': 'ExprCall', 'function': {'cls': 'ExprName', 'member': None, 'name': 'list'}}, slot_type: str = '', max_slot: int = 0, max_node: int = 0, section_types: list[str] = {'arguments': [], 'cls': 'ExprCall', 'function': {'cls': 'ExprName', 'member': None, 'name': 'list'}}) → NoneParameters
name: strpath: strnode_types: list[dict[(str, Any)]]node_features: list[str]edge_features: list[str]slot_type: str= ''max_slot: int= 0max_node: int= 0section_types: list[str]
from_api(cls, api: Api, name: str, path: str) → CorpusInfoCreate CorpusInfo from API.
Parameters
clsapi: Apiname: strpath: str
to_dict(self) → dict[(str, Any)]Convert to JSON-serializable dictionary.
to_json(self) → strSerialize to JSON string.
FeatureInfo
Metadata about a feature.
Attributes
| Name | Type | Description |
|---|---|---|
| description | str | — |
| has_values | bool | None | — |
| kind | str | — |
| name | str | — |
| value_type | str | — |
Methods
__init__(self, name: str, kind: str, value_type: str = '', description: str = '', has_values: bool | None = None) → NoneParameters
name: strkind: strvalue_type: str= ''description: str= ''has_values: bool | None= None
from_api(cls, api: Api, name: str, kind: str) → FeatureInfo | NoneCreate FeatureInfo from API.
Parameters
clsapi: Apiname: strkind: str
to_dict(self) → dict[(str, Any)]Convert to JSON-serializable dictionary.
to_json(self) → strSerialize to JSON string.
NodeInfo
Rich representation of a single node.
Attributes
| Name | Type | Description |
|---|---|---|
| features | dict[(str, str | int)] | None | — |
| node | int | — |
| otype | str | — |
| section_ref | str | — |
| slots | tuple[(int, ...)] | None | — |
| text | str | — |
Methods
__init__(self, node: int, otype: str, text: str = '', section_ref: str = '', slots: tuple[(int, ...)] | None = None, features: dict[(str, str | int)] | None = None) → NoneParameters
node: intotype: strtext: str= ''section_ref: str= ''slots: tuple[(int, ...)] | None= Nonefeatures: dict[(str, str | int)] | None= None
from_api(cls, api: Api, node: int, include_text: bool = True, include_section: bool = True, include_slots: bool = False, include_features: list[str] | None = None) → NodeInfoCreate NodeInfo from API and node ID.
Parameters
clsapi: Apinode: intinclude_text: bool= Trueinclude_section: bool= Trueinclude_slots: bool= Falseinclude_features: list[str] | None= None
to_dict(self) → dict[(str, Any)]Convert to JSON-serializable dictionary.
to_json(self) → strSerialize to JSON string.
NodeList
A list of nodes with rich information.
Attributes
| Name | Type | Description |
|---|---|---|
| nodes | list[NodeInfo] | — |
| query | str | None | — |
| total_count | int | — |
Methods
__init__(self, nodes: list[NodeInfo] = {'arguments': [], 'cls': 'ExprCall', 'function': {'cls': 'ExprName', 'member': None, 'name': 'list'}}, total_count: int = 0, query: str | None = None) → NoneParameters
nodes: list[NodeInfo]total_count: int= 0query: str | None= None
from_nodes(cls, api: Api, nodes: list[int] | tuple[(int, ...)], limit: int | None = None, query: str | None = None, node_kwargs: Any = {}) → NodeListCreate NodeList from API and node IDs.
Parameters
clsapi: Apinodes: list[int] | tuple[(int, ...)]limit: int | None= Nonequery: str | None= Nonenode_kwargs: Any= {}
to_dict(self) → dict[(str, Any)]Convert to JSON-serializable dictionary.
to_json(self) → strSerialize to JSON string.
SearchResult
Result of a search query.
Attributes
| Name | Type | Description |
|---|---|---|
| plan | str | None | — |
| results | list[list[NodeInfo]] | — |
| template | str | — |
| total_count | int | — |
Methods
__init__(self, results: list[list[NodeInfo]] = {'arguments': [], 'cls': 'ExprCall', 'function': {'cls': 'ExprName', 'member': None, 'name': 'list'}}, total_count: int = 0, template: str = '', plan: str | None = None) → NoneParameters
results: list[list[NodeInfo]]total_count: int= 0template: str= ''plan: str | None= None
from_search(cls, api: Api, results: tuple[(tuple[(int, ...)], ...)] | list[tuple[(int, ...)]], template: str, limit: int | None = None, node_kwargs: Any = {}) → SearchResultCreate SearchResult from search results.
Parameters
clsapi: Apiresults: tuple[(tuple[(int, ...)], ...)] | list[tuple[(int, ...)]]template: strlimit: int | None= Nonenode_kwargs: Any= {}
to_dict(self) → dict[(str, Any)]Convert to JSON-serializable dictionary.
to_json(self) → strSerialize to JSON string.