MCPcopy Create free account
hub / github.com/Louisym/MiniCC / register

Method register

tutorials/03_tool_system.py:270–282  ·  view source on GitHub ↗

注册一个工具。 参数: spec: 工具说明书 handler: 工具的执行函数 返回: self(返回自身是为了支持链式调用,后面演示)

(self, spec: ToolSpec, handler: Callable[[dict], str])

Source from the content-addressed store, hash-verified

268 self._specs: dict[str, ToolSpec] = {}
269
270 def register(self, spec: ToolSpec, handler: Callable[[dict], str]) -> "ToolExecutor":
271 """
272 注册一个工具。
273
274 参数:
275 spec: 工具说明书
276 handler: 工具的执行函数
277 返回:
278 self(返回自身是为了支持链式调用,后面演示)
279 """
280 self._handlers[spec.name] = handler
281 self._specs[spec.name] = spec
282 return self # 返回自身,这样可以连续调用 .register().register()
283
284 def execute(self, tool_name: str, input_json: str) -> tuple[str, bool]:
285 """

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected