Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Annotated[pydantic.AnyUrl, pydantic.UrlConstraints(host_required=False)] instead of AnyUrl #86

Open
dsp-ant opened this issue Dec 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@dsp-ant
Copy link
Member

dsp-ant commented Dec 3, 2024

Pydantic's AnyUrl requires a host to be specified. For file resources this means that a triple slash such as file:///foo.txt is required because there is no host. We should likely be using Annotated[pydantic.AnyUrl, pydantic.UrlConstraints(host_required=False)] or something along these lines.

@dsp-ant dsp-ant changed the title Use Annotated[pydantic.AnyUrl, pydantic.UrlConstraints(host_required=False)] instead of AnyUrk Use Annotated[pydantic.AnyUrl, pydantic.UrlConstraints(host_required=False)] instead of AnyUrl Dec 3, 2024
@dsp-ant dsp-ant added the enhancement New feature or request label Jan 3, 2025
@jspahrsummers jspahrsummers added bug Something isn't working and removed enhancement New feature or request labels Feb 13, 2025
@jspahrsummers
Copy link
Member

Looks like this is affecting https://github.com/modelcontextprotocol/python-sdk/tree/main/examples/servers/simple-resource:

MCP error 0: 1 validation error for function-wrap[wrap_val()]
  Input should be a valid URL, empty host [type=url_parsing, input_value='file:///greeting.txt', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/url_parsing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants