pathintegral-institute/mcpm.sh

[Bug]: Unable to start `mcpm`

Closed this issue · 7 comments

What happened?

When I used pipx install mcpm and ran mpc --version, I encountered the following error:

TypeError: cannot specify both default and default_factory

I think this might be a bug. I've tested it on both debian 13 and gentoo and was able to reproduce the issue. How should this be resolved?

What did you expect?

I hope to get help

MCPM Version

2.9.0

OS

Linux

Logs

╭───────────── Traceback (most recent call last) ──────────────╮
│ /home/shenzhe/.local/bin/mcpm:3 in <module>                  │
│                                                              │
│   1 #!/home/shenzhe/.local/share/pipx/venvs/mcpm/bin/python  │
│   2 import sys                                               │
│ ❱ 3 from mcpm.cli import main                                │
│   4 if __name__ == '__main__':                               │
│   5 │   if sys.argv[0].endswith('.exe'):                     │
│   6 │   │   sys.argv[0] = sys.argv[0][:-4]                   │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/mcpm/cli.py:13 in <module>                       │
│                                                              │
│    10 from rich.traceback import install as install_rich_tra │
│    11                                                        │
│    12 from mcpm.clients.client_config import ClientConfigMan │
│ ❱  13 from mcpm.commands import (                            │
│    14 │   client,                                            │
│    15 │   config,                                            │
│    16 │   doctor,                                            │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/mcpm/commands/__init__.py:25 in <module>         │
│                                                              │
│   22 # All command modules                                   │
│   23                                                         │
│   24                                                         │
│ ❱ 25 from . import (                                         │
│   26 │   client,                                             │
│   27 │   config,                                             │
│   28 │   doctor,                                             │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/mcpm/commands/profile/__init__.py:10 in <module> │
│                                                              │
│    7 from .inspect import inspect_profile                    │
│    8 from .list import list_profiles                         │
│    9 from .remove import remove_profile                      │
│ ❱ 10 from .run import run                                    │
│   11 from .share import share_profile                        │
│   12                                                         │
│   13                                                         │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/mcpm/commands/profile/run.py:9 in <module>       │
│                                                              │
│     6 from rich.console import Console                       │
│     7 from rich.panel import Panel                           │
│     8                                                        │
│ ❱   9 from mcpm.fastmcp_integration.proxy import create_mcpm │
│    10                                                        │
│    11 # Removed SessionAction import - using strings directl │
│    12 from mcpm.profile.profile_config import ProfileConfigM │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/mcpm/fastmcp_integration/proxy.py:8 in <module>  │
│                                                              │
│     5 import logging                                         │
│     6 from typing import Dict, List, Optional                │
│     7                                                        │
│ ❱   8 from fastmcp import FastMCP                            │
│     9 from fastmcp.utilities.mcp_config import (             │
│    10 │   MCPConfig,                                         │
│    11 │   RemoteMCPServer,                                   │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/fastmcp/__init__.py:5 in <module>                │
│                                                              │
│    2                                                         │
│    3 import warnings                                         │
│    4 from importlib.metadata import version                  │
│ ❱  5 from fastmcp.settings import Settings                   │
│    6                                                         │
│    7 settings = Settings()                                   │
│    8                                                         │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/fastmcp/settings.py:58 in <module>               │
│                                                              │
│    55 │   env_prefixes: list[str] | None                     │
│    56                                                        │
│    57                                                        │
│ ❱  58 class Settings(BaseSettings):                          │
│    59 │   """FastMCP settings."""                            │
│    60 │                                                      │
│    61 │   model_config = ExtendedSettingsConfigDict(         │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/pydantic/_internal/_model_construction.py:242 in │
│ __new__                                                      │
│                                                              │
│   239 │   │   │                                              │
│   240 │   │   │   ns_resolver = NsResolver(parent_namespace= │
│   241 │   │   │                                              │
│ ❱ 242 │   │   │   set_model_fields(cls, config_wrapper=confi │
│   243 │   │   │                                              │
│   244 │   │   │   # This is also set in `complete_model_clas │
│   245 │   │   │   # We set them here as well for backwards c │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/pydantic/_internal/_model_construction.py:566 in │
│ set_model_fields                                             │
│                                                              │
│   563 │   │   ns_resolver: Namespace resolver to use when ge │
│   564 │   """
│   565 │   typevars_map = get_model_typevars_map(cls)         │
│ ❱ 566 │   fields, class_vars = collect_model_fields(cls, con │
│   567 │                                                      │
│   568 │   cls.__pydantic_fields__ = fields                   │
│   569 │   cls.__class_vars__.update(class_vars)              │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/pydantic/_internal/_fields.py:364 in             │
│ collect_model_fields                                         │
│                                                              │
│   361 │   │   │   │   assigned_value.default = default       │
│   362 │   │   │   │   assigned_value._attributes_set['defaul │
│   363 │   │   │                                              │
│ ❱ 364 │   │   │   field_info = FieldInfo_.from_annotated_att │
│   365 │   │   │   # Store the original annotation and assign │
│   366 │   │   │   # Note that the assignment is always store │
│   367 │   │   │   #  parameterized with an unknown forward r │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/pydantic/fields.py:443 in                        │
│ from_annotated_attribute                                     │
│                                                              │
│    440 │   │   │   # `default` is the actual default value   │
│    441 │   │   │   attr_overrides['default'] = default       │
│    442 │   │                                                 │
│ ❱  443 │   │   field_info = FieldInfo._construct(            │
│    444 │   │   │   prepend_metadata + metadata if prepend_me │
│    445 │   │   )                                             │
│    446 │   │   field_info._qualifiers = inspected_ann.qualif │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/pydantic/fields.py:519 in _construct             │
│                                                              │
│    516 │   │   │   │   merged_metadata.append(meta)          │
│    517 │   │                                                 │
│    518 │   │   merged_kwargs.update(attr_overrides)          │
│ ❱  519 │   │   merged_field_info = cls(**merged_kwargs)      │
│    520 │   │   merged_field_info.metadata = merged_metadata  │
│    521 │   │   return merged_field_info                      │
│    522                                                       │
│                                                              │
│ /home/shenzhe/.local/share/pipx/venvs/mcpm/lib/python3.13/si │
│ te-packages/pydantic/fields.py:232 in __init__               │
│                                                              │
│    229 │   │   self.default_factory = kwargs.pop('default_fa │
│    230 │   │                                                 │
│    231 │   │   if self.default is not PydanticUndefined and  │
│ ❱  232 │   │   │   raise TypeError('cannot specify both defa │
│    233 │   │                                                 │
│    234 │   │   self.alias = kwargs.pop('alias', None)        │
│    235 │   │   self.validation_alias = kwargs.pop('validatio │
╰──────────────────────────────────────────────────────────────╯
TypeError: cannot specify both default and default_factory

Same

It looks like the problem is caused when Pydantic is >=2.12.0. To solve this i installed the locked dependencies with uv:

# Clean
pipx uninstal mcpm
uv tool uninstall mcpm

git clone https://github.com/pathintegral-institute/mcpm.sh
cd mcpm.sh

uv venv
uv sync  # install exdependencies

uv tool install .

mcpm -h

Another option is to restrict the pydantic version on the pyproject.toml: "pydantic>=2.5.1, <2.12.0",

@komod0 Thank you very much for sharing the solution, I successfully resolved this issue. It appears the problem was caused by changes in the pydantic API. Does the author have plans to fix it? I'd be happy to help.

@komod0 Thank you very much for sharing the solution, I successfully resolved this issue. It appears the problem was caused by changes in the pydantic API. Does the author have plans to fix it? I'd be happy to help.

@SSDGADsss I'm not the author or a contributor but i'll send a PR fixing that, it should be just adding the pydantic<2.12.0 restriction to the pyproject file

I installed after the pr merge but still same error? might gotta wait a bit

> # Clean

> pipx uninstal mcpm
> uv tool uninstall mcpm
> 
> git clone https://github.com/pathintegral-institute/mcpm.sh
> cd mcpm.sh
> 
> uv venv
> uv sync  # install exdependencies
> 
> uv tool install .
> 
> mcpm -h

@supastishn Try doing the above, there was no new version released after the change was merged yet so you will need to clone the repo manually to get the fix

Temporary solution until the release is published.

pip install --prefer-binary "pydantic>=2.5.1,<2.12.0" mcpm