Skip to content Skip to footer

How to Build Permission-Aware RAG That Connects Semantic Search to Business Data

What Happened

An AWS Quick and Elastic Agent Builder example lets analysts ask natural-language questions across Elasticsearch trade data and SEC filing excerpts. The workflow combines structured calculations, query-time company enrichment, and semantic search over filings through nine curated tools exposed by an MCP connector. It uses each analyst’s OAuth 2.1 permissions rather than requiring them to write ES|QL [1].

The demonstration dataset contains 1,004,837 trades, 24 companies, and 29 filing excerpts. In one example, an analyst investigates an intraday price decline alongside the timing of a Form 8-K. These are demonstration results, not evidence that every question will be answered correctly or within the same time [1].

Why It Matters to Businesses

This is a useful pattern for retrieval-augmented generation (RAG): retrieve evidence from documents, calculate facts from structured records, and keep the distinction visible to the user. A vector search result can identify a relevant filing passage; it should not replace a database calculation such as VWAP. Curated tools give an agent a narrower, more testable path to each source than unrestricted query generation.

The choice among Elasticsearch, Weaviate, Pinecone, Qdrant, Milvus, or Vespa—and orchestration frameworks such as LlamaIndex, LangChain, or Haystack—should follow requirements for filtering, access control, latency, operations, and existing data infrastructure. This example demonstrates the pattern with Elastic; it does not establish comparative performance across those products [1].

Kimbodo Engineering Perspective

For production RAG, we would treat retrieval quality and authorization as separate acceptance criteria. Relevant passages are not safe to return unless the requesting user may see them. Likewise, a fluent answer is not reliable unless its numerical claims can be traced to an executed calculation and its document claims to specific excerpts.

We would start with a small set of purpose-built tools for common investigations, then expand only after reviewing unanswered questions and tool-call logs. This trades some flexibility for clearer permissions, predictable costs, and easier testing.

How We Would Implement It

  • Index trades for structured queries, companies for enrichment, and filing excerpts for semantic retrieval; retain document IDs, timestamps, and access metadata [1].
  • Expose narrowly scoped search and calculation tools through MCP. Pass the user’s identity through the connector, enforce permissions at the data layer, and constrain query parameters and result sizes.
  • Route questions to the appropriate tool or tools. Return cited excerpts and calculation inputs with the answer; label interpretations separately from retrieved facts.
  • Evaluate with representative questions, including ambiguous company names, missing filings, conflicting timestamps, and users with different access rights. Check answers against known calculations before rollout.

Risks, Costs and Security

Key risks include unauthorized retrieval, prompt injection in filing text, misleading matches, incorrect tool selection, and plausible but wrong calculations. Use least-privilege OAuth access, audit tool calls, protect and rotate credentials, and remove temporary connectors, tools, indices, and setup keys after testing [1].

Cost depends on indexing, semantic retrieval, query volume, model calls, and operational monitoring. Measure those separately: caching a calculation may help, but caching a permission-sensitive answer across users may expose data. Set latency and accuracy targets before choosing additional vector infrastructure or agent-framework complexity.

Where Kimbodo Comes In

Kimbodo builds and operates this in production for businesses — see our RAG Development Services practice, or Estimate My RAG System.

Sources

  1. [1] Query a million trades in natural language with AWS Quick and Elastic Agent Builder MCP server

Leave a comment

0.0/5

Engineering Founded & Customer Focused

KIMBODO LLC. © 2026. All Rights Reserved.