Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/mcp/types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Callable
from typing import Annotated, Any, Generic, Literal, TypeAlias, TypeVar

from pydantic import BaseModel, ConfigDict, Field, FileUrl, RootModel
from pydantic import BaseModel, ConfigDict, Field, RootModel
from pydantic.networks import AnyUrl, UrlConstraints
from typing_extensions import deprecated

Expand Down Expand Up @@ -1181,11 +1181,10 @@ class ListRootsRequest(Request[RequestParams | None, Literal["roots/list"]]):
class Root(BaseModel):
"""Represents a root directory or file that the server can operate on."""

uri: FileUrl
uri: AnyUrl
"""
The URI identifying the root. This *must* start with file:// for now.
This restriction may be relaxed in future versions of the protocol to allow
other URI schemes.
The URI identifying the root. Can be any valid URI scheme (e.g., file://, https://,
git://, s3://, etc.). Servers should document which URI schemes they support.
"""
name: str | None = None
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/client/test_list_roots_callback.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pydantic import FileUrl
from pydantic import AnyUrl

from mcp.client.session import ClientSession
from mcp.server.fastmcp.server import Context
Expand All @@ -20,11 +20,11 @@ async def test_list_roots_callback():
callback_return = ListRootsResult(
roots=[
Root(
uri=FileUrl("file://users/fake/test"),
uri=AnyUrl("file://users/fake/test"),
name="Test Root 1",
),
Root(
uri=FileUrl("file://users/fake/test/2"),
uri=AnyUrl("https://github.com/user/repo"), # Non-file URL also works
name="Test Root 2",
),
]
Expand Down
Loading