Skip to content

Conversation

@jlowin
Copy link
Owner

@jlowin jlowin commented May 21, 2025

#526 introduced a new resource prefix format. To avoid compatibility issues, this PR allows users to use the legacy format by setting global config

import fastmcp
fastmcp.settings.settings.resource_prefix_format = "protocol" 

or on a per-server basis

from fastmcp import FastMCP

server = FastMCP("LegacyServer", resource_prefix_format="protocol")

The available options are "path" (new default) or "protocol" (legacy behavior).

Copilot AI review requested due to automatic review settings May 21, 2025 16:39
@jlowin jlowin added the enhancement Improvement to existing functionality. For issues and smaller PR improvements. label May 21, 2025
@github-actions github-actions bot added documentation Updates to docs, examples, or guides. Primary change is documentation-related. tests labels May 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR makes the resource prefix format configurable by introducing a new setting and updating resource-related functions and tests to support both legacy (protocol) and new (path) formats.

  • Added a new global setting ("resource_prefix_format") in the settings module with a default of "path".
  • Updated resource handling in the server module to pass the configurable format to prefix utility functions.
  • Enhanced tests and documentation to reflect the new configurable resource prefix behavior.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/server/test_resource_prefix_formats.py Added tests ensuring the resource_prefix_format parameter is correctly applied in usage.
tests/deprecated/test_resource_prefixes.py Added tests verifying legacy resource prefix behavior remains functional under protocol format.
src/fastmcp/settings.py Introduced new setting for resource_prefix_format with appropriate description and default value.
src/fastmcp/server/server.py Modified resource-related functions to accept and forward the resource_prefix_format parameter.
docs/servers/composition.mdx Updated documentation to describe both resource prefix formats and configuration options.
Comments suppressed due to low confidence (1)

src/fastmcp/settings.py:55

  • The word 'perfixing' is misspelled; it should be 'prefixing'.
                When perfixing a resource URI, either use path formatting (resource://prefix/path) or protocol formatting (prefix+resource://path). Protocol formatting was the default in FastMCP < 2.4; path formatting is current default.

@jlowin jlowin merged commit f2325fd into main May 21, 2025
6 checks passed
@jlowin jlowin deleted the backwards-compat-resources branch May 21, 2025 18:57
jordicore pushed a commit to jordicore/fastmcp that referenced this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Updates to docs, examples, or guides. Primary change is documentation-related. enhancement Improvement to existing functionality. For issues and smaller PR improvements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants