Skip to main content
Glama
@memoryrelay/mcp-server

@memoryrelay/mcp-server

Official
by memoryrelay

context_build

Builds ranked, token-budgeted context bundles from memories by searching, scoring, and optionally summarizing relevant results for LLM prompts.

Instructions

Build a ranked context bundle from memories using V2 API with optional AI summarization. Searches for relevant memories, ranks them by composite score, and optionally generates an AI summary. Useful for building token-efficient context windows for LLM prompts. Supports custom LLM endpoints (Ollama, llama.cpp, vLLM, etc.).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>"
    },
    "name": "context_build"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYesContext query describing what information is needed
llm_modelNoModel name for custom LLM (e.g., "mistral", "llama3", "gemma")
max_tokensNoToken budget for context window (enforces truncation)
ai_enhancedNoEnable AI summarization of context (uses LLM)
llm_api_urlNoCustom LLM API URL for summarization (OpenAI-compatible). Use for local LLMs: Ollama (http://localhost:11434/v1), llama.cpp, vLLM, LM Studio, etc.
search_modeNoSearch mode: "semantic", "hybrid", or "keyword"hybrid
max_memoriesNoMaximum number of memories to include (1-100, default 20)
exclude_memory_idsNoMemory IDs to exclude (for multi-turn context building)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.0

TDQS

B3.4/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It usefully discloses the internal pipeline (search → composite-score ranking → optional AI summary) and that summarization requires an LLM endpoint, but omits scope (whose memories are searched), cost/latency implications, and whether the call has side effects.

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

Conciseness4/5

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

Four sentences, front-loaded with the core action and pipeline, then use case, then the custom-endpoint note. The final sentence partially duplicates the llm_api_url parameter description but is short enough not to be wasteful.

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

Completeness3/5

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

For an eight-parameter tool with no output schema, the description should say what the returned bundle looks like (items, scores, summary field). It explains inputs well enough but leaves the return shape and failure modes unaddressed.

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

Parameters3/5

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

Schema coverage is 100%, so the schema already documents all eight parameters including enum, defaults and bounds. The description adds only the notion of composite-score ranking and token truncation, which the schema largely implies, so the baseline 3 applies.

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?

Specific verb and resource: 'Build a ranked context bundle from memories' plus the pipeline (search, rank, optionally summarize). It distinguishes itself from simple retrieval siblings by the bundle/token-budget framing, though it never names an alternative explicitly.

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?

Gives an intended use case ('building token-efficient context windows for LLM prompts'), which implies when to reach for it, but offers no explicit when-not guidance or comparison to memory_search/memory_recall.

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