mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 23:29:10 +02:00
* Update repository references from jlowin/fastmcp to prefecthq/fastmcp * Retrigger CI after repo transfer * chore: Update SDK documentation * Only run deep triage on bug issues for jlowin --------- Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
54 lines
1.5 KiB
Text
54 lines
1.5 KiB
Text
---
|
|
title: filesystem
|
|
sidebarTitle: filesystem
|
|
---
|
|
|
|
# `fastmcp.server.providers.filesystem`
|
|
|
|
|
|
FileSystemProvider for filesystem-based component discovery.
|
|
|
|
FileSystemProvider scans a directory for Python files, imports them, and
|
|
registers any Tool, Resource, ResourceTemplate, or Prompt objects found.
|
|
|
|
Components are created using the standalone decorators from fastmcp.tools,
|
|
fastmcp.resources, and fastmcp.prompts:
|
|
|
|
Example:
|
|
```python
|
|
# In mcp/tools.py
|
|
from fastmcp.tools import tool
|
|
|
|
@tool
|
|
def greet(name: str) -> str:
|
|
return f"Hello, {name}!"
|
|
|
|
# In main.py
|
|
from pathlib import Path
|
|
|
|
from fastmcp import FastMCP
|
|
from fastmcp.server.providers import FileSystemProvider
|
|
|
|
mcp = FastMCP("MyServer", providers=[FileSystemProvider(Path(__file__).parent / "mcp")])
|
|
```
|
|
|
|
|
|
## Classes
|
|
|
|
### `FileSystemProvider` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/providers/filesystem.py#L47" 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 any Tool, Resource,
|
|
ResourceTemplate, or Prompt objects found. Components are created using
|
|
the standalone decorators:
|
|
- @tool from fastmcp.tools
|
|
- @resource from fastmcp.resources
|
|
- @prompt from fastmcp.prompts
|
|
|
|
**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).
|
|
|