fastmcp/docs/python-sdk/fastmcp-fs-provider.mdx
marvin-context-protocol[bot] 24d500d384
chore: Update SDK documentation (#2761)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2026-01-10 11:49:29 -05:00

111 lines
3.5 KiB
Text

---
title: provider
sidebarTitle: provider
---
# `fastmcp.fs.provider`
FileSystemProvider for filesystem-based component discovery.
FileSystemProvider scans a directory for Python files, imports them, and
registers any functions decorated with @tool, @resource, or @prompt.
Example:
```python
from fastmcp import FastMCP
from fastmcp.fs import FileSystemProvider
mcp = FastMCP("MyServer", providers=[FileSystemProvider("mcp/")])
```
## Classes
### `FileSystemProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/fs/provider.py#L35" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
Provider that discovers components from the filesystem.
Scans a directory for Python files and registers functions decorated
with @tool, @resource, or @prompt from fastmcp.fs.
**Args:**
- `root`: Root directory to scan. Defaults to current directory.
- `reload`: If True, re-scan files on every request (dev mode).
Defaults to False (scan once at init, cache results).
**Methods:**
#### `list_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/fs/provider.py#L220" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
list_tools(self) -> Sequence[Tool]
```
Return all tools, reloading if in reload mode.
#### `get_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/fs/provider.py#L225" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
get_tool(self, name: str) -> Tool | None
```
Get a tool by name, reloading if in reload mode.
#### `list_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/fs/provider.py#L230" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
list_resources(self) -> Sequence[Resource]
```
Return all resources, reloading if in reload mode.
#### `get_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/fs/provider.py#L235" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
get_resource(self, uri: str) -> Resource | None
```
Get a resource by URI, reloading if in reload mode.
#### `list_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/fs/provider.py#L240" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
list_resource_templates(self) -> Sequence[ResourceTemplate]
```
Return all resource templates, reloading if in reload mode.
#### `get_resource_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/fs/provider.py#L245" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
get_resource_template(self, uri: str) -> ResourceTemplate | None
```
Get a resource template, reloading if in reload mode.
#### `list_prompts` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/fs/provider.py#L250" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
list_prompts(self) -> Sequence[Prompt]
```
Return all prompts, reloading if in reload mode.
#### `get_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/fs/provider.py#L255" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
get_prompt(self, name: str) -> Prompt | None
```
Get a prompt by name, reloading if in reload mode.