MCPcopy Create free account
hub / github.com/1Panel-dev/MaxKB / _extract_tool_id

Function _extract_tool_id

apps/application/flow/tools.py:373–395  ·  view source on GitHub ↗

从 raw_id 中提取最后一个符合 call_... 模式的 id,若无匹配则返回原值或 None

(raw_id)

Source from the content-addressed store, hash-verified

371
372
373def _extract_tool_id(raw_id):
374 """从 raw_id 中提取最后一个符合 call_... 模式的 id,若无匹配则返回原值或 None"""
375 if not raw_id:
376 return None
377 if not isinstance(raw_id, str):
378 raw_id = str(raw_id)
379
380 s = raw_id
381 prefix = "call_"
382 positions = [m.start() for m in re.finditer(re.escape(prefix), s)]
383 if not positions:
384 return raw_id
385
386 # 取最后一个前缀位置,截到下一个前缀或结尾
387 start = positions[-1]
388 end = len(s)
389 for pos in positions:
390 if pos > start:
391 end = pos
392 break
393
394 tool_id = s[start:end]
395 return tool_id or raw_id
396
397
398async def _initialize_skills(mcp_servers, temp_dir):

Callers 2

_get_fragment_keyFunction · 0.85
_yield_mcp_responseFunction · 0.85

Calls 1

startMethod · 0.45

Tested by

no test coverage detected