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.
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.
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.
How to use
- Install haystack-ai and the MCP server package
- Build a Haystack pipeline (retrieval, QA, or RAG)
- Wrap it with HaystackMCPServer and run
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
Related on TokRepo
- RAG tools — Browse retrieval-augmented generation frameworks
- MCP integrations — Explore MCP server configurations
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
Frequently Asked Questions
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.
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.
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.
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.
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.
Citations (3)
- Haystack MCP GitHub— Expose Haystack pipelines as MCP servers
- Haystack Documentation— Haystack AI framework for building RAG pipelines
- MCP Specification— Model Context Protocol specification
Related on TokRepo
Source & Thanks
Created by deepset. Licensed under Apache 2.0.
deepset-ai/haystack — 18k+ stars haystack-mcp
Discussion
Related Assets
Claude-Flow — Multi-Agent Orchestration for Claude Code
Layers swarm and hive-mind multi-agent orchestration on top of Claude Code with 64 specialized agents, SQLite memory, and parallel execution.
ccusage — Real-Time Token Cost Tracker for Claude Code
CLI that reads ~/.claude logs and breaks down Claude Code token spend by day, session, and project — pluggable into your statusline.
SuperClaude — Workflow Framework for Claude Code
Adds 16+ slash commands, 9 cognitive personas, and a smart flag system to Claude Code in one pipx install.