Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
handleYesThe expand_handle from a compressed result.

Implementation Reference

  • 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)]
  • 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"],
        },
    )
  • 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]
  • 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
  • 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
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided; description implies a read operation but does not detail any side effects, auth requirements, or handle expiration.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two efficient sentences front-load the purpose with no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter tool with no output schema, the description sufficiently guides usage, though output format is unstated.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds context that the handle comes from a compressed envelope, complementing the schema's parameter description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves the full content of a compressed result, using specific verb and resource.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description instructs to pass the expand_handle from a compressed envelope, implying the usage context, but lacks explicit conditions or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Yang1Bai/claw-tsaver'

If you have feedback or need assistance with the MCP directory API, please join our Discord server