tools
MCP tool implementations for Context-Fabric.
Tools are functions that agents can execute to interact with corpora.
Classes
_CachedSearch
A search executed through the shared result cache.
Attributes
| Name | Type | Description |
|---|---|---|
| _fresh_results | — | — |
| _search_api | — | — |
| _template | — | — |
| cached | — | — |
Methods
__init__(self, search_api: Any, template: str, cached: CachedSearchResult, fresh_results: list[tuple[(int, ...)]] | None) → NoneParameters
search_api: Anytemplate: strcached: CachedSearchResultfresh_results: list[tuple[(int, ...)]] | None
all_results(self) → list[tuple[(int, ...)]]Return every match, sorted like the cached results.
run(cls, search_api: Any, corpus_name: str, template: str) → _CachedSearchExecute `template`, or reuse the cached result for it.
Parameters
clssearch_api: Anycorpus_name: strtemplate: str
_Current
`corpus_manager` as the tools see it: the registry bound now.
Functions
describe_corpus(corpus: str | None = None) → dict[(str, Any)]Get corpus structure overview.
Parameters
corpus: str | None= None
describe_features(features: str | list[str], sample_limit: int = 20, corpus: str | None = None) → dict[(str, Any)]Get detailed info about one or more features.
Parameters
features: str | list[str]sample_limit: int= 20corpus: str | None= None
get_corpus_info(corpus: str | None = None) → dict[(str, Any)]Get detailed information about a loaded corpus.
Parameters
corpus: str | None= None
get_node_features(nodes: list[int], features: list[str], corpus: str | None = None) → dict[(str, Any)]Get feature values for a list of nodes.
Parameters
nodes: list[int]features: list[str]corpus: str | None= None
get_passages(sections: list[list[str | int]], limit: int = 50, lang: str = 'en', max_override: bool = False, corpus: str | None = None) → dict[(str, Any)]Get passages by section references.
Parameters
sections: list[list[str | int]]limit: int= 50lang: str= 'en'max_override: bool= Falsecorpus: str | None= None
get_text_formats(corpus: str | None = None) → dict[(str, Any)]Get text format samples showing how text is encoded in this corpus.
Parameters
corpus: str | None= None
list_features(kind: str = 'all', node_types: list[str] | None = None, corpus: str | None = None) → dict[(str, Any)]List all features with optional filtering.
Parameters
kind: str= 'all'node_types: list[str] | None= Nonecorpus: str | None= None
list_loaded_corpora() → dict[(str, Any)]List all currently loaded corpora.
search(template: str, return_type: str = 'results', aggregate_features: list[str] | None = None, group_by_section: bool = False, top_n: int = 50, limit: int = 100, max_override: bool = False, corpus: str | None = None) → dict[(str, Any)]Search for patterns in the corpus.
Parameters
template: strreturn_type: str= 'results'aggregate_features: list[str] | None= Nonegroup_by_section: bool= Falsetop_n: int= 50limit: int= 100max_override: bool= Falsecorpus: str | None= None
search_continue(cursor_id: str, offset: int = 0, limit: int = 100, max_override: bool = False) → dict[(str, Any)]Continue a paginated search using a cursor ID.
Parameters
cursor_id: stroffset: int= 0limit: int= 100max_override: bool= False
search_csv(template: str, file_path: str, limit: int = 10000, delimiter: str = ',', corpus: str | None = None) → dict[(str, Any)]Export search results to a CSV file.
Parameters
template: strfile_path: strlimit: int= 10000delimiter: str= ','corpus: str | None= None
search_syntax_guide(section: str | None = None) → dict[(str, Any)]Get documentation on search template syntax.
Parameters
section: str | None= None
set_transport(transport: str) → NoneSet the transport mode (called by server at startup).
Parameters
transport: str
using(registry: Any) → Iterator[None]Run the tools in this block on `registry` instead of the server's.
Parameters
registry: Any