2026年4月7日·1 分钟阅读

Haystack MCP — Connect AI Pipelines to MCP Clients

Expose Haystack RAG pipelines as MCP servers. Let Claude Code and other AI tools query your document search, QA, and retrieval pipelines through the MCP protocol.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 17/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Mcp Config
安装
Stage only
信任
信任等级:Community
入口
Haystack MCP — Connect AI Pipelines to MCP Clients
安全暂存命令
npx -y tokrepo@latest install a7d6f60b-2a29-4699-85ce-2b21a1ad9437 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

TL;DR
Expose Haystack RAG pipelines as MCP servers for Claude Code and other AI tools to query directly.
§01

What it is

Haystack MCP bridges the Haystack AI framework with the Model Context Protocol (MCP). It lets you expose any Haystack pipeline, whether for document search, question answering, or retrieval-augmented generation, as an MCP server. AI tools like Claude Code, Cursor, and other MCP-compatible clients can then query your pipelines directly without custom integration code.

Developers who have built Haystack RAG pipelines and want to make them accessible to AI coding agents benefit from this integration. It turns your document search infrastructure into a tool that any MCP client can call.

§02

How it saves time or tokens

Without Haystack MCP, connecting a Haystack pipeline to an AI agent requires building custom API endpoints and tool definitions. Haystack MCP handles the protocol translation automatically, saving the development time of building and maintaining a custom integration layer. The token_estimate for this workflow is approximately 3,800 tokens.

§03

How to use

  1. Install haystack-ai and the MCP server package
  2. Build a Haystack pipeline (retrieval, QA, or RAG)
  3. Wrap it with HaystackMCPServer and run
§04

Example

from haystack_mcp import HaystackMCPServer
from haystack import Pipeline
from haystack.components.retrievers import InMemoryBM25Retriever
from haystack.document_stores.in_memory import InMemoryDocumentStore

# Build a retrieval pipeline
store = InMemoryDocumentStore()
# ... add documents to store ...
pipeline = Pipeline()
pipeline.add_component('retriever', InMemoryBM25Retriever(store))

# Expose as MCP server
server = HaystackMCPServer(pipeline)
server.run()  # Now accessible via MCP protocol
§05

Related on TokRepo

§06

Common pitfalls

  • The MCP server must be running for AI tools to access the pipeline; configure it as a persistent service
  • Large document stores increase retrieval latency; optimize your Haystack pipeline before exposing it via MCP
  • MCP protocol compatibility varies between clients; test with your specific AI tool before relying on it

常见问题

Which AI tools can connect to Haystack MCP?+

Any MCP-compatible client can connect, including Claude Code, Cursor, Cline, and custom agents. The MCP protocol is standardized, so any tool implementing the client specification can query your Haystack pipeline.

Do I need to modify my existing Haystack pipeline?+

No. Haystack MCP wraps your existing pipeline without modification. You pass your built pipeline to the MCP server, and it handles protocol translation. No changes to pipeline components or configuration are needed.

What types of Haystack pipelines can I expose?+

Any Haystack pipeline works: document retrieval, question answering, RAG, summarization, or custom pipelines. The MCP server exposes the pipeline's run method as an MCP tool that clients can call.

Can I expose multiple pipelines from one server?+

Yes. You can register multiple Haystack pipelines as separate tools on a single MCP server. Each pipeline appears as a distinct tool that clients can discover and call independently.

Is Haystack MCP production-ready?+

Haystack MCP is suitable for development and internal tooling. For production use with high traffic, consider running it behind a process manager and monitoring connection stability between the MCP server and clients.

引用来源 (3)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产