diff --git a/docs/servers/providers/filesystem.mdx b/docs/servers/providers/filesystem.mdx index 95dba3b3b..353a671d5 100644 --- a/docs/servers/providers/filesystem.mdx +++ b/docs/servers/providers/filesystem.mdx @@ -34,13 +34,13 @@ from pathlib import Path from fastmcp import FastMCP from fastmcp.server.providers import FileSystemProvider -mcp = FastMCP("MyServer", providers=[FileSystemProvider(Path(__file__).parent / "mcp")]) +mcp = FastMCP("MyServer", providers=[FileSystemProvider(Path(__file__).parent / "components")]) ``` -In your `mcp/` directory, create Python files with decorated functions. +In your `components/` directory, create Python files with decorated functions. ```python -# mcp/tools/greet.py +# components/tools/greet.py from fastmcp.tools import tool @tool @@ -139,7 +139,7 @@ The decorator supports: `name`, `title`, `description`, `icons`, `tags`, and `me The directory structure is purely organizational. The provider recursively scans all `.py` files regardless of which subdirectory they're in. Subdirectories like `tools/`, `resources/`, and `prompts/` are optional conventions that help you organize code. ``` -mcp/ +components/ ├── tools/ │ ├── greeting.py # @tool functions │ └── calculator.py # @tool functions @@ -152,7 +152,7 @@ mcp/ You can also put all components in a single file or organize by feature rather than type. ``` -mcp/ +components/ ├── user_management.py # @tool, @resource, @prompt for users ├── billing.py # @tool, @resource for billing └── analytics.py # @tool for analytics @@ -176,9 +176,9 @@ The provider follows these rules when scanning: If your directory contains an `__init__.py` file, the provider imports files as proper Python package members. This means relative imports work correctly within your components directory. ```python -# mcp/__init__.py exists +# components/__init__.py exists -# mcp/tools/greeting.py +# components/tools/greeting.py from ..helpers import format_name # Relative imports work @tool @@ -197,7 +197,7 @@ from pathlib import Path from fastmcp.server.providers import FileSystemProvider -provider = FileSystemProvider(Path(__file__).parent / "mcp", reload=True) +provider = FileSystemProvider(Path(__file__).parent / "components", reload=True) ``` With `reload=True`, the provider: @@ -227,7 +227,7 @@ A complete example is available in the repository at `examples/filesystem-provid ``` examples/filesystem-provider/ ├── server.py # Server entry point -└── mcp/ +└── components/ ├── tools/ │ ├── greeting.py # greet, farewell tools │ └── calculator.py # add, multiply tools @@ -246,7 +246,7 @@ from fastmcp import FastMCP from fastmcp.server.providers import FileSystemProvider provider = FileSystemProvider( - root=Path(__file__).parent / "mcp", + root=Path(__file__).parent / "components", reload=True, ) diff --git a/examples/filesystem-provider/mcp/prompts/assistant.py b/examples/filesystem-provider/components/prompts/assistant.py similarity index 100% rename from examples/filesystem-provider/mcp/prompts/assistant.py rename to examples/filesystem-provider/components/prompts/assistant.py diff --git a/examples/filesystem-provider/mcp/resources/config.py b/examples/filesystem-provider/components/resources/config.py similarity index 100% rename from examples/filesystem-provider/mcp/resources/config.py rename to examples/filesystem-provider/components/resources/config.py diff --git a/examples/filesystem-provider/mcp/tools/calculator.py b/examples/filesystem-provider/components/tools/calculator.py similarity index 100% rename from examples/filesystem-provider/mcp/tools/calculator.py rename to examples/filesystem-provider/components/tools/calculator.py diff --git a/examples/filesystem-provider/mcp/tools/greeting.py b/examples/filesystem-provider/components/tools/greeting.py similarity index 100% rename from examples/filesystem-provider/mcp/tools/greeting.py rename to examples/filesystem-provider/components/tools/greeting.py diff --git a/examples/filesystem-provider/server.py b/examples/filesystem-provider/server.py index 2f3cf47a6..11bbf7f81 100644 --- a/examples/filesystem-provider/server.py +++ b/examples/filesystem-provider/server.py @@ -22,7 +22,7 @@ from fastmcp.server.providers import FileSystemProvider # Functions decorated with @tool, @resource, or @prompt are registered. # Directory structure is purely organizational - decorators determine type. provider = FileSystemProvider( - root=Path(__file__).parent / "mcp", + root=Path(__file__).parent / "components", reload=True, # Set True for dev mode (re-scan on every request) )