11import argparse
2+ import logging
23import os
34from pathlib import Path
45
1112 get_latest_custom_component_installation_logs as get_latest_custom_component_installation_logs_tool ,
1213 list_custom_component_installations as list_custom_component_installations_tool ,
1314)
15+ from deepset_mcp .tools .doc_search import (
16+ get_docs_config ,
17+ search_docs as search_docs_tool ,
18+ )
1419from deepset_mcp .tools .haystack_service import (
1520 get_component_definition as get_component_definition_tool ,
1621 get_custom_components as get_custom_components_tool ,
@@ -434,6 +439,41 @@ async def search_pipeline(pipeline_name: str, query: str) -> str:
434439 return response
435440
436441
442+ # Check if docs search should be enabled
443+ docs_config = get_docs_config ()
444+ if docs_config :
445+ docs_workspace , docs_pipeline_name , docs_api_key = docs_config
446+
447+ async def search_docs (query : str ) -> str :
448+ """Search the deepset platform documentation.
449+
450+ This tool allows you to search through deepset's official documentation to find
451+ information about features, API usage, best practices, and troubleshooting guides.
452+ Use this when you need to look up specific deepset functionality or help users
453+ understand how to use deepset features.
454+
455+ :param query: The search query to execute against the documentation.
456+ :returns: The formatted search results from the documentation.
457+ """
458+ async with AsyncDeepsetClient (api_key = docs_api_key ) as client :
459+ response = await search_docs_tool (
460+ client = client ,
461+ workspace = docs_workspace ,
462+ pipeline_name = docs_pipeline_name ,
463+ query = query ,
464+ )
465+ return response
466+
467+ # Add the tool to the server
468+ mcp .add_tool (search_docs )
469+
470+ else :
471+ logging .warning (
472+ "Documentation search tool not enabled. To enable, set the following environment variables: "
473+ "DEEPSET_DOCS_WORKSPACE, DEEPSET_DOCS_PIPELINE_NAME, DEEPSET_DOCS_API_KEY"
474+ )
475+
476+
437477def main () -> None :
438478 """Entrypoint for the deepset MCP server."""
439479 parser = argparse .ArgumentParser (description = "Run the Deepset MCP server." )
@@ -447,11 +487,27 @@ def main() -> None:
447487 "-k" ,
448488 help = "Deepset API key (env DEEPSET_API_KEY)" ,
449489 )
490+ parser .add_argument (
491+ "--docs-workspace" ,
492+ help = "Deepset docs search workspace (env DEEPSET_DOCS_WORKSPACE)" ,
493+ )
494+ parser .add_argument (
495+ "--docs-pipeline-name" ,
496+ help = "Deepset docs pipeline name (env DEEPSET_DOCS_PIPELINE_NAME)" ,
497+ )
498+ parser .add_argument (
499+ "--docs-api-key" ,
500+ help = "Deepset docs pipeline API key (env DEEPSET_DOCS_API_KEY)" ,
501+ )
450502 args = parser .parse_args ()
451503
452504 # prefer flags, fallback to env
453505 workspace = args .workspace or os .getenv ("DEEPSET_WORKSPACE" )
454506 api_key = args .api_key or os .getenv ("DEEPSET_API_KEY" )
507+ docs_workspace = args .docs_workspace or os .getenv ("DEEPSET_DOCS_WORKSPACE" )
508+ docs_pipeline_name = args .docs_pipeline_name or os .getenv ("DEEPSET_DOCS_PIPELINE_NAME" )
509+ docs_api_key = args .docs_api_key or os .getenv ("DEEPSET_DOCS_API_KEY" )
510+
455511 if not workspace :
456512 parser .error ("Missing workspace: set --workspace or DEEPSET_WORKSPACE" )
457513 if not api_key :
@@ -461,6 +517,14 @@ def main() -> None:
461517 os .environ ["DEEPSET_WORKSPACE" ] = workspace
462518 os .environ ["DEEPSET_API_KEY" ] = api_key
463519
520+ # Set docs environment variables if provided
521+ if docs_workspace :
522+ os .environ ["DEEPSET_DOCS_WORKSPACE" ] = docs_workspace
523+ if docs_pipeline_name :
524+ os .environ ["DEEPSET_DOCS_PIPELINE_NAME" ] = docs_pipeline_name
525+ if docs_api_key :
526+ os .environ ["DEEPSET_DOCS_API_KEY" ] = docs_api_key
527+
464528 # run with SSE transport (HTTP+Server-Sent Events)
465529 mcp .run (transport = "stdio" )
466530
0 commit comments