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

Method get_tools

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

Source from the content-addressed store, hash-verified

1803 return ResourceMappingSerializer().get_resource_count(result)
1804
1805 def get_tools(self):
1806 self.is_valid(raise_exception=True)
1807
1808 workspace_manage = is_workspace_manage_permission_read(self.data.get("user_id"),
1809 self.data.get("workspace_id"), 'TOOL:READ')
1810 is_x_pack_ee = self.is_x_pack_ee()
1811 results = native_search(
1812 self.get_query_set(workspace_manage, is_x_pack_ee),
1813 get_file_content(
1814 os.path.join(
1815 PROJECT_DIR,
1816 "apps",
1817 "tools",
1818 "sql",
1819 "list_tool.sql"
1820 if workspace_manage
1821 else ("list_tool_user_ee.sql" if is_x_pack_ee else "list_tool_user.sql"),
1822 )
1823 ),
1824 )
1825
1826 # 返回包含文件夹和工具的结构
1827 return {
1828 "folders": [folder for folder in results if folder["resource_type"] == "folder"],
1829 "tools": [
1830 {
1831 **tool,
1832 "input_field_list": json.loads(tool.get("input_field_list", "[]")),
1833 "init_field_list": json.loads(tool.get("init_field_list", "[]")),
1834 }
1835 for tool in results
1836 if tool["resource_type"] == "tool"
1837 ],
1838 }

Callers

nothing calls this directly

Calls 7

is_validMethod · 0.95
is_x_pack_eeMethod · 0.95
get_query_setMethod · 0.95
native_searchFunction · 0.90
get_file_contentFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected