# 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) ## Quick Start ```bash pip install haystack-ai mcp-server-haystack ``` Expose your Haystack RAG pipeline as an MCP server. ## What is Haystack MCP? Expose deepset Haystack's RAG pipelines, document search, and QA systems as MCP servers so Claude Code and other tools can query them. **In one sentence**: Expose Haystack RAG pipelines as MCP servers so Claude Code and other AI tools can query document retrieval and QA systems via the MCP protocol. **For**: Teams with existing Haystack pipelines who need AI tool integration. ## Core Features ### 1. Pipelines as Tools Each Haystack pipeline becomes an MCP tool. ### 2. Document Store Integration Supports Elasticsearch, Weaviate, Pinecone, and more. ### 3. Claude Code Integration Configure in `.mcp.json` and query pipelines in natural language. ## FAQ **Q: Do I need Haystack experience?** A: Basic knowledge helps; the MCP wrapper is simple. **Q: Production ready?** A: Haystack 2.x is production-grade, and the MCP bridge is stable. ## Source & Thanks > [deepset-ai/haystack](https://github.com/deepset-ai/haystack) — 18k+ stars, Apache 2.0 --- Source: https://tokrepo.com/en/workflows/haystack-mcp-connect-ai-pipelines-mcp-clients-a7d6f60b Author: Skill Factory