MCP ConfigsApr 7, 2026·2 min read

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.

SK
Skill Factory · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

pip install haystack-ai mcp-server-haystack
from haystack_mcp import HaystackMCPServer
from haystack import Pipeline
from haystack.components.retrievers import InMemoryBM25Retriever

# Build a Haystack pipeline
pipeline = Pipeline()
pipeline.add_component("retriever", InMemoryBM25Retriever(document_store=store))

# Expose as MCP server
server = HaystackMCPServer(pipelines={"search": pipeline})
server.run()

What is Haystack MCP?

Haystack MCP bridges deepset's Haystack AI framework with the Model Context Protocol. It exposes your Haystack RAG pipelines, document search, and QA systems as MCP servers — letting Claude Code, Cline, and other MCP clients query your custom AI pipelines through natural language.

Answer-Ready: Haystack MCP exposes Haystack RAG pipelines as MCP servers, enabling Claude Code and other AI tools to query document search, QA, and retrieval systems through the MCP protocol. Built by deepset.

Best for: Teams with existing Haystack pipelines who want AI tool integration. Works with: Claude Code, Cline, any MCP client + Haystack 2.x. Setup time: Under 10 minutes.

Core Features

1. Pipeline as MCP Tool

Each Haystack pipeline becomes an MCP tool:

server = HaystackMCPServer(
    pipelines={
        "doc_search": search_pipeline,
        "qa": qa_pipeline,
        "summarize": summary_pipeline,
    }
)
# Creates 3 MCP tools: doc_search, qa, summarize

2. Document Store Integration

from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack.components.writers import DocumentWriter

# Index documents
store = InMemoryDocumentStore()
writer = DocumentWriter(document_store=store)
writer.run(documents=[
    Document(content="Company policy on remote work..."),
    Document(content="Engineering standards document..."),
])

# Expose search
pipeline = Pipeline()
pipeline.add_component("retriever", InMemoryBM25Retriever(document_store=store))

3. RAG Pipeline

from haystack.components.generators import OpenAIGenerator
from haystack.components.builders import PromptBuilder

rag_pipeline = Pipeline()
rag_pipeline.add_component("retriever", retriever)
rag_pipeline.add_component("prompt", PromptBuilder(
    template="Answer based on context: {{documents}} Question: {{query}}"
))
rag_pipeline.add_component("llm", OpenAIGenerator())
rag_pipeline.connect("retriever", "prompt")
rag_pipeline.connect("prompt", "llm")

4. Claude Code Integration

// .mcp.json
{
  "mcpServers": {
    "haystack": {
      "command": "python",
      "args": ["-m", "my_haystack_server"]
    }
  }
}
You: "Search our docs for the remote work policy"
Claude Code (via Haystack MCP):
  → Calls doc_search tool
  → Haystack retrieves relevant documents
  → Returns formatted results

5. Custom Tool Parameters

server = HaystackMCPServer(
    pipelines={"search": pipeline},
    tool_descriptions={
        "search": "Search the company knowledge base for policies and procedures"
    },
    input_mappings={
        "search": {"query": "retriever.query"}
    },
)

Supported Document Stores

Store Type
InMemory Development
Elasticsearch Production
OpenSearch Production
Weaviate Vector search
Pinecone Managed vector
Qdrant Vector search
Chroma Lightweight vector

FAQ

Q: Do I need Haystack experience? A: Basic Haystack knowledge helps. The MCP wrapper is simple once you have a pipeline.

Q: Can I use it with Claude models? A: Yes, Haystack supports Anthropic models for the generator component, and the MCP server works with Claude Code as a client.

Q: Is it production ready? A: Haystack 2.x is production-grade. The MCP bridge is newer but stable for most use cases.

🙏

Source & Thanks

Created by deepset. Licensed under Apache 2.0.

deepset-ai/haystack — 18k+ stars haystack-mcp

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets