MCPcopy
hub / github.com/ModelEngine-Group/nexent / update_tool_labels

Function update_tool_labels

backend/database/tool_db.py:161–185  ·  view source on GitHub ↗

Update labels for a specific tool. Replaces all existing labels. Args: tool_id: Tool ID to update tenant_id: Tenant ID for access control labels: New list of label strings user_id: User performing the update Returns: True if updated, False if to

(tool_id: int, tenant_id: str, labels: List[str], user_id: str)

Source from the content-addressed store, hash-verified

159
160
161def update_tool_labels(tool_id: int, tenant_id: str, labels: List[str], user_id: str) -> bool:
162 """
163 Update labels for a specific tool. Replaces all existing labels.
164
165 Args:
166 tool_id: Tool ID to update
167 tenant_id: Tenant ID for access control
168 labels: New list of label strings
169 user_id: User performing the update
170
171 Returns:
172 True if updated, False if tool not found or access denied
173 """
174 with get_db_session() as session:
175 tool = session.query(ToolInfo).filter(
176 ToolInfo.tool_id == tool_id,
177 ToolInfo.author == tenant_id,
178 ToolInfo.delete_flag != 'Y'
179 ).first()
180 if not tool:
181 return False
182 tool.labels = labels
183 tool.updated_by = user_id
184 session.flush()
185 return True
186
187
188def query_all_enabled_tool_instances(agent_id: int, tenant_id: str, version_no: int = 0):

Calls 5

get_db_sessionFunction · 0.90
firstMethod · 0.45
filterMethod · 0.45
queryMethod · 0.45
flushMethod · 0.45

Tested by 2