Skip to content

Haystack live retrieval and a local MCP surface - #1

Open
coder058 wants to merge 3 commits into
mainfrom
cursor/haystack-live-retrieval-3e7e
Open

coder058 wants to merge 3 commits into
mainfrom
cursor/haystack-live-retrieval-3e7e

Conversation

@coder058

@coder058 coder058 commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

Live ask/retrieval ranks passages with a small Haystack 2.x Pipeline. This PR also adds a local MCP surface so the same desk can be attached in Cursor. The recorded Pages case is unchanged.

Haystack

  • LiveStore.retrieve() still reads latest captured versions from SQLite, then builds Haystack Documents and runs InMemoryBM25Retriever (haystack-ai==2.31.0).
  • Returned passage dicts keep the existing shape so citation validation, claims, approve(), and allowlisted connectors are untouched.
  • Tests assert the Haystack step is actually invoked: stubbing or removing it fails even though FTS5 rows still exist.

MCP (local/stdio + existing FastAPI)

  • Tools: search_sources (Haystack live retrieval, no new corpus), get_claim (one recorded claim cell + exact sentence), propose_write (pending draft only).
  • propose_write cannot approve itself. A separate human store.approve() / POST /api/drafts/{id}/decide writes the note.
  • HTTP: GET /api/mcp/tools lists schemas (curl -s http://127.0.0.1:8000/api/mcp/tools). POST /api/mcp/tools/{name} invokes one tool.
  • stdio: python -m infodesk.mcp_server (mcp==2.2.0). README has a Cursor mcp.json snippet and a checklist (auth, schema, approve, 429, harness).

What did not change

  • GitHub Pages recorded case, harness-generated public JSON, and recorded-vs-live separation.
  • Haystack/MCP do not fetch arbitrary URLs, write notes, or approve drafts.
  • No embeddings, semantic search, Notion/CRM, or apply-packet tools.
  • AutoMergingRetriever is unused: captures are flat paragraph windows.
Open in Web Open in Cursor 

Swap only the live retrieve() step from SQLite FTS5 MATCH to a Haystack 2.x
InMemoryBM25Retriever Pipeline over latest captured versions. Citation
validation, claims, approval, and the recorded Pages case stay unchanged.

Co-authored-by: Jordi Lluis <coder058@users.noreply.github.com>
@coder058
coder058 marked this pull request as ready for review September 13, 2026 19:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58b7fe2fbf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

+ where + " ORDER BY rank, c.id LIMIT 6", params).fetchall()]
WHERE d.source_id IN (""" + ",".join("?" for _ in source_ids) + ")"
+ where + " ORDER BY c.id", params).fetchall()]
return retrieve_passages(question, rows)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pass the filtered terms to the BM25 query

When an unanswerable question contains common words, such as What is the snowfall depth?, this forwards the raw question even though the preceding code computes stopword-filtered tokens. Haystack can therefore return passages matching only words such as what or the, causing LiveService to call the model with irrelevant evidence instead of taking its no-evidence path. Pass the normalized tokens to the retriever, or apply equivalent filtering inside the Haystack pipeline.

Useful? React with 👍 / 👎.

Expose search_sources, get_claim, and propose_write over stdio and the
existing FastAPI app. Retrieval still uses Haystack; propose_write cannot
approve itself or persist a note.

Co-authored-by: Jordi Lluis <coder058@users.noreply.github.com>
@cursor cursor Bot changed the title Use Haystack BM25 for live ask retrieval Haystack live retrieval and a local MCP surface Sep 13, 2026
Keep the live allowlist only; recorded claim IDs still come from CLAIMS.

Co-authored-by: Jordi Lluis <coder058@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants