fix: change Resource URI fields from AnyUrl to str (#1863)

This commit is contained in:
Felix Weinberger 2026-01-16 08:58:57 +00:00 • committed by GitHub
commit cfb2909631
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,7 +5,6 @@ from datetime import datetime
from typing import Annotated, Any, Final, Generic, Literal, TypeAlias, TypeVar
from pydantic import BaseModel, ConfigDict, Field, FileUrl, RootModel
from pydantic.networks import AnyUrl, UrlConstraints
LATEST_PROTOCOL_VERSION = "2025-11-25"
@ -756,7 +755,7 @@ class Annotations(BaseModel):
class Resource(BaseMetadata):
"""A known resource that the server is capable of reading."""
uri: Annotated[AnyUrl, UrlConstraints(host_required=False)]
uri: str
"""The URI of this resource."""
description: str | None = None
"""A description of what this resource represents."""
@ -827,7 +826,7 @@ class ListResourceTemplatesResult(PaginatedResult):
class ReadResourceRequestParams(RequestParams):
"""Parameters for reading a resource."""
uri: Annotated[AnyUrl, UrlConstraints(host_required=False)]
uri: str
"""
The URI of the resource to read. The URI can use any protocol; it is up to the
server how to interpret it.
@ -845,7 +844,7 @@ class ReadResourceRequest(Request[ReadResourceRequestParams, Literal["resources/
class ResourceContents(BaseModel):
"""The contents of a specific resource or sub-resource."""
uri: Annotated[AnyUrl, UrlConstraints(host_required=False)]
uri: str
"""The URI of this resource."""
mimeType: str | None = None
"""The MIME type of this resource, if known."""
@ -895,7 +894,7 @@ class ResourceListChangedNotification(
class SubscribeRequestParams(RequestParams):
"""Parameters for subscribing to a resource."""
uri: Annotated[AnyUrl, UrlConstraints(host_required=False)]
uri: str
"""
The URI of the resource to subscribe to. The URI can use any protocol; it is up to
the server how to interpret it.
@ -916,7 +915,7 @@ class SubscribeRequest(Request[SubscribeRequestParams, Literal["resources/subscr
class UnsubscribeRequestParams(RequestParams):
"""Parameters for unsubscribing from a resource."""
uri: Annotated[AnyUrl, UrlConstraints(host_required=False)]
uri: str
"""The URI of the resource to unsubscribe from."""
model_config = ConfigDict(extra="allow")
@ -934,7 +933,7 @@ class UnsubscribeRequest(Request[UnsubscribeRequestParams, Literal["resources/un
class ResourceUpdatedNotificationParams(NotificationParams):
"""Parameters for resource update notifications."""
uri: Annotated[AnyUrl, UrlConstraints(host_required=False)]
uri: str
"""
The URI of the resource that has been updated. This might be a sub-resource of the
one that the client actually subscribed to.