Merge pull request #440 from jlowin/doc-tool-removal

Add documentation for tool removal
This commit is contained in:
Jeremiah Lowin 2025-05-13 18:47:53 -04:00 committed by GitHub
commit 2c1f3c83f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -712,6 +712,25 @@ The duplicate behavior options are:
- `"replace"`: Silently replaces the existing tool with the new one.
- `"ignore"`: Keeps the original tool and ignores the new registration attempt.
### Removing Tools
<VersionBadge version="2.3.4" />
You can dynamically remove tools from a server using the `remove_tool` method:
```python
from fastmcp import FastMCP
mcp = FastMCP(name="DynamicToolServer")
@mcp.tool()
def calculate_sum(a: int, b: int) -> int:
"""Add two numbers together."""
return a + b
mcp.remove_tool("calculate_sum")
```
### Legacy JSON Parsing
<VersionBadge version="2.2.10" />