Skip to content

ResourceContents.uri made non-nullable in 1.27.0, breaking servers that return uri=null #2519

@divssheth

Description

@divssheth

Initial Checks

Description

In mcp==1.27.0, ResourceContents.uri was changed from optional to required:
Before (working):

uri: Annotated[AnyUrl, UrlConstraints(host_required=False)] | None = None
After (breaking):
uri: Annotated[AnyUrl, UrlConstraints(host_required=False)]

Impact:

Any MCP server that returns type=resource content items with uri=null (e.g. Azure AI Search knowledge agent) now causes a pydantic_core.ValidationError on every call_tool response. This happens inside send_request → result_type.model_validate(...) before the result even reaches the caller, making every tool call fail silently.
Observed symptom in agent-framework: "Maximum consecutive function call errors reached (3). Stopping further function calls for this request."

Reproduction:

from mcp.types import ResourceContents
# This should be valid per the MCP spec — uri is not always present
ResourceContents(mimeType="text/plain")  # raises ValidationError in 1.27.0

Expected behaviour:

uri should remain optional (| None = None) to maintain compatibility with servers that omit it, as it was in prior releases.

Workaround:
Pin to the wheel of mcp==1.27.0 that still has uri as optional (the regression was introduced in a re-publish of the same version string), or patch types.py locally.

Example Code

Python & MCP Python SDK

Environment:
- mcp==1.27.0
- Python 3.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions