Skip to main content
Glama
Vbj1808

retrieval-lens

by Vbj1808

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

retrieval_observe

Log a retrieval run — query, chunks, scores, sources, rankings

retrieval_query

Replay what the model saw before a specific answer

retrieval_diff

Compare two retrieval runs — what changed, what score drifted

retrieval_stats

Aggregate score distributions, top sources, runs over time


Quickstart

Run retrieval-lens directly with npx:

npx retrieval-lens

Add retrieval-lens to Claude Code with one command:

claude mcp add retrieval-lens npx retrieval-lens

Then 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 tools
retrieval_diffRetrieval DiffC

Compare two retrieval runs side by side to find missing chunks, shared chunks, and score movement between runs.

ParametersJSON Schema
NameRequiredDescriptionDefault
run_id_aYes
run_id_bYes
match_byYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
only_in_aYes
only_in_bYes
sharedYes
summaryYes

TDQS

C2.9/5.0
Behavior3/5

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.

Conciseness4/5

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.

Completeness2/5

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.

Parameters2/5

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.

Purpose4/5

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.

Usage Guidelines2/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
run_idYes
queryYes
chunksYes
pipeline_tagNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
storedYes
run_idYes
chunk_countYes

TDQS

B3.4/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness3/5

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.

Parameters2/5

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.

Purpose5/5

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.

Usage Guidelines3/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
run_idNo
pipeline_tagNo
limitNo
since_isoNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
runsYes

TDQS

B3/5.0
Behavior2/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 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.

Conciseness4/5

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.

Completeness2/5

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.

Parameters1/5

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.

Purpose5/5

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.

Usage Guidelines3/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
pipeline_tagNo
since_isoNo
until_isoNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
total_runsYes
avg_top1_scoreYes
p50_scoreYes
p90_scoreYes
top_sourcesYes
runs_per_dayYes

TDQS

B3.1/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness2/5

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.

Parameters1/5

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.

Purpose5/5

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.

Usage Guidelines3/5

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.

  1. 4 tool updatesv0.1.0
    • First observedretrieval_diff
    • First observedretrieval_observe
    • First observedretrieval_query
    • First observedretrieval_stats

TDQS

A3.6/5.0

Scored across 4 tools

Disambiguation5/5

Each tool addresses a distinct retrieval analysis task: capturing runs (observe), replaying them (query), comparing two runs (diff), and aggregating statistics (stats). No overlaps.

Naming Consistency5/5

All tools follow a consistent 'retrieval_verb' pattern, making the set predictable and easy to navigate.

Tool Count5/5

Four tools is a concise but complete set for retrieval audit and analysis, covering the essential workflows without unnecessary bloat.

Completeness5/5

The tools cover the full lifecycle of retrieval evaluation: capture, inspect, compare, and aggregate. No obvious gaps for the stated purpose.

Maintenance

ActivityInactive
ResponsivenessNo issues

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

Related MCP Servers

  • A
    license
    Not graded
    quality
    F
    maintenance
    The 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.
    115
    379
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    A 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.
    13
    590
    Apache 2.0
  • A
    license
    Not graded
    quality
    A
    maintenance
    Persistent, 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.
    17
    Apache 2.0