Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

nandsha
Copy link
Contributor

@nandsha nandsha commented Jun 9, 2025

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
Copy link
Member

Kludex commented Jun 11, 2025

We should be testing the examples cc @ihrpr

@Kludex Kludex merged commit f7265f7 into modelcontextprotocol:main Jun 11, 2025
19 of 20 checks passed
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