expand_content
Retrieve the full content of a compressed tool result using the expand_handle, restoring data that was reduced by the token-saving compression.
Instructions
Retrieve the full content of a previously compressed tool result. Pass the expand_handle returned in the compressed envelope.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| handle | Yes | The expand_handle from a compressed result. |
Implementation Reference
- src/claw_tsaver/proxy.py:229-239 (handler)Handler for the expand_content tool: retrieves stored content by handle from the SQLite store and returns it as text.
if name == "expand_content": handle = str(args.get("handle", "")) full = store.get_expansion(handle) if full is None: return [ TextContent( type="text", text=f"No expansion found for handle '{handle}'.", ) ] return [TextContent(type="text", text=full)] - src/claw_tsaver/proxy.py:178-194 (schema)Tool definition and input schema for expand_content: takes a single 'handle' string parameter.
EXPAND_TOOL = Tool( name="expand_content", description=( "Retrieve the full content of a previously compressed tool result. " "Pass the expand_handle returned in the compressed envelope." ), inputSchema={ "type": "object", "properties": { "handle": { "type": "string", "description": "The expand_handle from a compressed result.", } }, "required": ["handle"], }, ) - src/claw_tsaver/proxy.py:218-220 (registration)Registration: EXPAND_TOOL is included in the list of tools exposed by the MCP server.
@server.list_tools() async def _list_tools() -> list[Tool]: return [EXPAND_TOOL, *registry.tools] - src/claw_tsaver/store.py:50-56 (helper)Helper function that retrieves the stored full content for a given handle from the SQLite database.
def get_expansion(handle: str) -> str | None: """Return the stored content for ``handle``, or ``None`` if unknown.""" with _connect() as conn: row = conn.execute( "SELECT full_content FROM expansions WHERE id = ?", (handle,) ).fetchone() return row[0] if row else None - src/claw_tsaver/store.py:38-47 (helper)Helper function that saves full content to the SQLite store and returns a handle used by expand_content.
def save_expansion(tool_name: str, full_content: str) -> str: """Persist ``full_content`` and return a freshly minted handle.""" handle = "exp_" + secrets.token_hex(4) # 8 hex chars after the prefix with _connect() as conn: conn.execute( "INSERT INTO expansions (id, timestamp, tool_name, full_content) " "VALUES (?, ?, ?, ?)", (handle, int(time.time()), tool_name, full_content), ) return handle