Skip to main content
Glama
egoughnour

Massive Context MCP

by egoughnour

rlm_sub_query_batch

Batch process sub-queries across multiple chunks of a large context using parallel requests. Configure LLM provider, model, and concurrency limit to manage system resources.

Instructions

Process multiple chunks in parallel. Respects concurrency limit to manage system resources.

Args: query: Question/instruction for each sub-call context_name: Context identifier chunk_indices: List of chunk indices to process provider: LLM provider - 'auto', 'ollama', or 'claude-sdk' model: Model to use (provider-specific defaults apply) concurrency: Max parallel requests (default 4, max 8)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
context_nameYes
chunk_indicesYes
providerNoauto
modelNo
concurrencyNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The FastMCP tool registration and handler for rlm_sub_query_batch. It delegates to the private implementation _sub_query_batch_impl.
    @mcp.tool()
    async def rlm_sub_query_batch(
        query: str,
        context_name: str,
        chunk_indices: list[int],
        provider: str = "auto",
        model: Optional[str] = None,
        concurrency: int = 4,
    ) -> dict:
        """Process multiple chunks in parallel. Respects concurrency limit to manage system resources.
    
        Args:
            query: Question/instruction for each sub-call
            context_name: Context identifier
            chunk_indices: List of chunk indices to process
            provider: LLM provider - 'auto', 'ollama', or 'claude-sdk'
            model: Model to use (provider-specific defaults apply)
            concurrency: Max parallel requests (default 4, max 8)
        """
        return await _sub_query_batch_impl(query, context_name, chunk_indices, provider, model, concurrency)
  • Core implementation logic for rlm_sub_query_batch. Validates inputs, then processes multiple chunks in parallel with a concurrency-limited semaphore, calling the LLM provider for each chunk.
    async def _sub_query_batch_impl(
        query: str,
        context_name: str,
        chunk_indices: list[int],
        provider: str = "auto",
        model: Optional[str] = None,
        concurrency: int = 4,
    ) -> dict:
        """Implementation of batch sub-query processing."""
        concurrency = min(concurrency, 8)
    
        # Resolve auto provider and model once for the entire batch
        resolved_provider, resolved_model = await _resolve_provider_and_model(provider, model)
    
        error = _ensure_context_loaded(context_name)
        if error:
            return {"error": "context_not_found", "message": error}
    
        chunks = contexts[context_name].get("chunks")
        if not chunks:
            return {"error": "context_not_chunked", "message": f"Context '{context_name}' has not been chunked yet"}
    
        invalid_indices = [idx for idx in chunk_indices if idx >= len(chunks)]
        if invalid_indices:
            return {
                "error": "invalid_chunk_indices",
                "message": f"Invalid chunk indices: {invalid_indices} (max: {len(chunks) - 1})",
            }
    
        semaphore = asyncio.Semaphore(concurrency)
    
        async def process_chunk(chunk_idx: int) -> dict:
            async with semaphore:
                chunk_content = chunks[chunk_idx]
                result, call_error = await _make_provider_call(resolved_provider, resolved_model, query, chunk_content)
    
                if call_error:
                    return {
                        "chunk_index": chunk_idx,
                        "error": "provider_error",
                        "message": call_error,
                    }
    
                return {
                    "chunk_index": chunk_idx,
                    "response": result,
                    "provider": resolved_provider,
                    "model": resolved_model,
                }
    
        results = await asyncio.gather(*[process_chunk(idx) for idx in chunk_indices])
    
        successful = sum(1 for r in results if "response" in r)
        failed = len(results) - successful
    
        return {
            "status": "completed",
            "total_chunks": len(chunk_indices),
            "successful": successful,
            "failed": failed,
            "concurrency": concurrency,
            "provider": resolved_provider,
            "model": resolved_model,
            "requested_provider": provider if provider == "auto" else None,
            "results": results,
        }
  • Registered as a FastMCP tool via @mcp.tool() decorator on the async function rlm_sub_query_batch.
    @mcp.tool()
    async def rlm_sub_query_batch(
        query: str,
        context_name: str,
        chunk_indices: list[int],
        provider: str = "auto",
        model: Optional[str] = None,
        concurrency: int = 4,
    ) -> dict:
        """Process multiple chunks in parallel. Respects concurrency limit to manage system resources.
    
        Args:
            query: Question/instruction for each sub-call
            context_name: Context identifier
            chunk_indices: List of chunk indices to process
            provider: LLM provider - 'auto', 'ollama', or 'claude-sdk'
            model: Model to use (provider-specific defaults apply)
            concurrency: Max parallel requests (default 4, max 8)
        """
        return await _sub_query_batch_impl(query, context_name, chunk_indices, provider, model, concurrency)
  • Input schema/parameters: query (str), context_name (str), chunk_indices (list[int]), provider (str, default 'auto'), model (Optional[str]), concurrency (int, default 4). Returns dict with status, results, etc.
    async def rlm_sub_query_batch(
        query: str,
        context_name: str,
        chunk_indices: list[int],
        provider: str = "auto",
        model: Optional[str] = None,
        concurrency: int = 4,
    ) -> dict:
Behavior2/5

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

With no annotations, the description must fully disclose behavior. It mentions parallelism and concurrency limits but fails to indicate side effects (e.g., whether results are stored), idempotency, or prerequisites like context loading. The output schema is present, so return values are covered, but behavioral traits are underexplained.

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 very concise: one sentence for purpose and a bullet-style list of parameters. No extraneous information; every sentence is necessary. It is well-structured and front-loaded.

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?

Given the existence of an output schema and sibling tools, the description covers the core functionality and parameter details well. However, it lacks mention of prerequisites (e.g., context must be loaded) and error handling in parallel processing, which would enhance completeness.

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

Parameters5/5

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

The schema description coverage is 0%, so the description carries the full burden. It provides clear explanations for all 6 parameters, including default values, allowed values (e.g., provider options), and clarification on model defaults. This adds significant value beyond the raw schema.

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

Purpose4/5

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

The description clearly states the tool processes multiple chunks in parallel, but it does not explicitly distinguish it from the sibling tool 'rlm_sub_query', which likely handles single sub-queries. The inclusion of 'batch' in the name and 'multiple chunks' provides some differentiation but not explicit contrast.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'rlm_sub_query'. The description only states what the tool does, without context on appropriate scenarios 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/egoughnour/massive-context-mcp'

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