Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
f108177
1
Parent(s): 4e9aea2
Add documentation for tool removal
Browse files- docs/servers/tools.mdx +19 -0
docs/servers/tools.mdx
CHANGED
|
@@ -712,6 +712,25 @@ The duplicate behavior options are:
|
|
| 712 |
- `"replace"`: Silently replaces the existing tool with the new one.
|
| 713 |
- `"ignore"`: Keeps the original tool and ignores the new registration attempt.
|
| 714 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
### Legacy JSON Parsing
|
| 716 |
|
| 717 |
<VersionBadge version="2.2.10" />
|
|
|
|
| 712 |
- `"replace"`: Silently replaces the existing tool with the new one.
|
| 713 |
- `"ignore"`: Keeps the original tool and ignores the new registration attempt.
|
| 714 |
|
| 715 |
+
### Removing Tools
|
| 716 |
+
|
| 717 |
+
<VersionBadge version="2.3.4" />
|
| 718 |
+
|
| 719 |
+
You can dynamically remove tools from a server using the `remove_tool` method:
|
| 720 |
+
|
| 721 |
+
```python
|
| 722 |
+
from fastmcp import FastMCP
|
| 723 |
+
|
| 724 |
+
mcp = FastMCP(name="DynamicToolServer")
|
| 725 |
+
|
| 726 |
+
@mcp.tool()
|
| 727 |
+
def calculate_sum(a: int, b: int) -> int:
|
| 728 |
+
"""Add two numbers together."""
|
| 729 |
+
return a + b
|
| 730 |
+
|
| 731 |
+
mcp.remove_tool("calculate_sum")
|
| 732 |
+
```
|
| 733 |
+
|
| 734 |
### Legacy JSON Parsing
|
| 735 |
|
| 736 |
<VersionBadge version="2.2.10" />
|