Skip to content

MCP Versions 0.3.0 and higher are incompatible with Pydantic V2 #49

@gmichelhelcim

Description

@gmichelhelcim

Just some days ago, spinning up the MCP server with

uvx mcp-server-datahub@latest

worked without issues.

When spinning it up today, the server crashes with the following error, before it can run startup client tests.

 π sentinel 466-phishing-alert-refinements ✗ ❯ uvx mcp-server-datahub@0.3.0
Installed 85 packages in 111ms
/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/lib/python3.12/site-packages/pydantic/_internal/_config.py:383: UserWarning: Valid config keys have changed in V2:
* 'allow_population_by_field_name' has been renamed to 'validate_by_name'
  warnings.warn(message, UserWarning)
Traceback (most recent call last):
  File "/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/bin/mcp-server-datahub", line 6, in <module>
    from mcp_server_datahub.__main__ import main
  File "/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/lib/python3.12/site-packages/mcp_server_datahub/__main__.py", line 11, in <module>
    from fastmcp.server.middleware import CallNext, Middleware, MiddlewareContext
  File "/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/lib/python3.12/site-packages/fastmcp/__init__.py", line 5, in <module>
    from fastmcp.settings import Settings
  File "/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/lib/python3.12/site-packages/fastmcp/settings.py", line 58, in <module>
    class Settings(BaseSettings):
  File "/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 242, in __new__
    set_model_fields(cls, config_wrapper=config_wrapper, ns_resolver=ns_resolver)
  File "/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 566, in set_model_fields
    fields, class_vars = collect_model_fields(cls, config_wrapper, ns_resolver, typevars_map=typevars_map)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/lib/python3.12/site-packages/pydantic/_internal/_fields.py", line 364, in collect_model_fields
    field_info = FieldInfo_.from_annotated_attribute(ann_type, assigned_value, _source=AnnotationSource.CLASS)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/lib/python3.12/site-packages/pydantic/fields.py", line 443, in from_annotated_attribute
    field_info = FieldInfo._construct(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/lib/python3.12/site-packages/pydantic/fields.py", line 519, in _construct
    merged_field_info = cls(**merged_kwargs)
                        ^^^^^^^^^^^^^^^^^^^^
  File "/Users/gmichel/.cache/uv/archive-v0/lobeYhps_c8WwK7J6L20H/lib/python3.12/site-packages/pydantic/fields.py", line 232, in __init__
    raise TypeError('cannot specify both default and default_factory')
TypeError: cannot specify both default and default_factory

uv/uvx version: uv 0.8.0 (0b2357294 2025-07-17)
python3 --version: Python 3.13.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions