π The fast, Pythonic way to build MCP servers and clients.
Make the type checker less sad
William Easton93a7255f7a3b
diff --git a/src/fastmcp/prompts/prompt.py b/src/fastmcp/prompts/prompt.pyindex 0c634a27a..7c242bbf4 100644--- a/src/fastmcp/prompts/prompt.py+++ b/src/fastmcp/prompts/prompt.py@@ -59,7 +59,7 @@ class PromptArgument(FastMCPBaseModel):name: str = Field(description="Name of the argument")description: str | None = Field(- None, description="Description of what the argument does"+ default=None, description="Description of what the argument does")required: bool = Field(default=False, description="Whether the argument is required"@@ -71,13 +71,13 @@ class Prompt(FastMCPBaseModel, ABC):name: str = Field(description="Name of the prompt")description: str | None = Field(- None, description="Description of what the prompt does"+ default=None, description="Description of what the prompt does")tags: Annotated[set[str], BeforeValidator(_convert_set_defaults)] = Field(default_factory=set, description="Tags for the prompt")arguments: list[PromptArgument] | None = Field(- None, description="Arguments that can be passed to the prompt"+ default=None, description="Arguments that can be passed to the prompt")def __eq__(self, other: object) -> bool:diff --git a/src/fastmcp/resources/resource.py b/src/fastmcp/resources/resource.pyindex 15047241f..751a65b07 100644--- a/src/fastmcp/resources/resource.py+++ b/src/fastmcp/resources/resource.py@@ -38,9 +38,9 @@ class Resource(FastMCPBaseModel, abc.ABC):uri: Annotated[AnyUrl, UrlConstraints(host_required=False)] = Field(default=..., description="URI of the resource")- name: str | None = Field(description="Name of the resource", default=None)+ name: str | None = Field(default=None, description="Name of the resource")description: str | None = Field(- description="Description of the resource", default=None+ default=None, description="Description of the resource")tags: Annotated[set[str], BeforeValidator(_convert_set_defaults)] = Field(default_factory=set, description="Tags for the resource"diff --git a/src/fastmcp/tools/tool.py b/src/fastmcp/tools/tool.pyindex 7ed0b5638..aaa7ff35a 100644--- a/src/fastmcp/tools/tool.py+++ b/src/fastmcp/tools/tool.py@@ -45,14 +45,14 @@ class Tool(FastMCPBaseModel, ABC):default_factory=set, description="Tags for the tool")annotations: ToolAnnotations | None = Field(- None, description="Additional annotations about the tool"+ default=None, description="Additional annotations about the tool")exclude_args: list[str] | None = Field(- None,+ default=None,description="Arguments to exclude from the tool schema, such as State, Memory, or Credential",)serializer: Callable[[Any], str] | None = Field(- None, description="Optional custom serializer for tool results"+ default=None, description="Optional custom serializer for tool results")def to_mcp_tool(self, **overrides: Any) -> MCPTool:diff --git a/tests/utilities/test_typeadapter.py b/tests/utilities/test_typeadapter.pyindex 68f11b91d..a32d7fcb0 100644--- a/tests/utilities/test_typeadapter.py+++ b/tests/utilities/test_typeadapter.py@@ -60,7 +60,7 @@ def complex_arguments_fn(456,],field_with_default_via_field_annotation_before_nondefault_arg: Annotated[- int, Field(1)+ int, Field(default=1)],unannotated,my_model_a: SomeInputModelA,@@ -68,7 +68,7 @@ def complex_arguments_fn(my_model_b: SomeInputModelB,an_int_annotated_with_field_default: Annotated[int,- Field(1, description="An int with a field"),+ Field(default=1, description="An int with a field"),],unannotated_with_default=5,my_model_a_with_default: SomeInputModelA = SomeInputModelA(), # noqa: B008