Support Python dependencies in Server #34
Merged
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.
When developing and deploying a server, we want to be able to specify Python dependencies without having to do
--with dep
every time.In earlier versions of FastMCP, it was possible to use uv's [script dependencies] (https://docs.astral.sh/uv/guides/scripts/#declaring-script-dependencies) to declare dependenceis as frontmatter, but since we now use
fastmcp run server.py
instead ofuv run server.py
by default, they don't get parsed.This PR makes the following code possible (which requires pandas) while keeping the install command
fastmcp install demo.py
The README is also updated to clarify that:
fastmcp install
will respect server dependencies when creating an environment for Claude desktopfastmcp dev
will respect server dependencies when creating an environment for the MCP Inspectorfastmcp run
will NOT respect dependencies; it assumes they are already set up. However it does not require a if name == 'main' blockpython run
anduv run
are perfectly valid as long as the user callsmcp.run()
themselves and takes responsibility for all dependencies.