retrieval-lens
retrieval-lens
A black-box flight recorder for RAG retrieval inside MCP agents.
retrieval-lens is an MCP server that logs every retrieval step your RAG agent makes — what chunks were retrieved, their scores, sources, and rankings — so you can audit, replay, and diff retrieval runs after the fact.
The Problem
When a RAG agent gives a wrong answer, you need to know: did retrieval fail, or did generation fail? Right now there's no easy way to answer that. Your observability tool shows you the LLM call. It doesn't show you which chunks the model saw before it answered, what scores they had, or how retrieval changed between yesterday and today.
retrieval-lens fixes that. Every retrieval run is logged. Nothing is hidden.
Related MCP server: Graphlit MCP Server
Demo
When your RAG agent gives a wrong answer, ask retrieval-lens what it saw:
await mcp.call("retrieval_diff", {
run_id_a: "support-bot-before-embedding-refresh",
run_id_b: "support-bot-after-embedding-refresh",
match_by: "source"
});See docs/demo-diff.png for real output from Claude Code.
MCP Tools
Tool | What it does |
| Log a retrieval run — query, chunks, scores, sources, rankings |
| Replay what the model saw before a specific answer |
| Compare two retrieval runs — what changed, what score drifted |
| Aggregate score distributions, top sources, runs over time |
Quickstart
Run retrieval-lens directly with npx:
npx retrieval-lensAdd retrieval-lens to Claude Code with one command:
claude mcp add retrieval-lens npx retrieval-lensThen call retrieval_observe after every retrieval step in your RAG pipeline:
await mcp.call("retrieval_observe", {
run_id: crypto.randomUUID(),
query: "what is the refund policy?",
chunks: [
{ content: "Refunds are processed within 5 days...", score: 0.91, source: "policy.md", rank: 1 },
{ content: "Contact support for refund requests...", score: 0.74, source: "faq.md", rank: 2 }
],
pipeline_tag: "support-bot"
});Adapters
LangChain
See examples/langchain-adapter.ts
LlamaIndex
See examples/llamaindex-adapter.ts
Why not LangSmith / Langfuse?
Those are full observability platforms. retrieval-lens is surgical:
Local-first — SQLite, zero signup, no data leaves your machine
MCP-native — one config line, works in any MCP client
Retrieval-only — focused on the layer where most RAG failures actually happen
Status
🚧 Active development. Harness-first build using harness engineering principles.
F05 — scaffold
F01 — retrieval_observe
F02 — retrieval_query
F03 — retrieval_diff
F04 — retrieval_stats
License
MIT
Available Tools
4 toolsretrieval_diffRetrieval DiffC
Compare two retrieval runs side by side to find missing chunks, shared chunks, and score movement between runs.
| Name | Required | Description | Default |
|---|---|---|---|
| run_id_a | Yes | ||
| run_id_b | Yes | ||
| match_by | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| only_in_a | Yes | |
| only_in_b | Yes | |
| shared | Yes | |
| summary | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses the types of differences found (missing/shared chunks, score movement), but omits details on mutability, permissions, or side effects. The presence of an output schema partially offsets the need for return value transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence that conveys the main purpose efficiently. However, it could benefit from structured bullet points for additional context.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description is incomplete: it lacks parameter semantics, usage guidance, and behavioral context. The output schema exists, but the description does not hint at the output structure or how the results relate to the inputs.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description fails to explain any of the three parameters. It does not clarify what run_id_a/b represent or the meaning of the match_by enum, leaving the agent to infer from names.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states that the tool compares two retrieval runs to find missing chunks, shared chunks, and score movement. It effectively communicates the core function, but does not explicitly distinguish it from sibling tools like retrieval_observe or retrieval_stats.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
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, nor are there any exclusions or prerequisites mentioned. The description simply states the action without contextual usage advice.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
retrieval_observeRetrieval ObserveB
Capture a RAG retrieval run, including query, chunks, scores, sources, and ranks, for later audit and diff workflows.
| Name | Required | Description | Default |
|---|---|---|---|
| run_id | Yes | ||
| query | Yes | ||
| chunks | Yes | ||
| pipeline_tag | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| stored | Yes | |
| run_id | Yes | |
| chunk_count | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It indicates a capture (write) operation but does not mention side effects, idempotency, permission requirements, or what happens if a run_id already exists. This is insufficient for safe invocation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, well-formed sentence that immediately states the core action and data captured. No extraneous information; every word is purposeful.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the presence of an output schema and 4 parameters (3 required), the description is adequate for a simple capture tool but lacks details on error handling, data retention, or performance implications. It covers the 'what' but not the 'how' or 'edge cases'.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description only names the parameter fields (query, chunks, scores, sources, ranks) without adding detail beyond property names. It does not explain expected formats, constraints, or the nested structure of 'chunks', which has explicit sub-fields in the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool captures a RAG retrieval run with specific data (query, chunks, scores, sources, ranks) for audit and diff workflows. It directly ties to the sibling tool 'retrieval_diff', distinguishing its role as a recording tool rather than comparison or query execution.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'for later audit and diff workflows' implies usage context but does not explicitly contrast with siblings like 'retrieval_query' or 'retrieval_stats'. There is no guidance on when not to use this tool or when to prefer alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
retrieval_queryRetrieval QueryB
Replay stored retrieval runs so agents can inspect exactly which chunks, scores, sources, and ranks reached the model.
| Name | Required | Description | Default |
|---|---|---|---|
| run_id | No | ||
| pipeline_tag | No | ||
| limit | No | ||
| since_iso | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| runs | Yes |
TDQS
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 suggests a read-only inspection operation but does not disclose whether replaying re-executes queries, requires authentication, or has rate limits. Ambiguity around 'replay' and lack of side-effect information make it insufficient.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single concise sentence that front-loads the purpose. However, it omits parameter details that are critical given the schema's lack of descriptions, slightly reducing its effectiveness.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite having an output schema, the description fails to explain the 4 undocumented parameters, usage in context of sibling tools, or behavioral traits. For a tool with no annotations, this is incomplete and leaves significant gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 4 parameters with 0% description coverage, and the tool description adds no information about what each parameter does (run_id, pipeline_tag, limit, since_iso). Without any parameter guidance, the agent cannot correctly invoke the tool.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool replays stored retrieval runs for inspection of chunks, scores, sources, and ranks. It uses specific verbs (replay, inspect) and distinguishes from siblings by focusing on historical analysis rather than diff, observe, or stats.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for inspecting past retrieval results, but it does not explicitly state when to use vs. alternatives (retrieval_diff, retrieval_observe, retrieval_stats) or when not to use. The context is clear but lacks exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
retrieval_statsRetrieval StatsB
Aggregate retrieval quality and volume metrics across stored runs, including score distributions, top sources, and daily trends.
| Name | Required | Description | Default |
|---|---|---|---|
| pipeline_tag | No | ||
| since_iso | No | ||
| until_iso | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| total_runs | Yes | |
| avg_top1_score | Yes | |
| p50_score | Yes | |
| p90_score | Yes | |
| top_sources | Yes | |
| runs_per_day | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description fully carries the burden, but it only discloses aggregation behavior. It does not state whether the tool is read-only, potential performance impacts, data freshness, or required permissions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single 13-word sentence that is front-loaded with key information. Every word earns its place with no fluff.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite having an output schema, the description lacks parameter explanations and behavioral details. An agent would struggle to know what pipeline_tag values are valid or what date formats to use, making it insufficient for correct invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description does not explain any of the three parameters (pipeline_tag, since_iso, until_iso). The description adds no parameter-level meaning beyond vague time range implication.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool aggregates retrieval metrics, listing specific outputs like score distributions and daily trends. It distinguishes itself from siblings like retrieval_diff (comparison) and retrieval_query (search).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies use for aggregated stats, but does not explicitly state when to use this tool over alternatives like retrieval_diff or retrieval_observe. No when-not or exclusion guidance is provided.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v0.1.0- First observed
retrieval_diff - First observed
retrieval_observe - First observed
retrieval_query - First observed
retrieval_stats
TDQS
Scored across 4 tools
Each tool addresses a distinct retrieval analysis task: capturing runs (observe), replaying them (query), comparing two runs (diff), and aggregating statistics (stats). No overlaps.
All tools follow a consistent 'retrieval_verb' pattern, making the set predictable and easy to navigate.
Four tools is a concise but complete set for retrieval audit and analysis, covering the essential workflows without unnecessary bloat.
The tools cover the full lifecycle of retrieval evaluation: capture, inspect, compare, and aggregate. No obvious gaps for the stated purpose.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
- memnodeOAuthdev.memnode
Persistent, inspectable memory for AI agents with lineage, correction, and a hosted MCP endpoint.
Agent Replay Debugger MCP — record every agent step + deterministic replay. Step-debugger for
Portable memory for AI agents: capture once, recall across Claude, Cursor, and any MCP client.
Persistent memory for AI agents — log and recall conversation context over MCP.
Related MCP Servers
AlicenseBqualityCmaintenanceThis repository is an example of how to create a MCP server for Qdrant, a vector search engine.21,522Apache 2.0
Graphlit MCP Serverofficial
AlicenseNot gradedqualityFmaintenanceThe Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.115379MIT
Chroma MCP Serverofficial
AlicenseAqualityDmaintenanceA server that provides data retrieval capabilities powered by Chroma embedding database, enabling AI models to create collections over generated data and user inputs, and retrieve that data using vector search, full text search, and metadata filtering.13590Apache 2.0- AlicenseNot gradedqualityAmaintenancePersistent, auditable memory for AI agents. Hybrid BM25 + vector recall with 18 MCP tools, adaptive block metadata (A-MEM), intent-aware routing, contradiction detection, and governance workflows. Zero external dependencies. Drop-in memory for Claude Code and any MCP-compatible agent.17Apache 2.0