Skip to content

fix: Use FileUrl on the resources/list call in the simple-resource example - #907

Merged
Kludex merged 1 commit into
modelcontextprotocol:mainfrom
nandsha:fix/simple-resource-url-validation
Jun 11, 2025
Merged

fix: Use FileUrl on the resources/list call in the simple-resource example#907
Kludex merged 1 commit into
modelcontextprotocol:mainfrom
nandsha:fix/simple-resource-url-validation

Conversation

@nandsha

@nandsha nandsha commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

Problem

AnyUrl(f"file:///{name}.txt") fails validation because it requires hosts, but file URLs don't have them.

Solution

Before:

AnyUrl(f"file:///{name}.txt")  

After

FileUrl(f"file:///{name}.txt") 

Use FileUrl for clean file:// URL construction with correct function signature.

Testing

✅ Server works with MCP Inspector
✅ Resources list and read correctly
✅ Pyright passes with 0 errors
✅ All format and lint checks pass

Fixes #892

@nandsha
nandsha force-pushed the fix/simple-resource-url-validation branch from 235ca53 to 6c05a27 Compare June 9, 2025 11:47
@nandsha
nandsha force-pushed the fix/simple-resource-url-validation branch from 6ae96b4 to 9f68c6a Compare June 11, 2025 04:28
Use FileUrl for clean file:// URL construction with proper function signature.

Fixes modelcontextprotocol#892
@nandsha
nandsha force-pushed the fix/simple-resource-url-validation branch from 9f68c6a to 03b762e Compare June 11, 2025 07:20
@nandsha
nandsha marked this pull request as ready for review June 11, 2025 07:30
@Kludex Kludex changed the title Fix file:/// URL validation in simple-resource server Use FileUrl on the resources/list call in the simple-resource example Jun 11, 2025
@Kludex

Kludex commented Jun 11, 2025

Copy link
Copy Markdown
Member

We should be testing the examples cc @ihrpr

@Kludex
Kludex merged commit f7265f7 into modelcontextprotocol:main Jun 11, 2025
@nandsha
nandsha deleted the fix/simple-resource-url-validation branch June 29, 2025 03:30
@nandsha nandsha changed the title Use FileUrl on the resources/list call in the simple-resource example fix: Use FileUrl on the resources/list call in the simple-resource example Jul 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validation error when listing resources in simple-resource server example

2 participants