Skip to main content
Glama
egoughnour

Massive Context MCP

by egoughnour

rlm_chunk_context

Divide massive contexts into smaller chunks using configurable strategies (lines, chars, paragraphs). Returns chunk metadata to facilitate processing of datasets exceeding standard context limits.

Instructions

Chunk a loaded context by strategy. Returns chunk metadata, not full content.

Args: name: Context identifier strategy: Chunking strategy - 'lines', 'chars', or 'paragraphs' size: Chunk size (lines/chars depending on strategy)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
strategyNolines
sizeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool 'rlm_chunk_context' is registered as a FastMCP tool using the @mcp.tool() decorator. Defines input parameters: name (str), strategy (str, default 'lines'), size (int, default 100). Delegates to _chunk_context_impl.
    @mcp.tool()
    async def rlm_chunk_context(
        name: str,
        strategy: str = "lines",
        size: int = 100,
    ) -> dict:
        """Chunk a loaded context by strategy. Returns chunk metadata, not full content.
    
        Args:
            name: Context identifier
            strategy: Chunking strategy - 'lines', 'chars', or 'paragraphs'
            size: Chunk size (lines/chars depending on strategy)
        """
        return await _chunk_context_impl(name, strategy, size)
  • The _chunk_context_impl function contains the actual implementation logic. It ensures the context is loaded, calls _chunk_content to split it, stores chunk metadata in memory and on disk, and returns chunk metadata.
    async def _chunk_context_impl(
        name: str,
        strategy: str = "lines",
        size: int = 100,
    ) -> dict:
        """Implementation of context chunking."""
        error = _ensure_context_loaded(name)
        if error:
            return {"error": "context_not_found", "message": error}
    
        content = contexts[name]["content"]
        chunks = _chunk_content(content, strategy, size)
    
        chunk_meta = [{"index": i, "length": len(chunk), "preview": chunk[:100]} for i, chunk in enumerate(chunks)]
    
        contexts[name]["meta"]["chunks"] = chunk_meta
        contexts[name]["chunks"] = chunks
    
        chunk_dir = CHUNKS_DIR / name
        chunk_dir.mkdir(exist_ok=True)
        for i, chunk in enumerate(chunks):
            (chunk_dir / f"{i}.txt").write_text(chunk)
    
        return {
            "status": "chunked",
            "name": name,
            "strategy": strategy,
            "chunk_count": len(chunks),
            "chunks": chunk_meta,
        }
  • The _chunk_content helper function splits content into chunks using the specified strategy: 'lines' (by line count), 'chars' (by character count), or 'paragraphs' (by paragraph count).
    def _chunk_content(content: str, strategy: str, size: int) -> list[str]:
        """Chunk content using the specified strategy."""
        if strategy == "lines":
            lines = content.split("\n")
            return ["\n".join(lines[i : i + size]) for i in range(0, len(lines), size)]
        elif strategy == "chars":
            return [content[i : i + size] for i in range(0, len(content), size)]
        elif strategy == "paragraphs":
            paragraphs = re.split(r"\n\s*\n", content)
            return ["\n\n".join(paragraphs[i : i + size]) for i in range(0, len(paragraphs), size)]
        return []
  • The _ensure_context_loaded helper ensures the named context is available in memory, loading from disk if necessary.
    def _ensure_context_loaded(name: str) -> Optional[str]:
        """Ensure context is loaded into memory. Returns error message if not found."""
        if name in contexts:
            return None
    
        disk_context = _load_context_from_disk(name)
        if disk_context:
            content = disk_context.pop("content")
            contexts[name] = {"meta": disk_context, "content": content}
            return None
    
        return f"Context '{name}' not found"
Behavior3/5

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

No annotations are provided, so the description must convey behavioral traits. It notes that only metadata is returned, not full content, and lists the strategies. However, it does not disclose whether chunking modifies the original context, side effects, or required permissions.

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?

The description is three sentences with no filler. It front-loads the purpose and follows with parameter details. Every sentence adds value; no redundancy.

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?

The tool has an output schema, so return value details are not needed. The description covers parameters and output type. However, it lacks explicit preconditions (e.g., context must be loaded) and does not differentiate from sibling chunk-related tools. Still, it is adequately complete for a straightforward tool.

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?

Schema description coverage is 0%, so the description is essential. It explains 'name' as context identifier, 'strategy' with valid options (lines, chars, paragraphs), and 'size' with context-dependent meaning. This adds significant value beyond the schema's type/default info.

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 action ('chunk'), the resource ('a loaded context'), and the output ('chunk metadata, not full content'). It distinguishes from siblings like rlm_load_context and rlm_get_chunk which have different purposes.

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

Usage Guidelines3/5

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

The description implies that the context must be loaded before chunking, but does not explicitly state when to use this tool versus alternatives like rlm_filter_context. No exclusions or prerequisites are mentioned.

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/egoughnour/massive-context-mcp'

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