rlm_list_contexts
List all loaded contexts and their metadata to monitor the state of recursive chunk analysis for massive datasets.
Instructions
List all loaded contexts and their metadata.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "rlm_list_contexts"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/rlm_mcp_server.py:1641-1668 (handler)The actual tool handler function for rlm_list_contexts. Returns a dict with 'contexts' key listing all loaded contexts and any disk-only contexts.
@mcp.tool() async def rlm_list_contexts() -> dict: """List all loaded contexts and their metadata.""" ctx_list = [ { "name": name, "length": ctx["meta"]["length"], "lines": ctx["meta"]["lines"], "chunked": ctx["meta"].get("chunks") is not None, } for name, ctx in contexts.items() ] for meta_file in CONTEXTS_DIR.glob("*.meta.json"): disk_name = meta_file.stem.replace(".meta", "") if disk_name not in contexts: meta = json.loads(meta_file.read_text()) ctx_list.append( { "name": disk_name, "length": meta["length"], "lines": meta["lines"], "chunked": meta.get("chunks") is not None, "disk_only": True, } ) return {"contexts": ctx_list} - src/rlm_mcp_server.py:1641-1643 (registration)Registered using the @mcp.tool() decorator on the async function rlm_list_contexts (line 1641).
@mcp.tool() async def rlm_list_contexts() -> dict: """List all loaded contexts and their metadata.""" - src/rlm_mcp_server.py:951-954 (helper)_hash_content helper used indirectly by context loading/saving functions that feed into list_contexts.
def _hash_content(content: str) -> str: """Create short hash for content identification.""" return hashlib.sha256(content.encode()).hexdigest()[:12] - src/rlm_mcp_server.py:1642-1642 (schema)No input args, returns dict with 'contexts' key containing list of context metadata objects (name, length, lines, chunked, disk_only).
async def rlm_list_contexts() -> dict: - src/rlm_mcp_server.py:956-977 (helper)_load_context_from_disk helper used by list_contexts to discover contexts stored on disk but not in memory.
def _load_context_from_disk(name: str) -> Optional[dict]: """Load context from disk if it exists.""" meta_path = CONTEXTS_DIR / f"{name}.meta.json" content_path = CONTEXTS_DIR / f"{name}.txt" if not (meta_path.exists() and content_path.exists()): return None meta = json.loads(meta_path.read_text()) meta["content"] = content_path.read_text() return meta def _save_context_to_disk(name: str, content: str, meta: dict) -> None: """Persist context to disk.""" (CONTEXTS_DIR / f"{name}.txt").write_text(content) meta_without_content = {k: v for k, v in meta.items() if k != "content"} (CONTEXTS_DIR / f"{name}.meta.json").write_text(json.dumps(meta_without_content, indent=2)) def _ensure_context_loaded(name: str) -> Optional[str]: """Ensure context is loaded into memory. Returns error message if not found."""