Skip to content

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 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
@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 Jul 4, 2025
saqadri pushed a commit to saqadri/stdio-fixes that referenced this pull request Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants