Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Don't store exclude args as attribute

Jeremiah Lowin32a091e22893
diff --git a/src/fastmcp/server/openapi.py b/src/fastmcp/server/openapi.py
index e156e9bdd..58a0d5037 100644
--- a/src/fastmcp/server/openapi.py
+++ b/src/fastmcp/server/openapi.py
@@ -226,7 +226,6 @@ class OpenAPITool(Tool):
tags: set[str] = set(),
timeout: float | None = None,
annotations: ToolAnnotations | None = None,
- exclude_args: list[str] | None = None,
serializer: Callable[[Any], str] | None = None,
):
super().__init__(
@@ -235,7 +234,6 @@ class OpenAPITool(Tool):
parameters=parameters,
tags=tags,
annotations=annotations,
- exclude_args=exclude_args,
serializer=serializer,
)
self._client = client
diff --git a/src/fastmcp/tools/tool.py b/src/fastmcp/tools/tool.py
index aaa7ff35a..a62a81306 100644
--- a/src/fastmcp/tools/tool.py
+++ b/src/fastmcp/tools/tool.py
@@ -47,10 +47,6 @@ class Tool(FastMCPBaseModel, ABC):
annotations: ToolAnnotations | None = Field(
default=None, description="Additional annotations about the tool"
)
- exclude_args: list[str] | None = Field(
- default=None,
- description="Arguments to exclude from the tool schema, such as State, Memory, or Credential",
- )
serializer: Callable[[Any], str] | None = Field(
default=None, description="Optional custom serializer for tool results"
)
@@ -169,7 +165,6 @@ class FunctionTool(Tool):
parameters=schema,
tags=tags or set(),
annotations=annotations,
- exclude_args=exclude_args,
serializer=serializer,
)
diff --git a/tests/server/test_tool_exclude_args.py b/tests/server/test_tool_exclude_args.py
index d91e012c7..efe8349a7 100644
--- a/tests/server/test_tool_exclude_args.py
+++ b/tests/server/test_tool_exclude_args.py
@@ -21,9 +21,7 @@ async def test_tool_exclude_args_in_tool_manager():
tools = mcp._tool_manager.list_tools()
assert len(tools) == 1
- assert tools[0].exclude_args is not None
- for args in tools[0].exclude_args:
- assert args not in tools[0].parameters
+ assert "state" not in echo.parameters["properties"]
async def test_tool_exclude_args_without_default_value_raises_error():
@@ -64,10 +62,7 @@ async def test_add_tool_method_exclude_args():
# Check internal tool objects directly
tools = mcp._tool_manager.list_tools()
assert len(tools) == 1
- assert tools[0].exclude_args is not None
- assert tools[0].exclude_args == ["state"]
- for args in tools[0].exclude_args:
- assert args not in tools[0].parameters
+ assert "state" not in tools[0].parameters["properties"]
async def test_tool_functionality_with_exclude_args():