Returns a tool that Claude can use to search through all available tools
(tools: List[BetaFunctionTool[Any]])
| 45 | |
| 46 | |
| 47 | def make_tool_searcher(tools: List[BetaFunctionTool[Any]]) -> BetaFunctionTool[Any]: |
| 48 | """Returns a tool that Claude can use to search through all available tools""" |
| 49 | |
| 50 | @beta_tool |
| 51 | def search_available_tools(*, keyword: str) -> BetaFunctionToolResultType: |
| 52 | """Search for useful tools using a query string""" |
| 53 | |
| 54 | results: list[BetaToolReferenceBlockParam] = [] |
| 55 | for tool in tools: |
| 56 | if keyword in json.dumps(tool.to_dict()): |
| 57 | results.append({"type": "tool_reference", "tool_name": tool.name}) |
| 58 | |
| 59 | return results |
| 60 | |
| 61 | return search_available_tools |
| 62 | |
| 63 | |
| 64 | def main() -> None: |