MCPcopy
hub / github.com/1Panel-dev/MaxKB / get_tools

Method get_tools

apps/tools/serializers/tool.py:424–461  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

422 return workspace_user_role_mapping_model is not None and role_permission_mapping_model is not None
423
424 def get_tools(self):
425 self.is_valid(raise_exception=True)
426
427 workspace_manage = is_workspace_manage(self.data.get("user_id"), self.data.get("workspace_id"))
428 is_x_pack_ee = self.is_x_pack_ee()
429 results = native_search(
430 self.get_query_set(workspace_manage, is_x_pack_ee),
431 get_file_content(
432 os.path.join(
433 PROJECT_DIR,
434 "apps",
435 "tools",
436 "sql",
437 "list_tool.sql"
438 if workspace_manage
439 else ("list_tool_user_ee.sql" if is_x_pack_ee else "list_tool_user.sql"),
440 )
441 ),
442 )
443
444 get_authorized_tool = DatabaseModelManage.get_model("get_authorized_tool")
445 shared_queryset = QuerySet(Tool).none()
446 if get_authorized_tool is not None:
447 shared_queryset = self.get_authorized_query_set()
448 shared_queryset = get_authorized_tool(shared_queryset, self.data.get("workspace_id"))
449
450 return {
451 "shared_tools": [ToolModelSerializer(data).data for data in shared_queryset],
452 "tools": [
453 {
454 **tool,
455 "input_field_list": json.loads(tool.get("input_field_list", "[]")),
456 "init_field_list": json.loads(tool.get("init_field_list", "[]")),
457 }
458 for tool in results
459 if tool["resource_type"] == "tool"
460 ],
461 }
462
463 class Create(serializers.Serializer):
464 user_id = serializers.UUIDField(required=True, label=_("user id"))

Callers 5

validateFunction · 0.45
getMethod · 0.45
getMethod · 0.45
_yield_mcp_responseFunction · 0.45
get_mcp_toolsFunction · 0.45

Calls 10

is_validMethod · 0.95
is_x_pack_eeMethod · 0.95
get_query_setMethod · 0.95
is_workspace_manageFunction · 0.90
native_searchFunction · 0.90
get_file_contentFunction · 0.90
ToolModelSerializerClass · 0.85
getMethod · 0.45
get_modelMethod · 0.45

Tested by

no test coverage detected