MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / ui_fetch_tools

Function ui_fetch_tools

backend/app/services/tool/tool.py:134–157  ·  view source on GitHub ↗
(tools: List[Dict])

Source from the content-addressed store, hash-verified

132
133
134async def ui_fetch_tools(tools: List[Dict]) -> List[Dict]:
135 lang = CONFIG.DEFAULT_LANG
136 for tool in tools:
137 if tool["type"] == ToolType.ACTION:
138 action = await action_ops.get(action_id=tool["id"])
139 if action:
140 tool["name"] = action.name
141
142 elif tool["type"] == ToolType.PLUGIN:
143 if "/" not in tool["id"]:
144 raise_request_validation_error(f"Invalid plugin tool ID: {tool['id']}")
145 bundle_instance_id, plugin_id = tool["id"].split("/")
146 bundle_instance: BundleInstance = await bundle_instance_ops.get(bundle_instance_id=bundle_instance_id)
147 bundle = get_bundle(bundle_id=bundle_instance.bundle_id)
148 real_bundle_name = i18n_text(bundle.bundle_id, bundle.name, lang)
149 plugin = get_plugin(bundle_id=bundle.bundle_id, plugin_id=plugin_id)
150 real_plugin_name = i18n_text(plugin.bundle_id, plugin.name, lang)
151 if bundle:
152 tool["name"] = f"{real_bundle_name} / {real_plugin_name}"
153
154 else:
155 raise_request_validation_error(f"Invalid tool type: {tool['type']}")
156
157 return tools

Callers 2

api_ui_get_assistantFunction · 0.90
api_ui_list_assistantsFunction · 0.90

Calls 5

get_bundleFunction · 0.90
i18n_textFunction · 0.90
get_pluginFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected