Set server version for @app.tool and MCPApp.add_tool (#672)
This commit is contained in:
parent
3c6f1a69af
commit
630f7b8a26
3 changed files with 20 additions and 4 deletions
|
|
@ -203,9 +203,18 @@ class ToolCatalog(BaseModel):
|
||||||
tool_func: Callable,
|
tool_func: Callable,
|
||||||
toolkit_or_name: str | Toolkit,
|
toolkit_or_name: str | Toolkit,
|
||||||
module: ModuleType | None = None,
|
module: ModuleType | None = None,
|
||||||
|
toolkit_version: str | None = None,
|
||||||
|
toolkit_description: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Add a function to the catalog as a tool.
|
Add a function to the catalog as a tool.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
tool_func: The function to add to the catalog.
|
||||||
|
toolkit_or_name: The toolkit or name of the toolkit.
|
||||||
|
module: The module to add the tool from.
|
||||||
|
toolkit_version: The version of the toolkit. Overrides the version of the toolkit if provided.
|
||||||
|
toolkit_description: The description of the toolkit. Overrides the description of the toolkit if provided.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
input_model, output_model = create_func_models(tool_func)
|
input_model, output_model = create_func_models(tool_func)
|
||||||
|
|
@ -213,6 +222,8 @@ class ToolCatalog(BaseModel):
|
||||||
if isinstance(toolkit_or_name, Toolkit):
|
if isinstance(toolkit_or_name, Toolkit):
|
||||||
toolkit = toolkit_or_name
|
toolkit = toolkit_or_name
|
||||||
toolkit_name = toolkit.name
|
toolkit_name = toolkit.name
|
||||||
|
toolkit_version = toolkit_version or toolkit.version
|
||||||
|
toolkit_description = toolkit_description or toolkit.description
|
||||||
elif isinstance(toolkit_or_name, str):
|
elif isinstance(toolkit_or_name, str):
|
||||||
toolkit = None
|
toolkit = None
|
||||||
toolkit_name = toolkit_or_name
|
toolkit_name = toolkit_or_name
|
||||||
|
|
@ -223,8 +234,8 @@ class ToolCatalog(BaseModel):
|
||||||
definition = ToolCatalog.create_tool_definition(
|
definition = ToolCatalog.create_tool_definition(
|
||||||
tool_func,
|
tool_func,
|
||||||
toolkit_name,
|
toolkit_name,
|
||||||
toolkit.version if toolkit else None,
|
toolkit_version,
|
||||||
toolkit.description if toolkit else None,
|
toolkit_description,
|
||||||
)
|
)
|
||||||
|
|
||||||
fully_qualified_name = definition.get_fully_qualified_name()
|
fully_qualified_name = definition.get_fully_qualified_name()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "arcade-core"
|
name = "arcade-core"
|
||||||
version = "3.3.1"
|
version = "3.3.2"
|
||||||
description = "Arcade Core - Core library for Arcade platform"
|
description = "Arcade Core - Core library for Arcade platform"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = {text = "MIT"}
|
license = {text = "MIT"}
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,12 @@ class MCPApp:
|
||||||
adapters=adapters,
|
adapters=adapters,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
self._catalog.add_tool(func, self._toolkit_name)
|
self._catalog.add_tool(
|
||||||
|
func,
|
||||||
|
self._toolkit_name,
|
||||||
|
toolkit_version=self.version,
|
||||||
|
toolkit_description=self.instructions,
|
||||||
|
)
|
||||||
except ToolDefinitionError as e:
|
except ToolDefinitionError as e:
|
||||||
raise e.with_context(func.__name__) from e
|
raise e.with_context(func.__name__) from e
|
||||||
logger.debug(f"Added tool: {func.__name__}")
|
logger.debug(f"Added tool: {func.__name__}")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue