feat: add ability to remove tools (#1322)
Co-authored-by: David Soria Parra <167242713+dsp-ant@users.noreply.github.com> Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com> Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
df3e428ee8
commit
b8e758b02b
2 changed files with 204 additions and 0 deletions
|
|
@ -391,6 +391,17 @@ class FastMCP(Generic[LifespanResultT]):
|
|||
structured_output=structured_output,
|
||||
)
|
||||
|
||||
def remove_tool(self, name: str) -> None:
|
||||
"""Remove a tool from the server by name.
|
||||
|
||||
Args:
|
||||
name: The name of the tool to remove
|
||||
|
||||
Raises:
|
||||
ToolError: If the tool does not exist
|
||||
"""
|
||||
self._tool_manager.remove_tool(name)
|
||||
|
||||
def tool(
|
||||
self,
|
||||
name: str | None = None,
|
||||
|
|
|
|||
|
|
@ -70,6 +70,12 @@ class ToolManager:
|
|||
self._tools[tool.name] = tool
|
||||
return tool
|
||||
|
||||
def remove_tool(self, name: str) -> None:
|
||||
"""Remove a tool by name."""
|
||||
if name not in self._tools:
|
||||
raise ToolError(f"Unknown tool: {name}")
|
||||
del self._tools[name]
|
||||
|
||||
async def call_tool(
|
||||
self,
|
||||
name: str,
|
||||
|
|
|
|||
Loading…
Reference in a new issue