Skip to content

Commit 77f310e

Browse files
authored
feat: use memory with haystack service tools (#114)
1 parent 81e6133 commit 77f310e

4 files changed

Lines changed: 539 additions & 121 deletions

File tree

src/deepset_mcp/tool_factory.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
list_component_families as list_component_families_tool,
2323
search_component_definition as search_component_definition_tool,
2424
)
25+
from deepset_mcp.tools.haystack_service_models import ComponentSearchResults
2526
from deepset_mcp.tools.indexes import (
2627
create_index as create_index_tool,
2728
deploy_index as deploy_index_tool,
@@ -54,7 +55,7 @@
5455

5556

5657
# Special wrapper for search_component_definitions that needs the model
57-
async def search_component_definitions_wrapper(client: Any, query: str, top_k: int = 5) -> str:
58+
async def search_component_definitions_wrapper(client: Any, query: str, top_k: int = 5) -> ComponentSearchResults | str:
5859
"""Use this to search for components in deepset.
5960
6061
You can use full natural language queries to find components.
@@ -68,7 +69,7 @@ async def search_component_definitions_wrapper(client: Any, query: str, top_k: i
6869
top_k: Maximum number of results to return (default: 5)
6970
7071
Returns:
71-
A formatted string containing the matched component definitions
72+
ComponentSearchResults model or error message string
7273
"""
7374
model = get_initialized_model()
7475
return await search_component_definition_tool(client, query, model, top_k)
@@ -201,10 +202,22 @@ def get_workspace_from_env() -> str:
201202
ToolConfig(needs_client=True, needs_workspace=True),
202203
),
203204
# Non-workspace tools
204-
"list_component_families": (list_component_families_tool, ToolConfig(needs_client=True)),
205-
"get_component_definition": (get_component_definition_tool, ToolConfig(needs_client=True)),
206-
"search_component_definitions": (search_component_definitions_wrapper, ToolConfig(needs_client=True)),
207-
"get_custom_components": (get_custom_components_tool, ToolConfig(needs_client=True)),
205+
"list_component_families": (
206+
list_component_families_tool,
207+
ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE),
208+
),
209+
"get_component_definition": (
210+
get_component_definition_tool,
211+
ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE),
212+
),
213+
"search_component_definitions": (
214+
search_component_definitions_wrapper,
215+
ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE),
216+
),
217+
"get_custom_components": (
218+
get_custom_components_tool,
219+
ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE),
220+
),
208221
"list_secrets": (list_secrets_tool, ToolConfig(needs_client=True)),
209222
"get_secret": (get_secret_tool, ToolConfig(needs_client=True)),
210223
}

0 commit comments

Comments
 (0)