Skip to content

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

fix deprecation warnings

zzstoatzza62c562204c1
diff --git a/README.md b/README.md
index e2da55c36..97b42c99e 100644
--- a/README.md
+++ b/README.md
@@ -113,7 +113,7 @@ For development, install with:
git clone https://github.com/jlowin/fastmcp.git
cd fastmcp
# Install with dev dependencies
-uv sync --dev
+uv sync
```
## Quickstart
@@ -589,7 +589,7 @@ Contributions make the open-source community vibrant! We welcome improvements an
#### Setup
1. Clone: `git clone https://github.com/jlowin/fastmcp.git && cd fastmcp`
-2. Install Env & Dependencies: `uv venv && uv sync --dev` (Activate the `.venv` after creation)
+2. Install Env & Dependencies: `uv venv && uv sync` (Activate the `.venv` after creation)
#### Testing
diff --git a/pyproject.toml b/pyproject.toml
index 26720e1f1..8dcc4ab38 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -16,12 +16,6 @@ requires-python = ">=3.10"
readme = "README.md"
license = { text = "Apache-2.0" }
-[project.scripts]
-fastmcp = "fastmcp.cli:app"
-
-[project.optional-dependencies]
-
-
[dependency-groups]
dev = [
"pre-commit",
@@ -36,23 +30,32 @@ dev = [
"pdbpp>=0.10.3",
"dirty-equals>=0.9.0",
]
+
+[project.scripts]
+fastmcp = "fastmcp.cli:app"
+
[build-system]
-requires = ["hatchling>=1.21.0", "hatch-vcs>=0.4.0"]
+requires = ["hatchling", "uv-dynamic-versioning>=0.7.0"]
build-backend = "hatchling.build"
+[tool.hatch.version]
+source = "uv-dynamic-versioning"
+
+[tool.uv-dynamic-versioning]
+vcs = "git"
+style = "pep440"
+bump = true
+fallback-version = "0.0.0"
+
[tool.uv]
-# no default groups
-default-groups = []
+# uncomment to omit `dev` default group
+# default-groups = []
[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "session"
-filterwarnings = [
- "ignore:Accessing the 'model_fields' attribute on the instance is deprecated:DeprecationWarning",
-]
+filterwarnings = []
-[tool.hatch.version]
-source = "vcs"
[tool.pyright]
include = ["src", "tests"]
@@ -67,7 +70,7 @@ venvPath = "."
venv = ".venv"
[tool.ruff.lint]
-extend-select = ["I"]
+extend-select = ["I", "UP"]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401", "I001", "RUF013"]
diff --git a/src/fastmcp/utilities/func_metadata.py b/src/fastmcp/utilities/func_metadata.py
index 5673b5a26..e9d47b843 100644
--- a/src/fastmcp/utilities/func_metadata.py
+++ b/src/fastmcp/utilities/func_metadata.py
@@ -27,7 +27,7 @@ class ArgModelBase(BaseModel):
That is, sub-models etc are not dumped - they are kept as pydantic models.
"""
kwargs: dict[str, Any] = {}
- for field_name in self.model_fields.keys():
+ for field_name in self.__class__.model_fields.keys():
kwargs[field_name] = getattr(self, field_name)
return kwargs
diff --git a/src/fastmcp/utilities/openapi.py b/src/fastmcp/utilities/openapi.py
index 68abf0126..4427951b2 100644
--- a/src/fastmcp/utilities/openapi.py
+++ b/src/fastmcp/utilities/openapi.py
@@ -1,6 +1,6 @@
import json
import logging
-from typing import Any, Literal, Union, cast
+from typing import Any, Literal, cast
# Using the recommended library: openapi-pydantic
from openapi_pydantic import (
@@ -92,7 +92,7 @@ __all__ = [
def _resolve_ref(
- item: Union[Reference, Schema, Parameter, RequestBody, Any], openapi: OpenAPI
+ item: Reference | Schema | Parameter | RequestBody | Any, openapi: OpenAPI
) -> Any:
"""Resolves a potential Reference object to its target definition (no changes needed here)."""
if isinstance(item, Reference):
@@ -110,7 +110,7 @@ def _resolve_ref(
elif isinstance(target, BaseModel):
# Use model_extra for fields not explicitly defined (like components types)
# Check class fields first, then model_extra
- if part in target.model_fields: # Access class attribute here
+ if part in target.__class__.model_fields:
target = getattr(target, part, None)
elif target.model_extra and part in target.model_extra:
target = target.model_extra[part]
@@ -141,7 +141,7 @@ def _resolve_ref(
def _extract_schema_as_dict(
- schema_obj: Union[Schema, Reference], openapi: OpenAPI
+ schema_obj: Schema | Reference, openapi: OpenAPI
) -> JsonSchema:
"""Resolves a schema/reference and returns it as a dictionary."""
resolved_schema = _resolve_ref(schema_obj, openapi)
@@ -177,8 +177,8 @@ def _convert_to_parameter_location(param_in: str) -> ParameterLocation:
def _extract_parameters(
- operation_params: list[Union[Parameter, Reference]] | None,
- path_item_params: list[Union[Parameter, Reference]] | None,
+ operation_params: list[Parameter | Reference] | None,
+ path_item_params: list[Parameter | Reference] | None,
openapi: OpenAPI,
) -> list[ParameterInfo]:
"""Extracts and resolves parameters using corrected attribute names."""
diff --git a/uv.lock b/uv.lock
index a3b445223..72cdc17b9 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1,4 +1,5 @@
version = 1
+revision = 1
requires-python = ">=3.10"
[[package]]
@@ -127,7 +128,7 @@ name = "click"
version = "8.1.8"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "colorama", marker = "platform_system == 'Windows'" },
+ { name = "colorama", marker = "sys_platform == 'win32'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593 }
wheels = [
@@ -230,7 +231,7 @@ name = "fancycompleter"
version = "0.9.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "pyreadline", marker = "platform_system == 'Windows'" },
+ { name = "pyreadline", marker = "sys_platform == 'win32'" },
{ name = "pyrepl" },
]
sdist = { url = "https://files.pythonhosted.org/packages/a9/95/649d135442d8ecf8af5c7e235550c628056423c96c4bc6787348bdae9248/fancycompleter-0.9.1.tar.gz", hash = "sha256:09e0feb8ae242abdfd7ef2ba55069a46f011814a80fe5476be48f51b00247272", size = 10866 }
@@ -254,7 +255,6 @@ wheels = [
[[package]]
name = "fastmcp"
-version = "0.4.2.dev40+g8720a78.d20250410"
source = { editable = "." }
dependencies = [
{ name = "dotenv" },