[{"data":1,"prerenderedAt":380},["ShallowReactive",2],{"\u002Fdocs\u002Fapi-reference\u002Ftool-registry":3},{"id":4,"title":5,"body":6,"description":373,"extension":374,"meta":375,"navigation":84,"path":376,"seo":377,"stem":378,"__hash__":379},"docs\u002Fdocs\u002F4.api-reference\u002F4.tool-registry.md","ToolRegistry",{"type":7,"value":8,"toc":364},"minimark",[9,13,42,46,51,148,152,159,162,171,174,180,187,202,204,210,216,219,275,286,289,346,360],[10,11,5],"h1",{"id":12},"toolregistry",[14,15,20],"pre",{"className":16,"code":17,"language":18,"meta":19,"style":19},"language-python shiki shiki-themes github-dark","from mango.tools.base import ToolRegistry\n","python","",[21,22,23],"code",{"__ignoreMap":19},[24,25,28,32,36,39],"span",{"class":26,"line":27},"line",1,[24,29,31],{"class":30},"snl16","from",[24,33,35],{"class":34},"s95oV"," mango.tools.base ",[24,37,38],{"class":30},"import",[24,40,41],{"class":34}," ToolRegistry\n",[43,44,45],"p",{},"Manages tool registration and execution. The LLM receives tool definitions from the registry and calls tools by name.",[47,48,50],"h2",{"id":49},"usage","Usage",[14,52,54],{"className":16,"code":53,"language":18,"meta":19,"style":19},"from mango.tools.base import ToolRegistry\nfrom mango.tools import build_mongo_tools\n\ntools = ToolRegistry()\n\n# Register built-in MongoDB tools\nfor tool in build_mongo_tools(db, memory):\n    tools.register(tool)\n\n# Register a custom tool\ntools.register(MyCustomTool())\n",[21,55,56,66,79,86,98,103,110,125,131,136,142],{"__ignoreMap":19},[24,57,58,60,62,64],{"class":26,"line":27},[24,59,31],{"class":30},[24,61,35],{"class":34},[24,63,38],{"class":30},[24,65,41],{"class":34},[24,67,69,71,74,76],{"class":26,"line":68},2,[24,70,31],{"class":30},[24,72,73],{"class":34}," mango.tools ",[24,75,38],{"class":30},[24,77,78],{"class":34}," build_mongo_tools\n",[24,80,82],{"class":26,"line":81},3,[24,83,85],{"emptyLinePlaceholder":84},true,"\n",[24,87,89,92,95],{"class":26,"line":88},4,[24,90,91],{"class":34},"tools ",[24,93,94],{"class":30},"=",[24,96,97],{"class":34}," ToolRegistry()\n",[24,99,101],{"class":26,"line":100},5,[24,102,85],{"emptyLinePlaceholder":84},[24,104,106],{"class":26,"line":105},6,[24,107,109],{"class":108},"sAwPA","# Register built-in MongoDB tools\n",[24,111,113,116,119,122],{"class":26,"line":112},7,[24,114,115],{"class":30},"for",[24,117,118],{"class":34}," tool ",[24,120,121],{"class":30},"in",[24,123,124],{"class":34}," build_mongo_tools(db, memory):\n",[24,126,128],{"class":26,"line":127},8,[24,129,130],{"class":34},"    tools.register(tool)\n",[24,132,134],{"class":26,"line":133},9,[24,135,85],{"emptyLinePlaceholder":84},[24,137,139],{"class":26,"line":138},10,[24,140,141],{"class":108},"# Register a custom tool\n",[24,143,145],{"class":26,"line":144},11,[24,146,147],{"class":34},"tools.register(MyCustomTool())\n",[47,149,151],{"id":150},"methods","Methods",[153,154,156],"h3",{"id":155},"registertool-tool-none",[21,157,158],{},"register(tool: Tool) → None",[43,160,161],{},"Register a tool. Raises if a tool with the same name is already registered.",[14,163,165],{"className":16,"code":164,"language":18,"meta":19,"style":19},"tools.register(MyTool())\n",[21,166,167],{"__ignoreMap":19},[24,168,169],{"class":26,"line":27},[24,170,164],{"class":34},[172,173],"hr",{},[153,175,177],{"id":176},"get_definitions-listtooldef",[21,178,179],{},"get_definitions() → list[ToolDef]",[43,181,182,183,186],{},"Returns all tool definitions. Passed to the LLM on every ",[21,184,185],{},"chat()"," call.",[14,188,190],{"className":16,"code":189,"language":18,"meta":19,"style":19},"definitions = tools.get_definitions()\n",[21,191,192],{"__ignoreMap":19},[24,193,194,197,199],{"class":26,"line":27},[24,195,196],{"class":34},"definitions ",[24,198,94],{"class":30},[24,200,201],{"class":34}," tools.get_definitions()\n",[172,203],{},[153,205,207],{"id":206},"executetool_name-kwargs-toolresult",[21,208,209],{},"execute(tool_name, **kwargs) → ToolResult",[43,211,212],{},[213,214,215],"em",{},"async",[43,217,218],{},"Execute a tool by name with the given arguments.",[14,220,222],{"className":16,"code":221,"language":18,"meta":19,"style":19},"result = await tools.execute(\"run_mql\", operation=\"count\", collection=\"users\")\nprint(result.success, result.data)\n",[21,223,224,266],{"__ignoreMap":19},[24,225,226,229,231,234,237,241,244,248,250,253,255,258,260,263],{"class":26,"line":27},[24,227,228],{"class":34},"result ",[24,230,94],{"class":30},[24,232,233],{"class":30}," await",[24,235,236],{"class":34}," tools.execute(",[24,238,240],{"class":239},"sU2Wk","\"run_mql\"",[24,242,243],{"class":34},", ",[24,245,247],{"class":246},"s9osk","operation",[24,249,94],{"class":30},[24,251,252],{"class":239},"\"count\"",[24,254,243],{"class":34},[24,256,257],{"class":246},"collection",[24,259,94],{"class":30},[24,261,262],{"class":239},"\"users\"",[24,264,265],{"class":34},")\n",[24,267,268,272],{"class":26,"line":68},[24,269,271],{"class":270},"sDLfK","print",[24,273,274],{"class":34},"(result.success, result.data)\n",[43,276,277,278,281,282,285],{},"Raises ",[21,279,280],{},"KeyError"," if ",[21,283,284],{},"tool_name"," is not registered.",[47,287,288],{"id":288},"build_mongo_tools",[14,290,292],{"className":16,"code":291,"language":18,"meta":19,"style":19},"from mango.tools import build_mongo_tools\n\ntools_list = build_mongo_tools(\n    db: NoSQLRunner,\n    memory: MemoryService | None = None,\n)\n",[21,293,294,304,308,318,323,342],{"__ignoreMap":19},[24,295,296,298,300,302],{"class":26,"line":27},[24,297,31],{"class":30},[24,299,73],{"class":34},[24,301,38],{"class":30},[24,303,78],{"class":34},[24,305,306],{"class":26,"line":68},[24,307,85],{"emptyLinePlaceholder":84},[24,309,310,313,315],{"class":26,"line":81},[24,311,312],{"class":34},"tools_list ",[24,314,94],{"class":30},[24,316,317],{"class":34}," build_mongo_tools(\n",[24,319,320],{"class":26,"line":88},[24,321,322],{"class":34},"    db: NoSQLRunner,\n",[24,324,325,328,331,334,337,339],{"class":26,"line":100},[24,326,327],{"class":34},"    memory: MemoryService ",[24,329,330],{"class":30},"|",[24,332,333],{"class":246}," None",[24,335,336],{"class":30}," =",[24,338,333],{"class":270},[24,340,341],{"class":34},",\n",[24,343,344],{"class":26,"line":105},[24,345,265],{"class":34},[43,347,348,349,352,353,243,356,359],{},"Returns all built-in MongoDB tools as a list ready to register. Pass ",[21,350,351],{},"memory"," to enable memory-related tools (",[21,354,355],{},"search_saved_correct_tool_uses",[21,357,358],{},"save_text_memory",").",[361,362,363],"style",{},"html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .s9osk, html code.shiki .s9osk{--shiki-default:#FFAB70}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}",{"title":19,"searchDepth":68,"depth":68,"links":365},[366,367,372],{"id":49,"depth":68,"text":50},{"id":150,"depth":68,"text":151,"children":368},[369,370,371],{"id":155,"depth":81,"text":158},{"id":176,"depth":81,"text":179},{"id":206,"depth":81,"text":209},{"id":288,"depth":68,"text":288},"Registers and dispatches tools.","md",{},"\u002Fdocs\u002Fapi-reference\u002Ftool-registry",{"title":5,"description":373},"docs\u002F4.api-reference\u002F4.tool-registry","F5VeD5gCtYj-WCGETcwIIHpHeTnCKh4GoVyFn0pQ4bU",1776189332133]