What Happened
A recent engineering project built a publicly hosted Model Context Protocol (MCP) server for Vespa Cloud and evaluated an agent that used the MCP server vs an agent given a Vespa CLI/terminal. The MCP-based agent passed 97% of deterministic assertions vs 95% for the CLI agent, required fewer deployment attempts, resolved issues faster, and scored higher on an LLM rubric — at the cost of extra token/context overhead to discover and hold tool descriptions. The project produced operational lessons: tools should accept concise inputs and constrained actions, return informative errors, provide compact/raw detail options, collapse repeated events, cap responses to protect model context, expose observability metrics, and use robust file-upload flows (presigned upload URLs rather than embedding files inline). Auth for the control plane reused Auth0 with the MCP server acting as an OAuth proxy; per-application data-plane tokens remained an unresolved item. The MCP spec was simplified to support stateless scaling by removing protocol-level sessions [1].
Why It Matters to Businesses
Retrieval-augmented generation (RAG) systems combine embeddings, vector search and LLMs to deliver context-aware outputs. Businesses investing in RAG care about three operational outcomes:
- Reliability: predictable retrieval accuracy and stable deployment flows reduce failed runs and wasted tokens.
- Observability and MTTR: measurable signals (deploy metrics, event streams, request traces) let operators determine when to scale, rollback or re-index.
- Cost and Security Control: embedding and search costs, token use in agents, and data-plane access all have direct monetary and compliance impact.
The Vespa MCP evaluation shows that purpose-built tool interfaces for LLMs (vs giving them CLI access) materially improve deterministic correctness and developer throughput, with measurable trade-offs in token/context overhead and implementation complexity [1].
Kimbodo Engineering Perspective
When building production RAG systems we balance three trade-offs: precision vs recall, operational simplicity vs flexibility, and latency vs cost. Our experience and the Vespa MCP lessons suggest these practical judgments:
- Prefer constrained tool interfaces over raw shells for agent-driven automation. Tools reduce action-space errors, make validation simpler, and produce deterministic error messages that LLMs can interpret reliably — but expect increased context tokens to describe tool semantics and limits [1].
- Push heavy binary or multi-file uploads off the LLM channel. Presigned upload URLs or multipart upload endpoints are more robust than embedding content in tool calls; they cost more HTTP round-trips but reduce brittle failures during deployments [1].
- Expose observability signals from search and control planes. Allow agents and orchestration layers to query metrics (errors, latency, node restarts, indexing lags) so automated decisions (scale up, pause, retry) are data-driven [1].
- Use hybrid retrieval when possible. Combine dense vector search (Weaviate, Pinecone, Qdrant, Milvus) for semantic recall with sparse/lexical search (Elasticsearch, Vespa) or reranking to improve precision on factual queries.
- Embed metadata and filtering in the vector index. Include provenance, timestamps and tenant IDs to allow precise boolean/temporal filtering at retrieval time and reduce downstream hallucinations.
- Plan for token/context caps. Cap returned context length, provide compact/raw detail parameters in APIs, and collapse repeated events to keep model context usable and affordable [1].
How We Would Implement It
Below is a pragmatic, production-grade architecture and implementation roadmap Kimbodo would apply when building RAG systems that must be reliable, observable and secure.
Reference architecture
- LLM orchestration layer: LangChain or LlamaIndex for prompt templating, retrieval interfaces, and agent orchestration. Use the orchestrator to manage tool descriptions and call patterns.
- Vector store: choose by operational constraints:
- Hosted (Pinecone, Weaviate cloud) for fast time-to-market and managed scaling.
- Self-hosted (Qdrant, Milvus, Vespa, or Elasticsearch/Vespa for hybrid needs) when you need control over security, bespoke ranking, or custom storage.
- Search fallback / hybrid ranking: Elasticsearch or Vespa for exact-match and BM25; use them to pre-filter candidates or to rerank vector results.
- Document store and provenance: object store (S3-compatible) for payloads and per-document metadata in a transactional DB. Store chunked text + metadata with unique IDs referenced from vector index.
- MCP-like tool server for control-plane operations: a stateless HTTP API that exposes constrained operations (deploy, inspect, observe, upload) with compact/raw detail toggles and a presigned-upload flow for files [1].
- Observability: instrument metrics and traces; export Grafana dashboards and endpoints so orchestration agents can make decisions based on deploy and cluster health metrics [1].
- Auth and multi-tenant isolation: Control plane via OAuth/OIDC (Auth0 or corporate identity), tokenized data plane per-application with short-lived tokens and scoped rights; treat public endpoints as untrusted until authenticated [1].
Implementation steps
- Design retrieval schema: decide chunk size (typically 512–1,024 tokens), overlap, and metadata fields (source, timestamp, tenant, doc type).
- Create embedding pipeline: support incremental re-embedding for changed docs, batch embeddings with rate limiting, and a cache for repeated vectors.
- Indexing strategy: use HNSW/ANN for low-latency approximate search; maintain a periodic full rebuild process for drifted indexes and a nearline incremental indexer for frequent writes.
- Build an adapter layer: implement a small interface that can switch between vector backends (Weaviate, Pinecone, Qdrant, Milvus) and search engines (Elasticsearch, Vespa) without changing higher-level orchestration.
- Tooling for agents: publish concise tool descriptors, limit allowed operations, include parameter schemas and failure modes. Provide both compact and raw result forms; collapse repeated events in observability queries [1].
- File uploads: return presigned or unique upload URLs; have the LLM/agent upload zips or archives directly to the storage endpoint and then call the control API to start processing [1].
- Deploy behavior: use a blocking deploy API with configurable timeout and a long-running-task pattern so agents can poll status without holding model context indefinitely [1].
- Monitoring and alerts: expose deploy and index metrics; alert on index lag, high error rates, or sudden increases in approximate search misses. Allow agents to query metrics to decide operational steps [1].
Risks, Costs and Security
Designing RAG systems involves technical and business risks. Address them explicitly:
- Token and context costs: Tool descriptions and large returned contexts increase LLM tokens. Mitigate by compact/raw result toggles, collapsing repeated events, and pre-filtering candidates to reduce context size [1].
- Operational complexity: Hybrid stacks (vector + lexical + orchestration + object store) increase failure modes. Mitigate with robust observability, a clear adapter layer, and chaos-testing for index failures.
- Security and data exfiltration: Public endpoints are hostile by default — require OAuth/OIDC, short-lived scoped data-plane tokens, per-tenant isolation, and encrypted-at-rest storage. The Vespa MCP project left per-application data-plane tokens as an outstanding item; treat that as mandatory for multi-tenant systems [1].
- Cost of embeddings and storage: Embeddings and index storage scale with documents. Use incremental embeddings, deduplication, vector quantization where acceptable, and a lifecycle policy for old vectors.
- Model hallucination and provenance: Without precise source filtering and provenance metadata, LLMs will hallucinate. Always return source snippets with citations and let the downstream business logic apply trust rules.
- Scaling and state: Stateless control-plane APIs scale better; avoid protocol-level sessions for high-scale MCP-style servers as done in the Vespa MCP spec (stateless scaling was enabled by removing sessions) [1].
- Regulatory/compliance: Ensure data residency and deletion workflows for embedding and index data; plan for GDPR/CCPA right-to-erasure by tying vectors to deletable document IDs.
In short: use constrained, observable tools and a clear adapter layer between orchestration (LangChain / LlamaIndex) and vector/search backends (Weaviate, Pinecone, Qdrant, Milvus, Elasticsearch, Vespa). Favor presigned uploads, compact result modes, and exposed metrics to keep RAG reliable and maintainable — lessons demonstrated concretely by the Vespa MCP project and its evaluation [1].
Where Kimbodo Comes In
Kimbodo builds and operates this in production for businesses — see our RAG Development Services practice, or Estimate My RAG System.