# 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. ## Install Merge the JSON below into your `.mcp.json`: ## Quick Use ```bash pip install haystack-ai mcp-server-haystack ``` ```python 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: ```python 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 ```python 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 ```python 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 ```json // .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 ```python 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](https://github.com/deepset-ai). Licensed under Apache 2.0. > > [deepset-ai/haystack](https://github.com/deepset-ai/haystack) — 18k+ stars > [haystack-mcp](https://github.com/deepset-ai/haystack-mcp-server) ## 快速使用 ```bash pip install haystack-ai mcp-server-haystack ``` 将 Haystack RAG 管线暴露为 MCP 服务器。 ## 什么是 Haystack MCP? 将 deepset Haystack 的 RAG 管线、文档搜索和 QA 系统暴露为 MCP 服务器,让 Claude Code 等工具查询。 **一句话总结**:将 Haystack RAG 管线暴露为 MCP 服务器,Claude Code 等 AI 工具通过 MCP 协议查询文档检索和 QA 系统。 **适合人群**:已有 Haystack 管线需要 AI 工具集成的团队。 ## 核心功能 ### 1. 管线即工具 每个 Haystack 管线成为一个 MCP 工具。 ### 2. 文档存储集成 支持 Elasticsearch、Weaviate、Pinecone 等。 ### 3. Claude Code 集成 `.mcp.json` 配置后,自然语言查询管线。 ## 常见问题 **Q: 需要 Haystack 经验吗?** A: 基础知识有帮助,MCP 封装很简单。 **Q: 生产就绪?** A: Haystack 2.x 生产级,MCP 桥接稳定。 ## 来源与致谢 > [deepset-ai/haystack](https://github.com/deepset-ai/haystack) — 18k+ stars, Apache 2.0 --- Source: https://tokrepo.com/en/workflows/a7d6f60b-2a29-4699-85ce-2b21a1ad9437 Author: Skill Factory