Skip to main content
Glama

IA-QA — 152 QA & Dev Tools for AI Agents

build_rag_prompt

Read-onlyIdempotent

Assemble a complete RAG (Retrieval-Augmented Generation) prompt from retrieved context chunks and a user query. Handles token budgeting, citation numbering, system instruction injection, and source attribution.

Input Schema

NameRequiredDescriptionDefault
queryYesThe user question to answer
chunksYesRetrieved context chunks with .text (required), .source (optional), .score (optional)
languageNoResponse language instruction (e.g. "French", "Spanish")
cite_sourcesNoAdd [1], [2] citation numbers (default: true)
max_context_tokensNoMax tokens for context section (default: 2000)
system_instructionNoCustom system instruction (default: standard RAG grounding instruction)

Output Schema

NameRequiredDescriptionDefault
promptNo
system_promptNo
chunks_includedNo
included_chunksNo
chunks_truncatedNo
total_tokens_estimateNo
context_tokens_estimateNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "chunks": [
      +      {
      +        "source": "a.md",
      +        "text": "c1 text"
      +      }
      +    ],
      +    "query": "q?"
      +  }
      +]
  2. Changed1 schema field changed
    • addedOutput schema / properties
      Added value: +{
      +  "chunks_included": {
      +    "type": "number"
      +  },
      +  "chunks_truncated": {
      +    "type": "number"
      +  },
      +  "context_tokens_estimate": {
      +    "type": "number"
      +  },
      +  "included_chunks": {},
      +  "prompt": {},
      +  "system_prompt": {},
      +  "total_tokens_estimate": {
      +    "type": "number"
      +  }
      +}
  3. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "type": "object"
      +}
  4. First observed

TDQS

A3.9/5.0
Behavior4/5

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

Annotations already declare readOnly/idempotent/non-destructive/closed-world, so safety is covered. The description then adds real behavioral value beyond that: it discloses that the tool actually performs token budgeting, injects a system instruction, numbers citations, and attributes sources — transformations the agent would otherwise not know happen inside the call.

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 sentences, zero waste: the first states what is built and from what, the second enumerates the four processing behaviors. Front-loaded and appropriately sized for the tool's complexity.

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?

Return values are covered by the output schema and safety by the annotations, so the description only needs to explain the transformation, which it does. Minor gaps: it does not say whether low-score chunks are dropped when the token budget is exceeded, or how chunks are ordered before numbering.

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 coverage is 100%, so the baseline is 3, but the description's feature list maps onto the optional parameters and adds meaning — 'token budgeting' tells you max_context_tokens actually truncates context, and 'citation numbering' tells you cite_sources changes the output text, not just metadata. It does not clarify how chunk.score is used (ordering/filtering), which is the one semantic gap.

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?

Names a specific verb (assemble) and resource (RAG prompt) plus the exact inputs (retrieved chunks + user query), which clearly separates it from prompt_template_fill or system_prompt_builder. It stops short of explicitly naming a sibling it supersedes, so an agent still has to infer its place among prompt/context tools.

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?

Usage is implied by the phrase 'from retrieved context chunks and a user query' — use it when you already have retrieval results. There is no explicit when-not, no mention of where it sits relative to split_chunks, rag_relevance_rank, or truncate_to_tokens, and no prerequisites stated.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.