|
53 | 53 | ) |
54 | 54 | from deepset_mcp.tools.tokonomics import RichExplorer, explorable, explorable_and_referenceable, referenceable |
55 | 55 |
|
| 56 | +EXPLORER = RichExplorer(store=STORE) |
| 57 | + |
| 58 | + |
| 59 | +def get_from_object_store(object_id: str, path: str = "") -> str: |
| 60 | + """Use this tool to fetch an object from the object store. |
| 61 | +
|
| 62 | + You can fetch a specific object by using the object's id (e.g. `@obj_001`). |
| 63 | + You can also fetch any nested path by using the path-parameter |
| 64 | + (e.g. `{"object_id": "@obj_001", "path": "user_info.given_name"}` |
| 65 | + -> returns the content at obj.user_info.given_name). |
| 66 | +
|
| 67 | + :param object_id: The id of the object to fetch in the format `@obj_001`. |
| 68 | + :param path: The path of the object to fetch in the format of `access.to.attr` or `["access"]["to"]["attr"]`. |
| 69 | + """ |
| 70 | + return EXPLORER.explore(obj_id=object_id, path=path) |
| 71 | + |
| 72 | + |
| 73 | +def get_slice_from_object_store( |
| 74 | + object_id: str, |
| 75 | + start: int = 0, |
| 76 | + end: int | None = None, |
| 77 | + path: str = "", |
| 78 | +) -> str: |
| 79 | + """Extract a slice from a string or list object that is stored in the object store. |
| 80 | +
|
| 81 | + :param object_id: Identifier of the object. |
| 82 | + :param start: Start index for slicing. |
| 83 | + :param end: End index for slicing (None for end of sequence). |
| 84 | + :param path: Navigation path to object to slice (optional). |
| 85 | + :return: String representation of the slice. |
| 86 | + """ |
| 87 | + return EXPLORER.slice(obj_id=object_id, start=start, end=end, path=path) |
| 88 | + |
56 | 89 |
|
57 | 90 | # Special wrapper for search_component_definitions that needs the model |
58 | 91 | async def search_component_definitions_wrapper(client: Any, query: str, top_k: int = 5) -> ComponentSearchResults | str: |
@@ -220,6 +253,8 @@ def get_workspace_from_env() -> str: |
220 | 253 | ), |
221 | 254 | "list_secrets": (list_secrets_tool, ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE)), |
222 | 255 | "get_secret": (get_secret_tool, ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE)), |
| 256 | + "get_from_object_store": (get_from_object_store, ToolConfig(memory_type=MemoryType.NO_MEMORY)), |
| 257 | + "get_slice_from_object_store": (get_slice_from_object_store, ToolConfig(memory_type=MemoryType.NO_MEMORY)), |
223 | 258 | } |
224 | 259 |
|
225 | 260 |
|
@@ -335,8 +370,8 @@ def register_all_tools(mcp: FastMCP, workspace_mode: WorkspaceMode, workspace: s |
335 | 370 | workspace_mode: How workspace should be handled |
336 | 371 | workspace: Workspace to use for implicit mode (if None, reads from env) |
337 | 372 | """ |
338 | | - for _tool_name, (base_func, config) in TOOL_REGISTRY.items(): |
| 373 | + for tool_name, (base_func, config) in TOOL_REGISTRY.items(): |
339 | 374 | # Create enhanced tool |
340 | 375 | enhanced_tool = create_enhanced_tool(base_func, config, workspace_mode, workspace) # type: ignore[arg-type] |
341 | 376 |
|
342 | | - mcp.add_tool(enhanced_tool) |
| 377 | + mcp.add_tool(enhanced_tool, name=tool_name) |
0 commit comments