Skip to content

Conversation

@intellectronica
Copy link
Owner

Overview

This PR updates resource metadata and handling to fully comply with the MCP specification for resources.

Changes

Resource Metadata (MCP Compliance)

  • Changed URI protocol from file:// to resource://
    • Format: resource://skillz/{skill-slug}/{path}
  • Updated metadata structure to match MCP spec:
    • uri: Unique identifier with protocol
    • name: Path without protocol prefix
    • mime_type: Auto-detected MIME type (or None)
    • Removed: description and relative_path fields
  • Added MIME type detection using Python's mimetypes library
  • Content handling: Properly handles UTF-8 text and base64-encoded binary

Resource Collection

  • Excluded SKILL.md from resources: SKILL.md is only returned via the tool invocation's instructions field, not as a separate resource
  • All other files in skill directory and subdirectories remain available as resources

Client-Agnostic Documentation

  • Removed FastMCP-specific references (ctx.read_resource())
  • Updated usage instructions to be portable across any MCP client
  • Clarified when and how to retrieve resources
  • Removed script-specific instructions (clients know what to do with different file types)

Testing

  • Added comprehensive tests for resource metadata compliance
  • Verified MIME type detection
  • Confirmed SKILL.md exclusion
  • All existing tests pass ✓

Commits

  • Update resource metadata to follow MCP specification
  • Format code with ruff
  • Exclude SKILL.md from resources
  • Make usage instructions client-agnostic

intellectronica and others added 9 commits October 25, 2025 11:31
- Change URI protocol from file:// to resource://
- Add MIME type detection using Python's mimetypes library
- Update resource metadata structure:
  - uri: Unique identifier with protocol (resource://skillz/{skill}/{path})
  - name: Path without protocol ({skill}/{path})
  - mime_type: Detected MIME type or None
  - Remove description and relative_path fields
- Ensure UTF-8 text and binary (base64) content handled correctly
- Add comprehensive tests for resource metadata compliance

Follows guidance from:
https://modelcontextprotocol.info/docs/concepts/resources/
SKILL.md should only be returned from the tool invocation, not as
a resource. All other files in the skill directory and subdirectories
are available as resources.

- Updated _collect_resources to exclude SKILL.md
- Updated tests to verify SKILL.md is not in resources
- All other files remain accessible as resources
- Remove FastMCP-specific reference to ctx.read_resource()
- Replace with generic description of retrieving resources from MCP server
- Remove special mention of scripts (clients know what to do with them)
- Clarify that clients should retrieve resources when instructions
  reference additional files and it's appropriate for the task
- Add description of resource metadata fields (uri, name, mime_type)
- Break long line in docstring (line 269)
- Remove unused variable and import in test_resources.py
@intellectronica intellectronica merged commit 156475d into main Oct 25, 2025
1 check passed
@intellectronica intellectronica deleted the feature/improve-resources branch October 25, 2025 10:12
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.

4 participants