FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

SEP: Allow non-file URI schemes for Roots by chughtapan · Pull Request #1390 · modelcontextprotocol/python-sdk · GitHub

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 4 additions & 5 deletions src/mcp/types.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL