fix: propagate version to components in FileSystemProvider#3458
Open
martimfasantos wants to merge 1 commit intoPrefectHQ:mainfrom
Open
fix: propagate version to components in FileSystemProvider#3458martimfasantos wants to merge 1 commit intoPrefectHQ:mainfrom
version to components in FileSystemProvider#3458martimfasantos wants to merge 1 commit intoPrefectHQ:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FileSystemProvider.extract_components()infilesystem_discovery.pydoes not passversion=meta.versionwhen constructingTool,Resource,ResourceTemplate, orPromptobjects from decorated functions. This causes all components discovered throughFileSystemProviderto haveversion=None, breaking version-based deduplication (_dedupe_with_versions) and themeta.fastmcp.version/meta.fastmcp.versionsmetadata in the MCP wire output.Problem
When tools are registered using the
@tooldecorator with aversionparameter and discovered viaFileSystemProvider, the version information is silently discarded.Root Cause
In
fastmcp/server/providers/filesystem_discovery.py, theextract_components()function readsToolMeta,ResourceMeta, andPromptMetafrom decorated functions but omits theversionfield when calling*.from_function():The same omission applies to the
ResourceMeta → Resource/ResourceTemplateandPromptMeta → Promptbranches.Comparison with
LocalProviderThe
LocalProviderdecorators correctly pass version:Impact
_meta.fastmcp.versionis always missing — Clients relying ontool.meta["fastmcp"]["version"]getNone_meta.fastmcp.versionsis never populated — The_dedupe_with_versions()function inmcp_operations.pychecksc.version is not Noneto decide whether to inject theversionslist. Since all components haveversion=None, the list is never built.hello_worldv1.0 and v2.0 with different Python function names) are treated as unversioned duplicates, and the deduplication picks one arbitrarily instead of by version ordering.call_toolfails — Clients sending_meta.fastmcp.versionincall_toolrequests won't match specific versions since the server doesn't know tools have versions.Reproduction
Fix
Add
version=meta.versionto all three*.from_function()calls inextract_components():if isinstance(meta, ToolMeta): tool = Tool.from_function( obj, name=meta.name, + version=meta.version, title=meta.title, ... ) elif isinstance(meta, ResourceMeta): ... resource = ResourceTemplate.from_function( fn=obj, + version=meta.version, ... ) ... resource = Resource.from_function( fn=obj, + version=meta.version, ... ) elif isinstance(meta, PromptMeta): prompt = Prompt.from_function( obj, + version=meta.version, ... )Review Checklist