Spaces:
Running
Running
Jeremiah Lowin nate nowack commited on
Update static checks (#1448)
Browse filesCo-authored-by: nate nowack <thrast36@gmail.com>
- .github/workflows/run-static.yml +22 -0
- .github/workflows/run-tests.yml +4 -2
- docs/docs.json +19 -5
- docs/python-sdk/fastmcp-cli-run.mdx +14 -14
- docs/python-sdk/fastmcp-client-logging.mdx +5 -1
- docs/python-sdk/fastmcp-client-transports.mdx +26 -26
- docs/python-sdk/fastmcp-resources-resource_manager.mdx +12 -12
- docs/python-sdk/fastmcp-server-auth-auth.mdx +76 -25
- docs/python-sdk/fastmcp-server-auth-providers-bearer_env.mdx +0 -22
- docs/python-sdk/fastmcp-server-auth-providers-jwt.mdx +11 -11
- docs/python-sdk/fastmcp-server-auth-providers-workos.mdx +9 -19
- docs/python-sdk/fastmcp-server-dependencies.mdx +16 -3
- docs/python-sdk/fastmcp-server-http.mdx +14 -24
- docs/python-sdk/fastmcp-server-proxy.mdx +42 -36
- docs/python-sdk/fastmcp-server-server.mdx +53 -47
- docs/python-sdk/fastmcp-tools-tool.mdx +13 -13
- docs/python-sdk/fastmcp-tools-tool_manager.mdx +11 -11
- docs/python-sdk/fastmcp-tools-tool_transform.mdx +12 -12
- docs/python-sdk/fastmcp-utilities-components.mdx +17 -9
- docs/python-sdk/fastmcp-utilities-inspect.mdx +10 -10
- docs/python-sdk/fastmcp-utilities-openapi.mdx +13 -13
- docs/python-sdk/fastmcp-utilities-types.mdx +10 -10
- justfile +0 -1
- src/fastmcp/server/auth/providers/jwt.py +0 -2
.github/workflows/run-static.yml
CHANGED
|
@@ -42,7 +42,29 @@ jobs:
|
|
| 42 |
python-version: "3.12"
|
| 43 |
- name: Install dependencies
|
| 44 |
run: uv sync --dev
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
- name: Run pre-commit
|
| 46 |
uses: pre-commit/action@v3.0.1
|
| 47 |
env:
|
| 48 |
SKIP: no-commit-to-branch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
python-version: "3.12"
|
| 43 |
- name: Install dependencies
|
| 44 |
run: uv sync --dev
|
| 45 |
+
- name: Install just
|
| 46 |
+
uses: extractions/setup-just@v3
|
| 47 |
+
- name: Check lockfile is up to date
|
| 48 |
+
run: |
|
| 49 |
+
if ! uv lock --check; then
|
| 50 |
+
echo "❌ Lockfile is out of date!"
|
| 51 |
+
echo "To update the lockfile, run 'uv lock'."
|
| 52 |
+
exit 1
|
| 53 |
+
fi
|
| 54 |
+
echo "✅ Lockfile is up to date"
|
| 55 |
- name: Run pre-commit
|
| 56 |
uses: pre-commit/action@v3.0.1
|
| 57 |
env:
|
| 58 |
SKIP: no-commit-to-branch
|
| 59 |
+
- name: Check SDK documentation is up to date
|
| 60 |
+
run: |
|
| 61 |
+
just api-ref-all > /dev/null 2>&1
|
| 62 |
+
if ! git diff --quiet docs/python-sdk/ docs/docs.json; then
|
| 63 |
+
echo "❌ SDK documentation is out of date!"
|
| 64 |
+
echo "Files that were updated:"
|
| 65 |
+
git diff --name-only docs/python-sdk/ docs/docs.json
|
| 66 |
+
echo ""
|
| 67 |
+
echo "Run 'just api-ref-all' and commit the changes."
|
| 68 |
+
exit 1
|
| 69 |
+
fi
|
| 70 |
+
echo "✅ SDK documentation is up to date"
|
.github/workflows/run-tests.yml
CHANGED
|
@@ -44,7 +44,8 @@ jobs:
|
|
| 44 |
python-version: ${{ matrix.python-version }}
|
| 45 |
|
| 46 |
- name: Install FastMCP
|
| 47 |
-
run
|
|
|
|
| 48 |
|
| 49 |
- name: Run tests (excluding integration and client_process)
|
| 50 |
run: uv run pytest tests -m "not integration and not client_process"
|
|
@@ -68,7 +69,8 @@ jobs:
|
|
| 68 |
python-version: "3.10"
|
| 69 |
|
| 70 |
- name: Install FastMCP
|
| 71 |
-
run
|
|
|
|
| 72 |
|
| 73 |
- name: Run integration tests
|
| 74 |
run: uv run pytest tests -m "integration"
|
|
|
|
| 44 |
python-version: ${{ matrix.python-version }}
|
| 45 |
|
| 46 |
- name: Install FastMCP
|
| 47 |
+
# run with frozen to use the current lockfile; static checks will determine if it needs updating
|
| 48 |
+
run: uv sync --frozen
|
| 49 |
|
| 50 |
- name: Run tests (excluding integration and client_process)
|
| 51 |
run: uv run pytest tests -m "not integration and not client_process"
|
|
|
|
| 69 |
python-version: "3.10"
|
| 70 |
|
| 71 |
- name: Install FastMCP
|
| 72 |
+
# run with frozen to use the current lockfile; static checks will determine if it needs updating
|
| 73 |
+
run: uv sync --frozen
|
| 74 |
|
| 75 |
- name: Run integration tests
|
| 76 |
run: uv run pytest tests -m "integration"
|
docs/docs.json
CHANGED
|
@@ -65,7 +65,10 @@
|
|
| 65 |
{
|
| 66 |
"group": "Essentials",
|
| 67 |
"icon": "cube",
|
| 68 |
-
"pages": [
|
|
|
|
|
|
|
|
|
|
| 69 |
},
|
| 70 |
{
|
| 71 |
"group": "Core Components",
|
|
@@ -108,7 +111,10 @@
|
|
| 108 |
{
|
| 109 |
"group": "Essentials",
|
| 110 |
"icon": "cube",
|
| 111 |
-
"pages": [
|
|
|
|
|
|
|
|
|
|
| 112 |
},
|
| 113 |
{
|
| 114 |
"group": "Core Operations",
|
|
@@ -134,7 +140,10 @@
|
|
| 134 |
{
|
| 135 |
"group": "Authentication",
|
| 136 |
"icon": "user-shield",
|
| 137 |
-
"pages": [
|
|
|
|
|
|
|
|
|
|
| 138 |
}
|
| 139 |
]
|
| 140 |
},
|
|
@@ -180,12 +189,17 @@
|
|
| 180 |
},
|
| 181 |
{
|
| 182 |
"anchor": "What's New",
|
| 183 |
-
"pages": [
|
|
|
|
|
|
|
|
|
|
| 184 |
},
|
| 185 |
{
|
| 186 |
"anchor": "Community",
|
| 187 |
"icon": "users",
|
| 188 |
-
"pages": [
|
|
|
|
|
|
|
| 189 |
}
|
| 190 |
]
|
| 191 |
},
|
|
|
|
| 65 |
{
|
| 66 |
"group": "Essentials",
|
| 67 |
"icon": "cube",
|
| 68 |
+
"pages": [
|
| 69 |
+
"servers/server",
|
| 70 |
+
"deployment/running-server"
|
| 71 |
+
]
|
| 72 |
},
|
| 73 |
{
|
| 74 |
"group": "Core Components",
|
|
|
|
| 111 |
{
|
| 112 |
"group": "Essentials",
|
| 113 |
"icon": "cube",
|
| 114 |
+
"pages": [
|
| 115 |
+
"clients/client",
|
| 116 |
+
"clients/transports"
|
| 117 |
+
]
|
| 118 |
},
|
| 119 |
{
|
| 120 |
"group": "Core Operations",
|
|
|
|
| 140 |
{
|
| 141 |
"group": "Authentication",
|
| 142 |
"icon": "user-shield",
|
| 143 |
+
"pages": [
|
| 144 |
+
"clients/auth/oauth",
|
| 145 |
+
"clients/auth/bearer"
|
| 146 |
+
]
|
| 147 |
}
|
| 148 |
]
|
| 149 |
},
|
|
|
|
| 189 |
},
|
| 190 |
{
|
| 191 |
"anchor": "What's New",
|
| 192 |
+
"pages": [
|
| 193 |
+
"updates",
|
| 194 |
+
"changelog"
|
| 195 |
+
]
|
| 196 |
},
|
| 197 |
{
|
| 198 |
"anchor": "Community",
|
| 199 |
"icon": "users",
|
| 200 |
+
"pages": [
|
| 201 |
+
"community/showcase"
|
| 202 |
+
]
|
| 203 |
}
|
| 204 |
]
|
| 205 |
},
|
docs/python-sdk/fastmcp-cli-run.mdx
CHANGED
|
@@ -10,7 +10,7 @@ FastMCP run command implementation with enhanced type hints.
|
|
| 10 |
|
| 11 |
## Functions
|
| 12 |
|
| 13 |
-
### `is_url` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#
|
| 14 |
|
| 15 |
```python
|
| 16 |
is_url(path: str) -> bool
|
|
@@ -20,7 +20,7 @@ is_url(path: str) -> bool
|
|
| 20 |
Check if a string is a URL.
|
| 21 |
|
| 22 |
|
| 23 |
-
### `parse_file_path` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#
|
| 24 |
|
| 25 |
```python
|
| 26 |
parse_file_path(server_spec: str) -> tuple[Path, str | None]
|
|
@@ -36,10 +36,10 @@ Parse a file path that may include a server object specification.
|
|
| 36 |
- Tuple of (file_path, server_object)
|
| 37 |
|
| 38 |
|
| 39 |
-
### `import_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#
|
| 40 |
|
| 41 |
```python
|
| 42 |
-
import_server(file: Path,
|
| 43 |
```
|
| 44 |
|
| 45 |
|
|
@@ -47,13 +47,13 @@ Import a MCP server from a file.
|
|
| 47 |
|
| 48 |
**Args:**
|
| 49 |
- `file`: Path to the file
|
| 50 |
-
- `
|
| 51 |
|
| 52 |
**Returns:**
|
| 53 |
-
- The server object
|
| 54 |
|
| 55 |
|
| 56 |
-
### `run_with_uv` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#
|
| 57 |
|
| 58 |
```python
|
| 59 |
run_with_uv(server_spec: str, python_version: str | None = None, with_packages: list[str] | None = None, with_requirements: Path | None = None, project: Path | None = None, transport: TransportType | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: LogLevelType | None = None, show_banner: bool = True) -> None
|
|
@@ -76,7 +76,7 @@ Run a MCP server using uv run subprocess.
|
|
| 76 |
- `show_banner`: Whether to show the server banner
|
| 77 |
|
| 78 |
|
| 79 |
-
### `create_client_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#
|
| 80 |
|
| 81 |
```python
|
| 82 |
create_client_server(url: str) -> Any
|
|
@@ -92,7 +92,7 @@ Create a FastMCP server from a client URL.
|
|
| 92 |
- A FastMCP server instance
|
| 93 |
|
| 94 |
|
| 95 |
-
### `create_mcp_config_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#
|
| 96 |
|
| 97 |
```python
|
| 98 |
create_mcp_config_server(mcp_config_path: Path) -> FastMCP[None]
|
|
@@ -102,10 +102,10 @@ create_mcp_config_server(mcp_config_path: Path) -> FastMCP[None]
|
|
| 102 |
Create a FastMCP server from a MCPConfig.
|
| 103 |
|
| 104 |
|
| 105 |
-
### `import_server_with_args` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#
|
| 106 |
|
| 107 |
```python
|
| 108 |
-
import_server_with_args(file: Path,
|
| 109 |
```
|
| 110 |
|
| 111 |
|
|
@@ -113,14 +113,14 @@ Import a server with optional command line arguments.
|
|
| 113 |
|
| 114 |
**Args:**
|
| 115 |
- `file`: Path to the server file
|
| 116 |
-
- `
|
| 117 |
- `server_args`: Optional command line arguments to inject
|
| 118 |
|
| 119 |
**Returns:**
|
| 120 |
- The imported server object
|
| 121 |
|
| 122 |
|
| 123 |
-
### `run_command` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#
|
| 124 |
|
| 125 |
```python
|
| 126 |
run_command(server_spec: str, transport: TransportType | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: LogLevelType | None = None, server_args: list[str] | None = None, show_banner: bool = True, use_direct_import: bool = False) -> None
|
|
@@ -141,7 +141,7 @@ Run a MCP server or connect to a remote one.
|
|
| 141 |
- `use_direct_import`: Whether to use direct import instead of subprocess
|
| 142 |
|
| 143 |
|
| 144 |
-
### `run_v1_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#
|
| 145 |
|
| 146 |
```python
|
| 147 |
run_v1_server(server: FastMCP1x, host: str | None = None, port: int | None = None, transport: TransportType | None = None) -> None
|
|
|
|
| 10 |
|
| 11 |
## Functions
|
| 12 |
|
| 13 |
+
### `is_url` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L25" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 14 |
|
| 15 |
```python
|
| 16 |
is_url(path: str) -> bool
|
|
|
|
| 20 |
Check if a string is a URL.
|
| 21 |
|
| 22 |
|
| 23 |
+
### `parse_file_path` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L31" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 24 |
|
| 25 |
```python
|
| 26 |
parse_file_path(server_spec: str) -> tuple[Path, str | None]
|
|
|
|
| 36 |
- Tuple of (file_path, server_object)
|
| 37 |
|
| 38 |
|
| 39 |
+
### `import_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L62" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 40 |
|
| 41 |
```python
|
| 42 |
+
import_server(file: Path, server_or_factory: str | None = None) -> Any
|
| 43 |
```
|
| 44 |
|
| 45 |
|
|
|
|
| 47 |
|
| 48 |
**Args:**
|
| 49 |
- `file`: Path to the file
|
| 50 |
+
- `server_or_factory`: Optional object name in format "module\:object" or just "object"
|
| 51 |
|
| 52 |
**Returns:**
|
| 53 |
+
- The server object (or result of calling a factory function)
|
| 54 |
|
| 55 |
|
| 56 |
+
### `run_with_uv` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L179" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 57 |
|
| 58 |
```python
|
| 59 |
run_with_uv(server_spec: str, python_version: str | None = None, with_packages: list[str] | None = None, with_requirements: Path | None = None, project: Path | None = None, transport: TransportType | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: LogLevelType | None = None, show_banner: bool = True) -> None
|
|
|
|
| 76 |
- `show_banner`: Whether to show the server banner
|
| 77 |
|
| 78 |
|
| 79 |
+
### `create_client_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L257" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 80 |
|
| 81 |
```python
|
| 82 |
create_client_server(url: str) -> Any
|
|
|
|
| 92 |
- A FastMCP server instance
|
| 93 |
|
| 94 |
|
| 95 |
+
### `create_mcp_config_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L277" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 96 |
|
| 97 |
```python
|
| 98 |
create_mcp_config_server(mcp_config_path: Path) -> FastMCP[None]
|
|
|
|
| 102 |
Create a FastMCP server from a MCPConfig.
|
| 103 |
|
| 104 |
|
| 105 |
+
### `import_server_with_args` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L288" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 106 |
|
| 107 |
```python
|
| 108 |
+
import_server_with_args(file: Path, server_or_factory: str | None = None, server_args: list[str] | None = None) -> Any
|
| 109 |
```
|
| 110 |
|
| 111 |
|
|
|
|
| 113 |
|
| 114 |
**Args:**
|
| 115 |
- `file`: Path to the server file
|
| 116 |
+
- `server_or_factory`: Optional server object or factory function name
|
| 117 |
- `server_args`: Optional command line arguments to inject
|
| 118 |
|
| 119 |
**Returns:**
|
| 120 |
- The imported server object
|
| 121 |
|
| 122 |
|
| 123 |
+
### `run_command` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L314" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 124 |
|
| 125 |
```python
|
| 126 |
run_command(server_spec: str, transport: TransportType | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: LogLevelType | None = None, server_args: list[str] | None = None, show_banner: bool = True, use_direct_import: bool = False) -> None
|
|
|
|
| 141 |
- `use_direct_import`: Whether to use direct import instead of subprocess
|
| 142 |
|
| 143 |
|
| 144 |
+
### `run_v1_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L379" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 145 |
|
| 146 |
```python
|
| 147 |
run_v1_server(server: FastMCP1x, host: str | None = None, port: int | None = None, transport: TransportType | None = None) -> None
|
docs/python-sdk/fastmcp-client-logging.mdx
CHANGED
|
@@ -13,7 +13,11 @@ sidebarTitle: logging
|
|
| 13 |
default_log_handler(message: LogMessage) -> None
|
| 14 |
```
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
```python
|
| 19 |
create_log_callback(handler: LogHandler | None = None) -> LoggingFnT
|
|
|
|
| 13 |
default_log_handler(message: LogMessage) -> None
|
| 14 |
```
|
| 15 |
|
| 16 |
+
|
| 17 |
+
Default handler that properly routes server log messages to appropriate log levels.
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
### `create_log_callback` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/logging.py#L43" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 21 |
|
| 22 |
```python
|
| 23 |
create_log_callback(handler: LogHandler | None = None) -> LoggingFnT
|
docs/python-sdk/fastmcp-client-transports.mdx
CHANGED
|
@@ -7,7 +7,7 @@ sidebarTitle: transports
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
-
### `infer_transport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 11 |
|
| 12 |
```python
|
| 13 |
infer_transport(transport: ClientTransport | FastMCP | FastMCP1Server | AnyUrl | Path | MCPConfig | dict[str, Any] | str) -> ClientTransport
|
|
@@ -57,13 +57,13 @@ transport = infer_transport(config)
|
|
| 57 |
|
| 58 |
## Classes
|
| 59 |
|
| 60 |
-
### `SessionKwargs` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 61 |
|
| 62 |
|
| 63 |
Keyword arguments for the MCP ClientSession constructor.
|
| 64 |
|
| 65 |
|
| 66 |
-
### `ClientTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 67 |
|
| 68 |
|
| 69 |
Abstract base class for different MCP client transport mechanisms.
|
|
@@ -74,7 +74,7 @@ to an MCP server, and providing a ClientSession within an async context.
|
|
| 74 |
|
| 75 |
**Methods:**
|
| 76 |
|
| 77 |
-
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 78 |
|
| 79 |
```python
|
| 80 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
|
@@ -93,7 +93,7 @@ within this context.
|
|
| 93 |
constructor (e.g., callbacks, timeouts).
|
| 94 |
|
| 95 |
|
| 96 |
-
#### `close` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 97 |
|
| 98 |
```python
|
| 99 |
close(self)
|
|
@@ -102,7 +102,7 @@ close(self)
|
|
| 102 |
Close the transport.
|
| 103 |
|
| 104 |
|
| 105 |
-
### `WSTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 106 |
|
| 107 |
|
| 108 |
Transport implementation that connects to an MCP server via WebSockets.
|
|
@@ -110,13 +110,13 @@ Transport implementation that connects to an MCP server via WebSockets.
|
|
| 110 |
|
| 111 |
**Methods:**
|
| 112 |
|
| 113 |
-
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 114 |
|
| 115 |
```python
|
| 116 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
| 117 |
```
|
| 118 |
|
| 119 |
-
### `SSETransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 120 |
|
| 121 |
|
| 122 |
Transport implementation that connects to an MCP server via Server-Sent Events.
|
|
@@ -124,13 +124,13 @@ Transport implementation that connects to an MCP server via Server-Sent Events.
|
|
| 124 |
|
| 125 |
**Methods:**
|
| 126 |
|
| 127 |
-
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 128 |
|
| 129 |
```python
|
| 130 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
| 131 |
```
|
| 132 |
|
| 133 |
-
### `StreamableHttpTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 134 |
|
| 135 |
|
| 136 |
Transport implementation that connects to an MCP server via Streamable HTTP Requests.
|
|
@@ -138,13 +138,13 @@ Transport implementation that connects to an MCP server via Streamable HTTP Requ
|
|
| 138 |
|
| 139 |
**Methods:**
|
| 140 |
|
| 141 |
-
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 142 |
|
| 143 |
```python
|
| 144 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
| 145 |
```
|
| 146 |
|
| 147 |
-
### `StdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 148 |
|
| 149 |
|
| 150 |
Base transport for connecting to an MCP server via subprocess with stdio.
|
|
@@ -155,67 +155,67 @@ transports like Python, Node, Uvx, etc.
|
|
| 155 |
|
| 156 |
**Methods:**
|
| 157 |
|
| 158 |
-
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 159 |
|
| 160 |
```python
|
| 161 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
| 162 |
```
|
| 163 |
|
| 164 |
-
#### `connect` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 165 |
|
| 166 |
```python
|
| 167 |
connect(self, **session_kwargs: Unpack[SessionKwargs]) -> ClientSession | None
|
| 168 |
```
|
| 169 |
|
| 170 |
-
#### `disconnect` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 171 |
|
| 172 |
```python
|
| 173 |
disconnect(self)
|
| 174 |
```
|
| 175 |
|
| 176 |
-
#### `close` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 177 |
|
| 178 |
```python
|
| 179 |
close(self)
|
| 180 |
```
|
| 181 |
|
| 182 |
-
### `PythonStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 183 |
|
| 184 |
|
| 185 |
Transport for running Python scripts.
|
| 186 |
|
| 187 |
|
| 188 |
-
### `FastMCPStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 189 |
|
| 190 |
|
| 191 |
Transport for running FastMCP servers using the FastMCP CLI.
|
| 192 |
|
| 193 |
|
| 194 |
-
### `NodeStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 195 |
|
| 196 |
|
| 197 |
Transport for running Node.js scripts.
|
| 198 |
|
| 199 |
|
| 200 |
-
### `UvStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 201 |
|
| 202 |
|
| 203 |
Transport for running commands via the uv tool.
|
| 204 |
|
| 205 |
|
| 206 |
-
### `UvxStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 207 |
|
| 208 |
|
| 209 |
Transport for running commands via the uvx tool.
|
| 210 |
|
| 211 |
|
| 212 |
-
### `NpxStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 213 |
|
| 214 |
|
| 215 |
Transport for running commands via the npx tool.
|
| 216 |
|
| 217 |
|
| 218 |
-
### `FastMCPTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 219 |
|
| 220 |
|
| 221 |
In-memory transport for FastMCP servers.
|
|
@@ -228,13 +228,13 @@ tests or scenarios where client and server run in the same runtime.
|
|
| 228 |
|
| 229 |
**Methods:**
|
| 230 |
|
| 231 |
-
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 232 |
|
| 233 |
```python
|
| 234 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
| 235 |
```
|
| 236 |
|
| 237 |
-
### `MCPConfigTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 238 |
|
| 239 |
|
| 240 |
Transport for connecting to one or more MCP servers defined in an MCPConfig.
|
|
@@ -287,7 +287,7 @@ async with client:
|
|
| 287 |
|
| 288 |
**Methods:**
|
| 289 |
|
| 290 |
-
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#
|
| 291 |
|
| 292 |
```python
|
| 293 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
|
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
+
### `infer_transport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L904" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 11 |
|
| 12 |
```python
|
| 13 |
infer_transport(transport: ClientTransport | FastMCP | FastMCP1Server | AnyUrl | Path | MCPConfig | dict[str, Any] | str) -> ClientTransport
|
|
|
|
| 57 |
|
| 58 |
## Classes
|
| 59 |
|
| 60 |
+
### `SessionKwargs` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L59" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 61 |
|
| 62 |
|
| 63 |
Keyword arguments for the MCP ClientSession constructor.
|
| 64 |
|
| 65 |
|
| 66 |
+
### `ClientTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L71" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 67 |
|
| 68 |
|
| 69 |
Abstract base class for different MCP client transport mechanisms.
|
|
|
|
| 74 |
|
| 75 |
**Methods:**
|
| 76 |
|
| 77 |
+
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L82" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 78 |
|
| 79 |
```python
|
| 80 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
|
|
|
| 93 |
constructor (e.g., callbacks, timeouts).
|
| 94 |
|
| 95 |
|
| 96 |
+
#### `close` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L108" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 97 |
|
| 98 |
```python
|
| 99 |
close(self)
|
|
|
|
| 102 |
Close the transport.
|
| 103 |
|
| 104 |
|
| 105 |
+
### `WSTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L117" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 106 |
|
| 107 |
|
| 108 |
Transport implementation that connects to an MCP server via WebSockets.
|
|
|
|
| 110 |
|
| 111 |
**Methods:**
|
| 112 |
|
| 113 |
+
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L135" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 114 |
|
| 115 |
```python
|
| 116 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
| 117 |
```
|
| 118 |
|
| 119 |
+
### `SSETransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L156" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 120 |
|
| 121 |
|
| 122 |
Transport implementation that connects to an MCP server via Server-Sent Events.
|
|
|
|
| 124 |
|
| 125 |
**Methods:**
|
| 126 |
|
| 127 |
+
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L192" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 128 |
|
| 129 |
```python
|
| 130 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
| 131 |
```
|
| 132 |
|
| 133 |
+
### `StreamableHttpTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L228" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 134 |
|
| 135 |
|
| 136 |
Transport implementation that connects to an MCP server via Streamable HTTP Requests.
|
|
|
|
| 138 |
|
| 139 |
**Methods:**
|
| 140 |
|
| 141 |
+
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L264" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 142 |
|
| 143 |
```python
|
| 144 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
| 145 |
```
|
| 146 |
|
| 147 |
+
### `StdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L301" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 148 |
|
| 149 |
|
| 150 |
Base transport for connecting to an MCP server via subprocess with stdio.
|
|
|
|
| 155 |
|
| 156 |
**Methods:**
|
| 157 |
|
| 158 |
+
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L344" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 159 |
|
| 160 |
```python
|
| 161 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
| 162 |
```
|
| 163 |
|
| 164 |
+
#### `connect` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L357" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 165 |
|
| 166 |
```python
|
| 167 |
connect(self, **session_kwargs: Unpack[SessionKwargs]) -> ClientSession | None
|
| 168 |
```
|
| 169 |
|
| 170 |
+
#### `disconnect` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L408" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 171 |
|
| 172 |
```python
|
| 173 |
disconnect(self)
|
| 174 |
```
|
| 175 |
|
| 176 |
+
#### `close` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L423" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 177 |
|
| 178 |
```python
|
| 179 |
close(self)
|
| 180 |
```
|
| 181 |
|
| 182 |
+
### `PythonStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L432" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 183 |
|
| 184 |
|
| 185 |
Transport for running Python scripts.
|
| 186 |
|
| 187 |
|
| 188 |
+
### `FastMCPStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L478" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 189 |
|
| 190 |
|
| 191 |
Transport for running FastMCP servers using the FastMCP CLI.
|
| 192 |
|
| 193 |
|
| 194 |
+
### `NodeStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L505" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 195 |
|
| 196 |
|
| 197 |
Transport for running Node.js scripts.
|
| 198 |
|
| 199 |
|
| 200 |
+
### `UvStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L547" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 201 |
|
| 202 |
|
| 203 |
Transport for running commands via the uv tool.
|
| 204 |
|
| 205 |
|
| 206 |
+
### `UvxStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L604" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 207 |
|
| 208 |
|
| 209 |
Transport for running commands via the uvx tool.
|
| 210 |
|
| 211 |
|
| 212 |
+
### `NpxStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L668" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 213 |
|
| 214 |
|
| 215 |
Transport for running commands via the npx tool.
|
| 216 |
|
| 217 |
|
| 218 |
+
### `FastMCPTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L730" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 219 |
|
| 220 |
|
| 221 |
In-memory transport for FastMCP servers.
|
|
|
|
| 228 |
|
| 229 |
**Methods:**
|
| 230 |
|
| 231 |
+
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L749" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 232 |
|
| 233 |
```python
|
| 234 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
| 235 |
```
|
| 236 |
|
| 237 |
+
### `MCPConfigTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L784" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 238 |
|
| 239 |
|
| 240 |
Transport for connecting to one or more MCP servers defined in an MCPConfig.
|
|
|
|
| 287 |
|
| 288 |
**Methods:**
|
| 289 |
|
| 290 |
+
#### `connect_session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L856" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 291 |
|
| 292 |
```python
|
| 293 |
connect_session(self, **session_kwargs: Unpack[SessionKwargs]) -> AsyncIterator[ClientSession]
|
docs/python-sdk/fastmcp-resources-resource_manager.mdx
CHANGED
|
@@ -45,7 +45,7 @@ get_resource_templates(self) -> dict[str, ResourceTemplate]
|
|
| 45 |
Get all registered templates, keyed by URI template.
|
| 46 |
|
| 47 |
|
| 48 |
-
#### `list_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#
|
| 49 |
|
| 50 |
```python
|
| 51 |
list_resources(self) -> list[Resource]
|
|
@@ -54,7 +54,7 @@ list_resources(self) -> list[Resource]
|
|
| 54 |
Lists all resources, applying protocol filtering.
|
| 55 |
|
| 56 |
|
| 57 |
-
#### `list_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#
|
| 58 |
|
| 59 |
```python
|
| 60 |
list_resource_templates(self) -> list[ResourceTemplate]
|
|
@@ -63,7 +63,7 @@ list_resource_templates(self) -> list[ResourceTemplate]
|
|
| 63 |
Lists all templates, applying protocol filtering.
|
| 64 |
|
| 65 |
|
| 66 |
-
#### `add_resource_or_template_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#
|
| 67 |
|
| 68 |
```python
|
| 69 |
add_resource_or_template_from_fn(self, fn: Callable[..., Any], uri: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> Resource | ResourceTemplate
|
|
@@ -84,7 +84,7 @@ Add a resource or template to the manager from a function.
|
|
| 84 |
- returns the existing resource or template.
|
| 85 |
|
| 86 |
|
| 87 |
-
#### `add_resource_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#
|
| 88 |
|
| 89 |
```python
|
| 90 |
add_resource_from_fn(self, fn: Callable[..., Any], uri: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> Resource
|
|
@@ -105,7 +105,7 @@ Add a resource to the manager from a function.
|
|
| 105 |
- returns the existing resource.
|
| 106 |
|
| 107 |
|
| 108 |
-
#### `add_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#
|
| 109 |
|
| 110 |
```python
|
| 111 |
add_resource(self, resource: Resource) -> Resource
|
|
@@ -116,10 +116,10 @@ Add a resource to the manager.
|
|
| 116 |
**Args:**
|
| 117 |
- `resource`: A Resource instance to add. The resource's .key attribute
|
| 118 |
will be used as the storage key. To overwrite it, call
|
| 119 |
-
Resource.
|
| 120 |
|
| 121 |
|
| 122 |
-
#### `add_template_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#
|
| 123 |
|
| 124 |
```python
|
| 125 |
add_template_from_fn(self, fn: Callable[..., Any], uri_template: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> ResourceTemplate
|
|
@@ -128,7 +128,7 @@ add_template_from_fn(self, fn: Callable[..., Any], uri_template: str, name: str
|
|
| 128 |
Create a template from a function.
|
| 129 |
|
| 130 |
|
| 131 |
-
#### `add_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#
|
| 132 |
|
| 133 |
```python
|
| 134 |
add_template(self, template: ResourceTemplate) -> ResourceTemplate
|
|
@@ -139,14 +139,14 @@ Add a template to the manager.
|
|
| 139 |
**Args:**
|
| 140 |
- `template`: A ResourceTemplate instance to add. The template's .key attribute
|
| 141 |
will be used as the storage key. To overwrite it, call
|
| 142 |
-
ResourceTemplate.
|
| 143 |
|
| 144 |
**Returns:**
|
| 145 |
- The added template. If a template with the same URI already exists,
|
| 146 |
- returns the existing template.
|
| 147 |
|
| 148 |
|
| 149 |
-
#### `has_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#
|
| 150 |
|
| 151 |
```python
|
| 152 |
has_resource(self, uri: AnyUrl | str) -> bool
|
|
@@ -155,7 +155,7 @@ has_resource(self, uri: AnyUrl | str) -> bool
|
|
| 155 |
Check if a resource exists.
|
| 156 |
|
| 157 |
|
| 158 |
-
#### `get_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#
|
| 159 |
|
| 160 |
```python
|
| 161 |
get_resource(self, uri: AnyUrl | str) -> Resource
|
|
@@ -170,7 +170,7 @@ Get resource by URI, checking concrete resources first, then templates.
|
|
| 170 |
- `NotFoundError`: If no resource or template matching the URI is found.
|
| 171 |
|
| 172 |
|
| 173 |
-
#### `read_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#
|
| 174 |
|
| 175 |
```python
|
| 176 |
read_resource(self, uri: AnyUrl | str) -> str | bytes
|
|
|
|
| 45 |
Get all registered templates, keyed by URI template.
|
| 46 |
|
| 47 |
|
| 48 |
+
#### `list_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L174" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 49 |
|
| 50 |
```python
|
| 51 |
list_resources(self) -> list[Resource]
|
|
|
|
| 54 |
Lists all resources, applying protocol filtering.
|
| 55 |
|
| 56 |
|
| 57 |
+
#### `list_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L181" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 58 |
|
| 59 |
```python
|
| 60 |
list_resource_templates(self) -> list[ResourceTemplate]
|
|
|
|
| 63 |
Lists all templates, applying protocol filtering.
|
| 64 |
|
| 65 |
|
| 66 |
+
#### `add_resource_or_template_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L188" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 67 |
|
| 68 |
```python
|
| 69 |
add_resource_or_template_from_fn(self, fn: Callable[..., Any], uri: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> Resource | ResourceTemplate
|
|
|
|
| 84 |
- returns the existing resource or template.
|
| 85 |
|
| 86 |
|
| 87 |
+
#### `add_resource_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L236" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 88 |
|
| 89 |
```python
|
| 90 |
add_resource_from_fn(self, fn: Callable[..., Any], uri: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> Resource
|
|
|
|
| 105 |
- returns the existing resource.
|
| 106 |
|
| 107 |
|
| 108 |
+
#### `add_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L276" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 109 |
|
| 110 |
```python
|
| 111 |
add_resource(self, resource: Resource) -> Resource
|
|
|
|
| 116 |
**Args:**
|
| 117 |
- `resource`: A Resource instance to add. The resource's .key attribute
|
| 118 |
will be used as the storage key. To overwrite it, call
|
| 119 |
+
Resource.model_copy(key=new_key) before calling this method.
|
| 120 |
|
| 121 |
|
| 122 |
+
#### `add_template_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L298" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 123 |
|
| 124 |
```python
|
| 125 |
add_template_from_fn(self, fn: Callable[..., Any], uri_template: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> ResourceTemplate
|
|
|
|
| 128 |
Create a template from a function.
|
| 129 |
|
| 130 |
|
| 131 |
+
#### `add_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L325" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 132 |
|
| 133 |
```python
|
| 134 |
add_template(self, template: ResourceTemplate) -> ResourceTemplate
|
|
|
|
| 139 |
**Args:**
|
| 140 |
- `template`: A ResourceTemplate instance to add. The template's .key attribute
|
| 141 |
will be used as the storage key. To overwrite it, call
|
| 142 |
+
ResourceTemplate.model_copy(key=new_key) before calling this method.
|
| 143 |
|
| 144 |
**Returns:**
|
| 145 |
- The added template. If a template with the same URI already exists,
|
| 146 |
- returns the existing template.
|
| 147 |
|
| 148 |
|
| 149 |
+
#### `has_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L351" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 150 |
|
| 151 |
```python
|
| 152 |
has_resource(self, uri: AnyUrl | str) -> bool
|
|
|
|
| 155 |
Check if a resource exists.
|
| 156 |
|
| 157 |
|
| 158 |
+
#### `get_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L368" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 159 |
|
| 160 |
```python
|
| 161 |
get_resource(self, uri: AnyUrl | str) -> Resource
|
|
|
|
| 170 |
- `NotFoundError`: If no resource or template matching the URI is found.
|
| 171 |
|
| 172 |
|
| 173 |
+
#### `read_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L413" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 174 |
|
| 175 |
```python
|
| 176 |
read_resource(self, uri: AnyUrl | str) -> str | bytes
|
docs/python-sdk/fastmcp-server-auth-auth.mdx
CHANGED
|
@@ -7,7 +7,13 @@ sidebarTitle: auth
|
|
| 7 |
|
| 8 |
## Classes
|
| 9 |
|
| 10 |
-
### `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
Base class for all FastMCP authentication providers.
|
|
@@ -20,7 +26,7 @@ custom authentication routes.
|
|
| 20 |
|
| 21 |
**Methods:**
|
| 22 |
|
| 23 |
-
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#
|
| 24 |
|
| 25 |
```python
|
| 26 |
verify_token(self, token: str) -> AccessToken | None
|
|
@@ -37,25 +43,34 @@ All auth providers must implement token verification.
|
|
| 37 |
- AccessToken object if valid, None if invalid or expired
|
| 38 |
|
| 39 |
|
| 40 |
-
#### `
|
| 41 |
|
| 42 |
```python
|
| 43 |
-
|
| 44 |
```
|
| 45 |
|
| 46 |
-
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
-
|
| 53 |
|
| 54 |
**Returns:**
|
| 55 |
-
- List of routes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
|
| 58 |
-
### `TokenVerifier` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#
|
| 59 |
|
| 60 |
|
| 61 |
Base class for token verifiers (Resource Servers).
|
|
@@ -66,7 +81,7 @@ Token verifiers typically don't provide authentication routes by default.
|
|
| 66 |
|
| 67 |
**Methods:**
|
| 68 |
|
| 69 |
-
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#
|
| 70 |
|
| 71 |
```python
|
| 72 |
verify_token(self, token: str) -> AccessToken | None
|
|
@@ -75,7 +90,46 @@ verify_token(self, token: str) -> AccessToken | None
|
|
| 75 |
Verify a bearer token and return access info if valid.
|
| 76 |
|
| 77 |
|
| 78 |
-
### `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
|
| 81 |
OAuth Authorization Server provider.
|
|
@@ -86,7 +140,7 @@ authorization flows, token issuance, and token verification.
|
|
| 86 |
|
| 87 |
**Methods:**
|
| 88 |
|
| 89 |
-
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#
|
| 90 |
|
| 91 |
```python
|
| 92 |
verify_token(self, token: str) -> AccessToken | None
|
|
@@ -104,21 +158,18 @@ to our existing load_access_token method.
|
|
| 104 |
- AccessToken object if valid, None if invalid or expired
|
| 105 |
|
| 106 |
|
| 107 |
-
#### `
|
| 108 |
|
| 109 |
```python
|
| 110 |
-
|
| 111 |
```
|
| 112 |
|
| 113 |
-
|
| 114 |
|
| 115 |
-
This method
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
**Args:**
|
| 120 |
-
- `routes`: List of standard OAuth routes from create_auth_routes
|
| 121 |
|
| 122 |
**Returns:**
|
| 123 |
-
- List of
|
| 124 |
|
|
|
|
| 7 |
|
| 8 |
## Classes
|
| 9 |
|
| 10 |
+
### `AccessToken` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L28" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
AccessToken that includes all JWT claims.
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
### `AuthProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L34" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 17 |
|
| 18 |
|
| 19 |
Base class for all FastMCP authentication providers.
|
|
|
|
| 26 |
|
| 27 |
**Methods:**
|
| 28 |
|
| 29 |
+
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L56" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 30 |
|
| 31 |
```python
|
| 32 |
verify_token(self, token: str) -> AccessToken | None
|
|
|
|
| 43 |
- AccessToken object if valid, None if invalid or expired
|
| 44 |
|
| 45 |
|
| 46 |
+
#### `get_routes` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L69" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 47 |
|
| 48 |
```python
|
| 49 |
+
get_routes(self) -> list[Route]
|
| 50 |
```
|
| 51 |
|
| 52 |
+
Get the routes for this authentication provider.
|
| 53 |
|
| 54 |
+
Each provider is responsible for creating whatever routes it needs:
|
| 55 |
+
- TokenVerifier: typically no routes (default implementation)
|
| 56 |
+
- RemoteAuthProvider: protected resource metadata routes
|
| 57 |
+
- OAuthProvider: full OAuth authorization server routes
|
| 58 |
+
- Custom providers: whatever routes they need
|
| 59 |
|
| 60 |
**Returns:**
|
| 61 |
+
- List of routes for this provider
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
#### `get_resource_metadata_url` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L83" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
get_resource_metadata_url(self) -> AnyHttpUrl | None
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
Get the resource metadata URL for RFC 9728 compliance.
|
| 71 |
|
| 72 |
|
| 73 |
+
### `TokenVerifier` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L96" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 74 |
|
| 75 |
|
| 76 |
Base class for token verifiers (Resource Servers).
|
|
|
|
| 81 |
|
| 82 |
**Methods:**
|
| 83 |
|
| 84 |
+
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L120" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 85 |
|
| 86 |
```python
|
| 87 |
verify_token(self, token: str) -> AccessToken | None
|
|
|
|
| 90 |
Verify a bearer token and return access info if valid.
|
| 91 |
|
| 92 |
|
| 93 |
+
### `RemoteAuthProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L125" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
Authentication provider for resource servers that verify tokens from known authorization servers.
|
| 97 |
+
|
| 98 |
+
This provider composes a TokenVerifier with authorization server metadata to create
|
| 99 |
+
standardized OAuth 2.0 Protected Resource endpoints (RFC 9728). Perfect for:
|
| 100 |
+
- JWT verification with known issuers
|
| 101 |
+
- Remote token introspection services
|
| 102 |
+
- Any resource server that knows where its tokens come from
|
| 103 |
+
|
| 104 |
+
Use this when you have token verification logic and want to advertise
|
| 105 |
+
the authorization servers that issue valid tokens.
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
**Methods:**
|
| 109 |
+
|
| 110 |
+
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L161" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 111 |
+
|
| 112 |
+
```python
|
| 113 |
+
verify_token(self, token: str) -> AccessToken | None
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
Verify token using the configured token verifier.
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
#### `get_routes` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L165" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 120 |
+
|
| 121 |
+
```python
|
| 122 |
+
get_routes(self) -> list[Route]
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
Get OAuth routes for this provider.
|
| 126 |
+
|
| 127 |
+
By default, returns only the standardized OAuth 2.0 Protected Resource routes.
|
| 128 |
+
Subclasses can override this method to add additional routes by calling
|
| 129 |
+
super().get_routes() and extending the returned list.
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
### `OAuthProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L183" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 133 |
|
| 134 |
|
| 135 |
OAuth Authorization Server provider.
|
|
|
|
| 140 |
|
| 141 |
**Methods:**
|
| 142 |
|
| 143 |
+
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L250" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 144 |
|
| 145 |
```python
|
| 146 |
verify_token(self, token: str) -> AccessToken | None
|
|
|
|
| 158 |
- AccessToken object if valid, None if invalid or expired
|
| 159 |
|
| 160 |
|
| 161 |
+
#### `get_routes` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L265" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 162 |
|
| 163 |
```python
|
| 164 |
+
get_routes(self) -> list[Route]
|
| 165 |
```
|
| 166 |
|
| 167 |
+
Get OAuth authorization server routes and optional protected resource routes.
|
| 168 |
|
| 169 |
+
This method creates the full set of OAuth routes including:
|
| 170 |
+
- Standard OAuth authorization server routes (/.well-known/oauth-authorization-server, /authorize, /token, etc.)
|
| 171 |
+
- Optional protected resource routes if resource_server_url is configured
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
**Returns:**
|
| 174 |
+
- List of OAuth routes
|
| 175 |
|
docs/python-sdk/fastmcp-server-auth-providers-bearer_env.mdx
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: bearer_env
|
| 3 |
-
sidebarTitle: bearer_env
|
| 4 |
-
---
|
| 5 |
-
|
| 6 |
-
# `fastmcp.server.auth.providers.bearer_env`
|
| 7 |
-
|
| 8 |
-
## Classes
|
| 9 |
-
|
| 10 |
-
### `EnvBearerAuthProviderSettings` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer_env.py#L8" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
Settings for the BearerAuthProvider.
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
### `EnvBearerAuthProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer_env.py#L25" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
A BearerAuthProvider that loads settings from environment variables. Any
|
| 20 |
-
providing setting will always take precedence over the environment
|
| 21 |
-
variables.
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docs/python-sdk/fastmcp-server-auth-providers-jwt.mdx
CHANGED
|
@@ -10,19 +10,19 @@ TokenVerifier implementations for FastMCP.
|
|
| 10 |
|
| 11 |
## Classes
|
| 12 |
|
| 13 |
-
### `JWKData` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 14 |
|
| 15 |
|
| 16 |
JSON Web Key data structure.
|
| 17 |
|
| 18 |
|
| 19 |
-
### `JWKSData` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 20 |
|
| 21 |
|
| 22 |
JSON Web Key Set data structure.
|
| 23 |
|
| 24 |
|
| 25 |
-
### `RSAKeyPair` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 26 |
|
| 27 |
|
| 28 |
RSA key pair for JWT testing.
|
|
@@ -30,7 +30,7 @@ RSA key pair for JWT testing.
|
|
| 30 |
|
| 31 |
**Methods:**
|
| 32 |
|
| 33 |
-
#### `generate` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 34 |
|
| 35 |
```python
|
| 36 |
generate(cls) -> RSAKeyPair
|
|
@@ -42,7 +42,7 @@ Generate an RSA key pair for testing.
|
|
| 42 |
- Generated key pair
|
| 43 |
|
| 44 |
|
| 45 |
-
#### `create_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 46 |
|
| 47 |
```python
|
| 48 |
create_token(self, subject: str = 'fastmcp-user', issuer: str = 'https://fastmcp.example.com', audience: str | list[str] | None = None, scopes: list[str] | None = None, expires_in_seconds: int = 3600, additional_claims: dict[str, Any] | None = None, kid: str | None = None) -> str
|
|
@@ -60,13 +60,13 @@ Generate a test JWT token for testing purposes.
|
|
| 60 |
- `kid`: Key ID to include in header
|
| 61 |
|
| 62 |
|
| 63 |
-
### `JWTVerifierSettings` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 64 |
|
| 65 |
|
| 66 |
Settings for JWT token verification.
|
| 67 |
|
| 68 |
|
| 69 |
-
### `JWTVerifier` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 70 |
|
| 71 |
|
| 72 |
JWT token verifier using public key or JWKS.
|
|
@@ -85,7 +85,7 @@ Use this when:
|
|
| 85 |
|
| 86 |
**Methods:**
|
| 87 |
|
| 88 |
-
#### `load_access_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 89 |
|
| 90 |
```python
|
| 91 |
load_access_token(self, token: str) -> AccessToken | None
|
|
@@ -100,7 +100,7 @@ Validates the provided JWT bearer token.
|
|
| 100 |
- AccessToken object if valid, None if invalid or expired
|
| 101 |
|
| 102 |
|
| 103 |
-
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 104 |
|
| 105 |
```python
|
| 106 |
verify_token(self, token: str) -> AccessToken | None
|
|
@@ -118,7 +118,7 @@ to our existing load_access_token method.
|
|
| 118 |
- AccessToken object if valid, None if invalid or expired
|
| 119 |
|
| 120 |
|
| 121 |
-
### `StaticTokenVerifier` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 122 |
|
| 123 |
|
| 124 |
Simple static token verifier for testing and development.
|
|
@@ -139,7 +139,7 @@ WARNING: Never use this in production - tokens are stored in plain text!
|
|
| 139 |
|
| 140 |
**Methods:**
|
| 141 |
|
| 142 |
-
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#
|
| 143 |
|
| 144 |
```python
|
| 145 |
verify_token(self, token: str) -> AccessToken | None
|
|
|
|
| 10 |
|
| 11 |
## Classes
|
| 12 |
|
| 13 |
+
### `JWKData` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L26" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 14 |
|
| 15 |
|
| 16 |
JSON Web Key data structure.
|
| 17 |
|
| 18 |
|
| 19 |
+
### `JWKSData` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L39" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 20 |
|
| 21 |
|
| 22 |
JSON Web Key Set data structure.
|
| 23 |
|
| 24 |
|
| 25 |
+
### `RSAKeyPair` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L46" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 26 |
|
| 27 |
|
| 28 |
RSA key pair for JWT testing.
|
|
|
|
| 30 |
|
| 31 |
**Methods:**
|
| 32 |
|
| 33 |
+
#### `generate` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L53" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 34 |
|
| 35 |
```python
|
| 36 |
generate(cls) -> RSAKeyPair
|
|
|
|
| 42 |
- Generated key pair
|
| 43 |
|
| 44 |
|
| 45 |
+
#### `create_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L88" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 46 |
|
| 47 |
```python
|
| 48 |
create_token(self, subject: str = 'fastmcp-user', issuer: str = 'https://fastmcp.example.com', audience: str | list[str] | None = None, scopes: list[str] | None = None, expires_in_seconds: int = 3600, additional_claims: dict[str, Any] | None = None, kid: str | None = None) -> str
|
|
|
|
| 60 |
- `kid`: Key ID to include in header
|
| 61 |
|
| 62 |
|
| 63 |
+
### `JWTVerifierSettings` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L141" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 64 |
|
| 65 |
|
| 66 |
Settings for JWT token verification.
|
| 67 |
|
| 68 |
|
| 69 |
+
### `JWTVerifier` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L160" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 70 |
|
| 71 |
|
| 72 |
JWT token verifier using public key or JWKS.
|
|
|
|
| 85 |
|
| 86 |
**Methods:**
|
| 87 |
|
| 88 |
+
#### `load_access_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L356" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 89 |
|
| 90 |
```python
|
| 91 |
load_access_token(self, token: str) -> AccessToken | None
|
|
|
|
| 100 |
- AccessToken object if valid, None if invalid or expired
|
| 101 |
|
| 102 |
|
| 103 |
+
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L458" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 104 |
|
| 105 |
```python
|
| 106 |
verify_token(self, token: str) -> AccessToken | None
|
|
|
|
| 118 |
- AccessToken object if valid, None if invalid or expired
|
| 119 |
|
| 120 |
|
| 121 |
+
### `StaticTokenVerifier` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L474" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 122 |
|
| 123 |
|
| 124 |
Simple static token verifier for testing and development.
|
|
|
|
| 139 |
|
| 140 |
**Methods:**
|
| 141 |
|
| 142 |
+
#### `verify_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/jwt.py#L508" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 143 |
|
| 144 |
```python
|
| 145 |
verify_token(self, token: str) -> AccessToken | None
|
docs/python-sdk/fastmcp-server-auth-providers-workos.mdx
CHANGED
|
@@ -7,14 +7,14 @@ sidebarTitle: workos
|
|
| 7 |
|
| 8 |
## Classes
|
| 9 |
|
| 10 |
-
### `AuthKitProviderSettings` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/workos.py#
|
| 11 |
|
| 12 |
-
### `AuthKitProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/workos.py#
|
| 13 |
|
| 14 |
|
| 15 |
-
|
| 16 |
|
| 17 |
-
This provider implements
|
| 18 |
instead of OAuth proxying. This is the recommended approach for WorkOS DCR
|
| 19 |
as it allows WorkOS to handle the OAuth flow directly while FastMCP acts
|
| 20 |
as a resource server.
|
|
@@ -35,24 +35,14 @@ https://workos.com/docs/authkit/mcp/integrating/token-verification
|
|
| 35 |
|
| 36 |
**Methods:**
|
| 37 |
|
| 38 |
-
#### `
|
| 39 |
|
| 40 |
```python
|
| 41 |
-
|
| 42 |
```
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
```python
|
| 50 |
-
customize_auth_routes(self, routes: list[BaseRoute]) -> list[BaseRoute]
|
| 51 |
-
```
|
| 52 |
-
|
| 53 |
-
Add AuthKit metadata endpoints.
|
| 54 |
-
|
| 55 |
-
This adds:
|
| 56 |
-
- /.well-known/oauth-authorization-server (forwards AuthKit metadata)
|
| 57 |
-
- /.well-known/oauth-protected-resource (returns FastMCP resource info)
|
| 58 |
|
|
|
|
| 7 |
|
| 8 |
## Classes
|
| 9 |
|
| 10 |
+
### `AuthKitProviderSettings` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/workos.py#L18" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 11 |
|
| 12 |
+
### `AuthKitProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/workos.py#L31" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 13 |
|
| 14 |
|
| 15 |
+
AuthKit metadata provider for DCR (Dynamic Client Registration).
|
| 16 |
|
| 17 |
+
This provider implements AuthKit integration using metadata forwarding
|
| 18 |
instead of OAuth proxying. This is the recommended approach for WorkOS DCR
|
| 19 |
as it allows WorkOS to handle the OAuth flow directly while FastMCP acts
|
| 20 |
as a resource server.
|
|
|
|
| 35 |
|
| 36 |
**Methods:**
|
| 37 |
|
| 38 |
+
#### `get_routes` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/workos.py#L114" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 39 |
|
| 40 |
```python
|
| 41 |
+
get_routes(self) -> list[Route]
|
| 42 |
```
|
| 43 |
|
| 44 |
+
Get OAuth routes including AuthKit authorization server metadata forwarding.
|
| 45 |
|
| 46 |
+
This returns the standard protected resource routes plus an authorization server
|
| 47 |
+
metadata endpoint that forwards AuthKit's OAuth metadata to clients.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
docs/python-sdk/fastmcp-server-dependencies.mdx
CHANGED
|
@@ -7,19 +7,19 @@ sidebarTitle: dependencies
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
-
### `get_context` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/dependencies.py#
|
| 11 |
|
| 12 |
```python
|
| 13 |
get_context() -> Context
|
| 14 |
```
|
| 15 |
|
| 16 |
-
### `get_http_request` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/dependencies.py#
|
| 17 |
|
| 18 |
```python
|
| 19 |
get_http_request() -> Request
|
| 20 |
```
|
| 21 |
|
| 22 |
-
### `get_http_headers` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/dependencies.py#
|
| 23 |
|
| 24 |
```python
|
| 25 |
get_http_headers(include_all: bool = False) -> dict[str, str]
|
|
@@ -34,3 +34,16 @@ an empty dict is returned).
|
|
| 34 |
By default, strips problematic headers like `content-length` that cause issues if forwarded to downstream clients.
|
| 35 |
If `include_all` is True, all headers are returned.
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
+
### `get_context` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/dependencies.py#L30" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 11 |
|
| 12 |
```python
|
| 13 |
get_context() -> Context
|
| 14 |
```
|
| 15 |
|
| 16 |
+
### `get_http_request` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/dependencies.py#L42" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 17 |
|
| 18 |
```python
|
| 19 |
get_http_request() -> Request
|
| 20 |
```
|
| 21 |
|
| 22 |
+
### `get_http_headers` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/dependencies.py#L56" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 23 |
|
| 24 |
```python
|
| 25 |
get_http_headers(include_all: bool = False) -> dict[str, str]
|
|
|
|
| 34 |
By default, strips problematic headers like `content-length` that cause issues if forwarded to downstream clients.
|
| 35 |
If `include_all` is True, all headers are returned.
|
| 36 |
|
| 37 |
+
|
| 38 |
+
### `get_access_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/dependencies.py#L105" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
get_access_token() -> AccessToken | None
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
Get the FastMCP access token from the current context.
|
| 46 |
+
|
| 47 |
+
**Returns:**
|
| 48 |
+
- The access token if an authenticated user is available, None otherwise.
|
| 49 |
+
|
docs/python-sdk/fastmcp-server-http.mdx
CHANGED
|
@@ -7,29 +7,13 @@ sidebarTitle: http
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
-
### `set_http_request` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#
|
| 11 |
|
| 12 |
```python
|
| 13 |
set_http_request(request: Request) -> Generator[Request, None, None]
|
| 14 |
```
|
| 15 |
|
| 16 |
-
### `
|
| 17 |
-
|
| 18 |
-
```python
|
| 19 |
-
setup_auth_middleware_and_routes(auth: AuthProvider) -> tuple[list[Middleware], list[Route], list[str]]
|
| 20 |
-
```
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
Set up authentication middleware and routes if auth is enabled.
|
| 24 |
-
|
| 25 |
-
**Args:**
|
| 26 |
-
- `auth`: An AuthProvider for authentication (TokenVerifier or OAuthProvider)
|
| 27 |
-
|
| 28 |
-
**Returns:**
|
| 29 |
-
- Tuple of (middleware, auth_routes, required_scopes)
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
### `create_base_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L119" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 33 |
|
| 34 |
```python
|
| 35 |
create_base_app(routes: list[BaseRoute], middleware: list[Middleware], debug: bool = False, lifespan: Callable | None = None) -> StarletteWithLifespan
|
|
@@ -48,7 +32,7 @@ Create a base Starlette app with common middleware and routes.
|
|
| 48 |
- A Starlette application
|
| 49 |
|
| 50 |
|
| 51 |
-
### `create_sse_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#
|
| 52 |
|
| 53 |
```python
|
| 54 |
create_sse_app(server: FastMCP[LifespanResultT], message_path: str, sse_path: str, auth: AuthProvider | None = None, debug: bool = False, routes: list[BaseRoute] | None = None, middleware: list[Middleware] | None = None) -> StarletteWithLifespan
|
|
@@ -70,7 +54,7 @@ Returns:
|
|
| 70 |
A Starlette application with RequestContextMiddleware
|
| 71 |
|
| 72 |
|
| 73 |
-
### `create_streamable_http_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#
|
| 74 |
|
| 75 |
```python
|
| 76 |
create_streamable_http_app(server: FastMCP[LifespanResultT], streamable_http_path: str, event_store: EventStore | None = None, auth: AuthProvider | None = None, json_response: bool = False, stateless_http: bool = False, debug: bool = False, routes: list[BaseRoute] | None = None, middleware: list[Middleware] | None = None) -> StarletteWithLifespan
|
|
@@ -96,17 +80,23 @@ Return an instance of the StreamableHTTP server app.
|
|
| 96 |
|
| 97 |
## Classes
|
| 98 |
|
| 99 |
-
### `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
**Methods:**
|
| 102 |
|
| 103 |
-
#### `lifespan` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#
|
| 104 |
|
| 105 |
```python
|
| 106 |
-
lifespan(self) -> Lifespan
|
| 107 |
```
|
| 108 |
|
| 109 |
-
### `RequestContextMiddleware` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#
|
| 110 |
|
| 111 |
|
| 112 |
Middleware that stores each request in a ContextVar
|
|
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
+
### `set_http_request` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L80" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 11 |
|
| 12 |
```python
|
| 13 |
set_http_request(request: Request) -> Generator[Request, None, None]
|
| 14 |
```
|
| 15 |
|
| 16 |
+
### `create_base_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L104" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
```python
|
| 19 |
create_base_app(routes: list[BaseRoute], middleware: list[Middleware], debug: bool = False, lifespan: Callable | None = None) -> StarletteWithLifespan
|
|
|
|
| 32 |
- A Starlette application
|
| 33 |
|
| 34 |
|
| 35 |
+
### `create_sse_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L132" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 36 |
|
| 37 |
```python
|
| 38 |
create_sse_app(server: FastMCP[LifespanResultT], message_path: str, sse_path: str, auth: AuthProvider | None = None, debug: bool = False, routes: list[BaseRoute] | None = None, middleware: list[Middleware] | None = None) -> StarletteWithLifespan
|
|
|
|
| 54 |
A Starlette application with RequestContextMiddleware
|
| 55 |
|
| 56 |
|
| 57 |
+
### `create_streamable_http_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L251" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 58 |
|
| 59 |
```python
|
| 60 |
create_streamable_http_app(server: FastMCP[LifespanResultT], streamable_http_path: str, event_store: EventStore | None = None, auth: AuthProvider | None = None, json_response: bool = False, stateless_http: bool = False, debug: bool = False, routes: list[BaseRoute] | None = None, middleware: list[Middleware] | None = None) -> StarletteWithLifespan
|
|
|
|
| 80 |
|
| 81 |
## Classes
|
| 82 |
|
| 83 |
+
### `StreamableHTTPASGIApp` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L35" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
ASGI application wrapper for Streamable HTTP server transport.
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
### `StarletteWithLifespan` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L73" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 90 |
|
| 91 |
**Methods:**
|
| 92 |
|
| 93 |
+
#### `lifespan` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L75" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 94 |
|
| 95 |
```python
|
| 96 |
+
lifespan(self) -> Lifespan[Starlette]
|
| 97 |
```
|
| 98 |
|
| 99 |
+
### `RequestContextMiddleware` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L88" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 100 |
|
| 101 |
|
| 102 |
Middleware that stores each request in a ContextVar
|
docs/python-sdk/fastmcp-server-proxy.mdx
CHANGED
|
@@ -7,7 +7,7 @@ sidebarTitle: proxy
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
-
### `default_proxy_roots_handler` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 11 |
|
| 12 |
```python
|
| 13 |
default_proxy_roots_handler(context: RequestContext[ClientSession, LifespanContextT]) -> RootsList
|
|
@@ -19,7 +19,13 @@ A handler that forwards the list roots request from the remote server to the pro
|
|
| 19 |
|
| 20 |
## Classes
|
| 21 |
|
| 22 |
-
### `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
|
| 25 |
A ToolManager that sources its tools from a remote client in addition to local and mounted tools.
|
|
@@ -27,7 +33,7 @@ A ToolManager that sources its tools from a remote client in addition to local a
|
|
| 27 |
|
| 28 |
**Methods:**
|
| 29 |
|
| 30 |
-
#### `get_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 31 |
|
| 32 |
```python
|
| 33 |
get_tools(self) -> dict[str, Tool]
|
|
@@ -36,7 +42,7 @@ get_tools(self) -> dict[str, Tool]
|
|
| 36 |
Gets the unfiltered tool inventory including local, mounted, and proxy tools.
|
| 37 |
|
| 38 |
|
| 39 |
-
#### `list_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 40 |
|
| 41 |
```python
|
| 42 |
list_tools(self) -> list[Tool]
|
|
@@ -45,7 +51,7 @@ list_tools(self) -> list[Tool]
|
|
| 45 |
Gets the filtered list of tools including local, mounted, and proxy tools.
|
| 46 |
|
| 47 |
|
| 48 |
-
#### `call_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 49 |
|
| 50 |
```python
|
| 51 |
call_tool(self, key: str, arguments: dict[str, Any]) -> ToolResult
|
|
@@ -54,7 +60,7 @@ call_tool(self, key: str, arguments: dict[str, Any]) -> ToolResult
|
|
| 54 |
Calls a tool, trying local/mounted first, then proxy if not found.
|
| 55 |
|
| 56 |
|
| 57 |
-
### `ProxyResourceManager` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 58 |
|
| 59 |
|
| 60 |
A ResourceManager that sources its resources from a remote client in addition to local and mounted resources.
|
|
@@ -62,7 +68,7 @@ A ResourceManager that sources its resources from a remote client in addition to
|
|
| 62 |
|
| 63 |
**Methods:**
|
| 64 |
|
| 65 |
-
#### `get_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 66 |
|
| 67 |
```python
|
| 68 |
get_resources(self) -> dict[str, Resource]
|
|
@@ -71,7 +77,7 @@ get_resources(self) -> dict[str, Resource]
|
|
| 71 |
Gets the unfiltered resource inventory including local, mounted, and proxy resources.
|
| 72 |
|
| 73 |
|
| 74 |
-
#### `get_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 75 |
|
| 76 |
```python
|
| 77 |
get_resource_templates(self) -> dict[str, ResourceTemplate]
|
|
@@ -80,7 +86,7 @@ get_resource_templates(self) -> dict[str, ResourceTemplate]
|
|
| 80 |
Gets the unfiltered template inventory including local, mounted, and proxy templates.
|
| 81 |
|
| 82 |
|
| 83 |
-
#### `list_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 84 |
|
| 85 |
```python
|
| 86 |
list_resources(self) -> list[Resource]
|
|
@@ -89,7 +95,7 @@ list_resources(self) -> list[Resource]
|
|
| 89 |
Gets the filtered list of resources including local, mounted, and proxy resources.
|
| 90 |
|
| 91 |
|
| 92 |
-
#### `list_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 93 |
|
| 94 |
```python
|
| 95 |
list_resource_templates(self) -> list[ResourceTemplate]
|
|
@@ -98,7 +104,7 @@ list_resource_templates(self) -> list[ResourceTemplate]
|
|
| 98 |
Gets the filtered list of templates including local, mounted, and proxy templates.
|
| 99 |
|
| 100 |
|
| 101 |
-
#### `read_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 102 |
|
| 103 |
```python
|
| 104 |
read_resource(self, uri: AnyUrl | str) -> str | bytes
|
|
@@ -107,7 +113,7 @@ read_resource(self, uri: AnyUrl | str) -> str | bytes
|
|
| 107 |
Reads a resource, trying local/mounted first, then proxy if not found.
|
| 108 |
|
| 109 |
|
| 110 |
-
### `ProxyPromptManager` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 111 |
|
| 112 |
|
| 113 |
A PromptManager that sources its prompts from a remote client in addition to local and mounted prompts.
|
|
@@ -115,7 +121,7 @@ A PromptManager that sources its prompts from a remote client in addition to loc
|
|
| 115 |
|
| 116 |
**Methods:**
|
| 117 |
|
| 118 |
-
#### `get_prompts` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 119 |
|
| 120 |
```python
|
| 121 |
get_prompts(self) -> dict[str, Prompt]
|
|
@@ -124,7 +130,7 @@ get_prompts(self) -> dict[str, Prompt]
|
|
| 124 |
Gets the unfiltered prompt inventory including local, mounted, and proxy prompts.
|
| 125 |
|
| 126 |
|
| 127 |
-
#### `list_prompts` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 128 |
|
| 129 |
```python
|
| 130 |
list_prompts(self) -> list[Prompt]
|
|
@@ -133,7 +139,7 @@ list_prompts(self) -> list[Prompt]
|
|
| 133 |
Gets the filtered list of prompts including local, mounted, and proxy prompts.
|
| 134 |
|
| 135 |
|
| 136 |
-
#### `render_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 137 |
|
| 138 |
```python
|
| 139 |
render_prompt(self, name: str, arguments: dict[str, Any] | None = None) -> GetPromptResult
|
|
@@ -142,7 +148,7 @@ render_prompt(self, name: str, arguments: dict[str, Any] | None = None) -> GetPr
|
|
| 142 |
Renders a prompt, trying local/mounted first, then proxy if not found.
|
| 143 |
|
| 144 |
|
| 145 |
-
### `ProxyTool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 146 |
|
| 147 |
|
| 148 |
A Tool that represents and executes a tool on a remote server.
|
|
@@ -150,7 +156,7 @@ A Tool that represents and executes a tool on a remote server.
|
|
| 150 |
|
| 151 |
**Methods:**
|
| 152 |
|
| 153 |
-
#### `from_mcp_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 154 |
|
| 155 |
```python
|
| 156 |
from_mcp_tool(cls, client: Client, mcp_tool: mcp.types.Tool) -> ProxyTool
|
|
@@ -159,7 +165,7 @@ from_mcp_tool(cls, client: Client, mcp_tool: mcp.types.Tool) -> ProxyTool
|
|
| 159 |
Factory method to create a ProxyTool from a raw MCP tool schema.
|
| 160 |
|
| 161 |
|
| 162 |
-
#### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 163 |
|
| 164 |
```python
|
| 165 |
run(self, arguments: dict[str, Any], context: Context | None = None) -> ToolResult
|
|
@@ -168,7 +174,7 @@ run(self, arguments: dict[str, Any], context: Context | None = None) -> ToolResu
|
|
| 168 |
Executes the tool by making a call through the client.
|
| 169 |
|
| 170 |
|
| 171 |
-
### `ProxyResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 172 |
|
| 173 |
|
| 174 |
A Resource that represents and reads a resource from a remote server.
|
|
@@ -176,7 +182,7 @@ A Resource that represents and reads a resource from a remote server.
|
|
| 176 |
|
| 177 |
**Methods:**
|
| 178 |
|
| 179 |
-
#### `from_mcp_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 180 |
|
| 181 |
```python
|
| 182 |
from_mcp_resource(cls, client: Client, mcp_resource: mcp.types.Resource) -> ProxyResource
|
|
@@ -185,7 +191,7 @@ from_mcp_resource(cls, client: Client, mcp_resource: mcp.types.Resource) -> Prox
|
|
| 185 |
Factory method to create a ProxyResource from a raw MCP resource schema.
|
| 186 |
|
| 187 |
|
| 188 |
-
#### `read` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 189 |
|
| 190 |
```python
|
| 191 |
read(self) -> str | bytes
|
|
@@ -194,7 +200,7 @@ read(self) -> str | bytes
|
|
| 194 |
Read the resource content from the remote server.
|
| 195 |
|
| 196 |
|
| 197 |
-
### `ProxyTemplate` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 198 |
|
| 199 |
|
| 200 |
A ResourceTemplate that represents and creates resources from a remote server template.
|
|
@@ -202,7 +208,7 @@ A ResourceTemplate that represents and creates resources from a remote server te
|
|
| 202 |
|
| 203 |
**Methods:**
|
| 204 |
|
| 205 |
-
#### `from_mcp_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 206 |
|
| 207 |
```python
|
| 208 |
from_mcp_template(cls, client: Client, mcp_template: mcp.types.ResourceTemplate) -> ProxyTemplate
|
|
@@ -211,7 +217,7 @@ from_mcp_template(cls, client: Client, mcp_template: mcp.types.ResourceTemplate)
|
|
| 211 |
Factory method to create a ProxyTemplate from a raw MCP template schema.
|
| 212 |
|
| 213 |
|
| 214 |
-
#### `create_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 215 |
|
| 216 |
```python
|
| 217 |
create_resource(self, uri: str, params: dict[str, Any], context: Context | None = None) -> ProxyResource
|
|
@@ -220,7 +226,7 @@ create_resource(self, uri: str, params: dict[str, Any], context: Context | None
|
|
| 220 |
Create a resource from the template by calling the remote server.
|
| 221 |
|
| 222 |
|
| 223 |
-
### `ProxyPrompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 224 |
|
| 225 |
|
| 226 |
A Prompt that represents and renders a prompt from a remote server.
|
|
@@ -228,7 +234,7 @@ A Prompt that represents and renders a prompt from a remote server.
|
|
| 228 |
|
| 229 |
**Methods:**
|
| 230 |
|
| 231 |
-
#### `from_mcp_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 232 |
|
| 233 |
```python
|
| 234 |
from_mcp_prompt(cls, client: Client, mcp_prompt: mcp.types.Prompt) -> ProxyPrompt
|
|
@@ -237,7 +243,7 @@ from_mcp_prompt(cls, client: Client, mcp_prompt: mcp.types.Prompt) -> ProxyPromp
|
|
| 237 |
Factory method to create a ProxyPrompt from a raw MCP prompt schema.
|
| 238 |
|
| 239 |
|
| 240 |
-
#### `render` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 241 |
|
| 242 |
```python
|
| 243 |
render(self, arguments: dict[str, Any]) -> list[PromptMessage]
|
|
@@ -246,14 +252,14 @@ render(self, arguments: dict[str, Any]) -> list[PromptMessage]
|
|
| 246 |
Render the prompt by making a call through the client.
|
| 247 |
|
| 248 |
|
| 249 |
-
### `FastMCPProxy` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 250 |
|
| 251 |
|
| 252 |
A FastMCP server that acts as a proxy to a remote MCP-compliant server.
|
| 253 |
It uses specialized managers that fulfill requests via a client factory.
|
| 254 |
|
| 255 |
|
| 256 |
-
### `ProxyClient` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 257 |
|
| 258 |
|
| 259 |
A proxy client that forwards advanced interactions between a remote MCP server and the proxy's connected clients.
|
|
@@ -262,7 +268,7 @@ Supports forwarding roots, sampling, elicitation, logging, and progress.
|
|
| 262 |
|
| 263 |
**Methods:**
|
| 264 |
|
| 265 |
-
#### `default_sampling_handler` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 266 |
|
| 267 |
```python
|
| 268 |
default_sampling_handler(cls, messages: list[mcp.types.SamplingMessage], params: mcp.types.CreateMessageRequestParams, context: RequestContext[ClientSession, LifespanContextT]) -> mcp.types.CreateMessageResult
|
|
@@ -271,7 +277,7 @@ default_sampling_handler(cls, messages: list[mcp.types.SamplingMessage], params:
|
|
| 271 |
A handler that forwards the sampling request from the remote server to the proxy's connected clients and relays the response back to the remote server.
|
| 272 |
|
| 273 |
|
| 274 |
-
#### `default_elicitation_handler` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 275 |
|
| 276 |
```python
|
| 277 |
default_elicitation_handler(cls, message: str, response_type: type, params: mcp.types.ElicitRequestParams, context: RequestContext[ClientSession, LifespanContextT]) -> ElicitResult
|
|
@@ -280,7 +286,7 @@ default_elicitation_handler(cls, message: str, response_type: type, params: mcp.
|
|
| 280 |
A handler that forwards the elicitation request from the remote server to the proxy's connected clients and relays the response back to the remote server.
|
| 281 |
|
| 282 |
|
| 283 |
-
#### `default_log_handler` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 284 |
|
| 285 |
```python
|
| 286 |
default_log_handler(cls, message: LogMessage) -> None
|
|
@@ -289,7 +295,7 @@ default_log_handler(cls, message: LogMessage) -> None
|
|
| 289 |
A handler that forwards the log notification from the remote server to the proxy's connected clients.
|
| 290 |
|
| 291 |
|
| 292 |
-
#### `default_progress_handler` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 293 |
|
| 294 |
```python
|
| 295 |
default_progress_handler(cls, progress: float, total: float | None, message: str | None) -> None
|
|
@@ -298,7 +304,7 @@ default_progress_handler(cls, progress: float, total: float | None, message: str
|
|
| 298 |
A handler that forwards the progress notification from the remote server to the proxy's connected clients.
|
| 299 |
|
| 300 |
|
| 301 |
-
### `StatefulProxyClient` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 302 |
|
| 303 |
|
| 304 |
A proxy client that provides a stateful client factory for the proxy server.
|
|
@@ -312,7 +318,7 @@ Note that it is essential to ensure that the proxy server itself is also statefu
|
|
| 312 |
|
| 313 |
**Methods:**
|
| 314 |
|
| 315 |
-
#### `clear` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 316 |
|
| 317 |
```python
|
| 318 |
clear(self)
|
|
@@ -321,7 +327,7 @@ clear(self)
|
|
| 321 |
Clear all cached clients and force disconnect them.
|
| 322 |
|
| 323 |
|
| 324 |
-
#### `new_stateful` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#
|
| 325 |
|
| 326 |
```python
|
| 327 |
new_stateful(self) -> Client[ClientTransportT]
|
|
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
+
### `default_proxy_roots_handler` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L521" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 11 |
|
| 12 |
```python
|
| 13 |
default_proxy_roots_handler(context: RequestContext[ClientSession, LifespanContextT]) -> RootsList
|
|
|
|
| 19 |
|
| 20 |
## Classes
|
| 21 |
|
| 22 |
+
### `ProxyManagerMixin` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L56" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
A mixin for proxy managers to provide a unified client retrieval method.
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
### `ProxyToolManager` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L69" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 29 |
|
| 30 |
|
| 31 |
A ToolManager that sources its tools from a remote client in addition to local and mounted tools.
|
|
|
|
| 33 |
|
| 34 |
**Methods:**
|
| 35 |
|
| 36 |
+
#### `get_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L76" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 37 |
|
| 38 |
```python
|
| 39 |
get_tools(self) -> dict[str, Tool]
|
|
|
|
| 42 |
Gets the unfiltered tool inventory including local, mounted, and proxy tools.
|
| 43 |
|
| 44 |
|
| 45 |
+
#### `list_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L102" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 46 |
|
| 47 |
```python
|
| 48 |
list_tools(self) -> list[Tool]
|
|
|
|
| 51 |
Gets the filtered list of tools including local, mounted, and proxy tools.
|
| 52 |
|
| 53 |
|
| 54 |
+
#### `call_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L107" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 55 |
|
| 56 |
```python
|
| 57 |
call_tool(self, key: str, arguments: dict[str, Any]) -> ToolResult
|
|
|
|
| 60 |
Calls a tool, trying local/mounted first, then proxy if not found.
|
| 61 |
|
| 62 |
|
| 63 |
+
### `ProxyResourceManager` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L123" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 64 |
|
| 65 |
|
| 66 |
A ResourceManager that sources its resources from a remote client in addition to local and mounted resources.
|
|
|
|
| 68 |
|
| 69 |
**Methods:**
|
| 70 |
|
| 71 |
+
#### `get_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L130" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 72 |
|
| 73 |
```python
|
| 74 |
get_resources(self) -> dict[str, Resource]
|
|
|
|
| 77 |
Gets the unfiltered resource inventory including local, mounted, and proxy resources.
|
| 78 |
|
| 79 |
|
| 80 |
+
#### `get_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L153" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 81 |
|
| 82 |
```python
|
| 83 |
get_resource_templates(self) -> dict[str, ResourceTemplate]
|
|
|
|
| 86 |
Gets the unfiltered template inventory including local, mounted, and proxy templates.
|
| 87 |
|
| 88 |
|
| 89 |
+
#### `list_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L176" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 90 |
|
| 91 |
```python
|
| 92 |
list_resources(self) -> list[Resource]
|
|
|
|
| 95 |
Gets the filtered list of resources including local, mounted, and proxy resources.
|
| 96 |
|
| 97 |
|
| 98 |
+
#### `list_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L181" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 99 |
|
| 100 |
```python
|
| 101 |
list_resource_templates(self) -> list[ResourceTemplate]
|
|
|
|
| 104 |
Gets the filtered list of templates including local, mounted, and proxy templates.
|
| 105 |
|
| 106 |
|
| 107 |
+
#### `read_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L186" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 108 |
|
| 109 |
```python
|
| 110 |
read_resource(self, uri: AnyUrl | str) -> str | bytes
|
|
|
|
| 113 |
Reads a resource, trying local/mounted first, then proxy if not found.
|
| 114 |
|
| 115 |
|
| 116 |
+
### `ProxyPromptManager` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L204" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 117 |
|
| 118 |
|
| 119 |
A PromptManager that sources its prompts from a remote client in addition to local and mounted prompts.
|
|
|
|
| 121 |
|
| 122 |
**Methods:**
|
| 123 |
|
| 124 |
+
#### `get_prompts` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L211" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 125 |
|
| 126 |
```python
|
| 127 |
get_prompts(self) -> dict[str, Prompt]
|
|
|
|
| 130 |
Gets the unfiltered prompt inventory including local, mounted, and proxy prompts.
|
| 131 |
|
| 132 |
|
| 133 |
+
#### `list_prompts` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L234" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 134 |
|
| 135 |
```python
|
| 136 |
list_prompts(self) -> list[Prompt]
|
|
|
|
| 139 |
Gets the filtered list of prompts including local, mounted, and proxy prompts.
|
| 140 |
|
| 141 |
|
| 142 |
+
#### `render_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L239" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 143 |
|
| 144 |
```python
|
| 145 |
render_prompt(self, name: str, arguments: dict[str, Any] | None = None) -> GetPromptResult
|
|
|
|
| 148 |
Renders a prompt, trying local/mounted first, then proxy if not found.
|
| 149 |
|
| 150 |
|
| 151 |
+
### `ProxyTool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L256" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 152 |
|
| 153 |
|
| 154 |
A Tool that represents and executes a tool on a remote server.
|
|
|
|
| 156 |
|
| 157 |
**Methods:**
|
| 158 |
|
| 159 |
+
#### `from_mcp_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L266" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 160 |
|
| 161 |
```python
|
| 162 |
from_mcp_tool(cls, client: Client, mcp_tool: mcp.types.Tool) -> ProxyTool
|
|
|
|
| 165 |
Factory method to create a ProxyTool from a raw MCP tool schema.
|
| 166 |
|
| 167 |
|
| 168 |
+
#### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L280" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 169 |
|
| 170 |
```python
|
| 171 |
run(self, arguments: dict[str, Any], context: Context | None = None) -> ToolResult
|
|
|
|
| 174 |
Executes the tool by making a call through the client.
|
| 175 |
|
| 176 |
|
| 177 |
+
### `ProxyResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L299" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 178 |
|
| 179 |
|
| 180 |
A Resource that represents and reads a resource from a remote server.
|
|
|
|
| 182 |
|
| 183 |
**Methods:**
|
| 184 |
|
| 185 |
+
#### `from_mcp_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L319" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 186 |
|
| 187 |
```python
|
| 188 |
from_mcp_resource(cls, client: Client, mcp_resource: mcp.types.Resource) -> ProxyResource
|
|
|
|
| 191 |
Factory method to create a ProxyResource from a raw MCP resource schema.
|
| 192 |
|
| 193 |
|
| 194 |
+
#### `read` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L337" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 195 |
|
| 196 |
```python
|
| 197 |
read(self) -> str | bytes
|
|
|
|
| 200 |
Read the resource content from the remote server.
|
| 201 |
|
| 202 |
|
| 203 |
+
### `ProxyTemplate` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L352" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 204 |
|
| 205 |
|
| 206 |
A ResourceTemplate that represents and creates resources from a remote server template.
|
|
|
|
| 208 |
|
| 209 |
**Methods:**
|
| 210 |
|
| 211 |
+
#### `from_mcp_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L362" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 212 |
|
| 213 |
```python
|
| 214 |
from_mcp_template(cls, client: Client, mcp_template: mcp.types.ResourceTemplate) -> ProxyTemplate
|
|
|
|
| 217 |
Factory method to create a ProxyTemplate from a raw MCP template schema.
|
| 218 |
|
| 219 |
|
| 220 |
+
#### `create_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L378" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 221 |
|
| 222 |
```python
|
| 223 |
create_resource(self, uri: str, params: dict[str, Any], context: Context | None = None) -> ProxyResource
|
|
|
|
| 226 |
Create a resource from the template by calling the remote server.
|
| 227 |
|
| 228 |
|
| 229 |
+
### `ProxyPrompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L413" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 230 |
|
| 231 |
|
| 232 |
A Prompt that represents and renders a prompt from a remote server.
|
|
|
|
| 234 |
|
| 235 |
**Methods:**
|
| 236 |
|
| 237 |
+
#### `from_mcp_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L425" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 238 |
|
| 239 |
```python
|
| 240 |
from_mcp_prompt(cls, client: Client, mcp_prompt: mcp.types.Prompt) -> ProxyPrompt
|
|
|
|
| 243 |
Factory method to create a ProxyPrompt from a raw MCP prompt schema.
|
| 244 |
|
| 245 |
|
| 246 |
+
#### `render` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L447" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 247 |
|
| 248 |
```python
|
| 249 |
render(self, arguments: dict[str, Any]) -> list[PromptMessage]
|
|
|
|
| 252 |
Render the prompt by making a call through the client.
|
| 253 |
|
| 254 |
|
| 255 |
+
### `FastMCPProxy` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L454" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 256 |
|
| 257 |
|
| 258 |
A FastMCP server that acts as a proxy to a remote MCP-compliant server.
|
| 259 |
It uses specialized managers that fulfill requests via a client factory.
|
| 260 |
|
| 261 |
|
| 262 |
+
### `ProxyClient` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L531" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 263 |
|
| 264 |
|
| 265 |
A proxy client that forwards advanced interactions between a remote MCP server and the proxy's connected clients.
|
|
|
|
| 268 |
|
| 269 |
**Methods:**
|
| 270 |
|
| 271 |
+
#### `default_sampling_handler` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L562" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 272 |
|
| 273 |
```python
|
| 274 |
default_sampling_handler(cls, messages: list[mcp.types.SamplingMessage], params: mcp.types.CreateMessageRequestParams, context: RequestContext[ClientSession, LifespanContextT]) -> mcp.types.CreateMessageResult
|
|
|
|
| 277 |
A handler that forwards the sampling request from the remote server to the proxy's connected clients and relays the response back to the remote server.
|
| 278 |
|
| 279 |
|
| 280 |
+
#### `default_elicitation_handler` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L588" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 281 |
|
| 282 |
```python
|
| 283 |
default_elicitation_handler(cls, message: str, response_type: type, params: mcp.types.ElicitRequestParams, context: RequestContext[ClientSession, LifespanContextT]) -> ElicitResult
|
|
|
|
| 286 |
A handler that forwards the elicitation request from the remote server to the proxy's connected clients and relays the response back to the remote server.
|
| 287 |
|
| 288 |
|
| 289 |
+
#### `default_log_handler` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L607" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 290 |
|
| 291 |
```python
|
| 292 |
default_log_handler(cls, message: LogMessage) -> None
|
|
|
|
| 295 |
A handler that forwards the log notification from the remote server to the proxy's connected clients.
|
| 296 |
|
| 297 |
|
| 298 |
+
#### `default_progress_handler` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L617" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 299 |
|
| 300 |
```python
|
| 301 |
default_progress_handler(cls, progress: float, total: float | None, message: str | None) -> None
|
|
|
|
| 304 |
A handler that forwards the progress notification from the remote server to the proxy's connected clients.
|
| 305 |
|
| 306 |
|
| 307 |
+
### `StatefulProxyClient` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L630" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 308 |
|
| 309 |
|
| 310 |
A proxy client that provides a stateful client factory for the proxy server.
|
|
|
|
| 318 |
|
| 319 |
**Methods:**
|
| 320 |
|
| 321 |
+
#### `clear` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L652" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 322 |
|
| 323 |
```python
|
| 324 |
clear(self)
|
|
|
|
| 327 |
Clear all cached clients and force disconnect them.
|
| 328 |
|
| 329 |
|
| 330 |
+
#### `new_stateful` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/proxy.py#L660" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 331 |
|
| 332 |
```python
|
| 333 |
new_stateful(self) -> Client[ClientTransportT]
|
docs/python-sdk/fastmcp-server-server.mdx
CHANGED
|
@@ -26,7 +26,7 @@ Default lifespan context manager that does nothing.
|
|
| 26 |
- An empty context object
|
| 27 |
|
| 28 |
|
| 29 |
-
### `add_resource_prefix` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 30 |
|
| 31 |
```python
|
| 32 |
add_resource_prefix(uri: str, prefix: str, prefix_format: Literal['protocol', 'path'] | None = None) -> str
|
|
@@ -64,7 +64,7 @@ add_resource_prefix("resource:///absolute/path", "prefix")
|
|
| 64 |
- `ValueError`: If the URI doesn't match the expected protocol\://path format
|
| 65 |
|
| 66 |
|
| 67 |
-
### `remove_resource_prefix` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 68 |
|
| 69 |
```python
|
| 70 |
remove_resource_prefix(uri: str, prefix: str, prefix_format: Literal['protocol', 'path'] | None = None) -> str
|
|
@@ -103,7 +103,7 @@ remove_resource_prefix("resource://prefix//absolute/path", "prefix")
|
|
| 103 |
- `ValueError`: If the URI doesn't match the expected protocol\://path format
|
| 104 |
|
| 105 |
|
| 106 |
-
### `has_resource_prefix` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 107 |
|
| 108 |
```python
|
| 109 |
has_resource_prefix(uri: str, prefix: str, prefix_format: Literal['protocol', 'path'] | None = None) -> bool
|
|
@@ -147,25 +147,31 @@ False
|
|
| 147 |
|
| 148 |
**Methods:**
|
| 149 |
|
| 150 |
-
#### `settings` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 151 |
|
| 152 |
```python
|
| 153 |
settings(self) -> Settings
|
| 154 |
```
|
| 155 |
|
| 156 |
-
#### `name` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 157 |
|
| 158 |
```python
|
| 159 |
name(self) -> str
|
| 160 |
```
|
| 161 |
|
| 162 |
-
#### `instructions` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 163 |
|
| 164 |
```python
|
| 165 |
instructions(self) -> str | None
|
| 166 |
```
|
| 167 |
|
| 168 |
-
#### `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
```python
|
| 171 |
run_async(self, transport: Transport | None = None, show_banner: bool = True, **transport_kwargs: Any) -> None
|
|
@@ -177,7 +183,7 @@ Run the FastMCP server asynchronously.
|
|
| 177 |
- `transport`: Transport protocol to use ("stdio", "sse", or "streamable-http")
|
| 178 |
|
| 179 |
|
| 180 |
-
#### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 181 |
|
| 182 |
```python
|
| 183 |
run(self, transport: Transport | None = None, show_banner: bool = True, **transport_kwargs: Any) -> None
|
|
@@ -189,13 +195,13 @@ Run the FastMCP server. Note this is a synchronous function.
|
|
| 189 |
- `transport`: Transport protocol to use ("stdio", "sse", or "streamable-http")
|
| 190 |
|
| 191 |
|
| 192 |
-
#### `add_middleware` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 193 |
|
| 194 |
```python
|
| 195 |
add_middleware(self, middleware: Middleware) -> None
|
| 196 |
```
|
| 197 |
|
| 198 |
-
#### `get_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 199 |
|
| 200 |
```python
|
| 201 |
get_tools(self) -> dict[str, Tool]
|
|
@@ -204,13 +210,13 @@ get_tools(self) -> dict[str, Tool]
|
|
| 204 |
Get all registered tools, indexed by registered key.
|
| 205 |
|
| 206 |
|
| 207 |
-
#### `get_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 208 |
|
| 209 |
```python
|
| 210 |
get_tool(self, key: str) -> Tool
|
| 211 |
```
|
| 212 |
|
| 213 |
-
#### `get_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 214 |
|
| 215 |
```python
|
| 216 |
get_resources(self) -> dict[str, Resource]
|
|
@@ -219,13 +225,13 @@ get_resources(self) -> dict[str, Resource]
|
|
| 219 |
Get all registered resources, indexed by registered key.
|
| 220 |
|
| 221 |
|
| 222 |
-
#### `get_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 223 |
|
| 224 |
```python
|
| 225 |
get_resource(self, key: str) -> Resource
|
| 226 |
```
|
| 227 |
|
| 228 |
-
#### `get_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 229 |
|
| 230 |
```python
|
| 231 |
get_resource_templates(self) -> dict[str, ResourceTemplate]
|
|
@@ -234,7 +240,7 @@ get_resource_templates(self) -> dict[str, ResourceTemplate]
|
|
| 234 |
Get all registered resource templates, indexed by registered key.
|
| 235 |
|
| 236 |
|
| 237 |
-
#### `get_resource_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 238 |
|
| 239 |
```python
|
| 240 |
get_resource_template(self, key: str) -> ResourceTemplate
|
|
@@ -243,7 +249,7 @@ get_resource_template(self, key: str) -> ResourceTemplate
|
|
| 243 |
Get a registered resource template by key.
|
| 244 |
|
| 245 |
|
| 246 |
-
#### `get_prompts` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 247 |
|
| 248 |
```python
|
| 249 |
get_prompts(self) -> dict[str, Prompt]
|
|
@@ -252,13 +258,13 @@ get_prompts(self) -> dict[str, Prompt]
|
|
| 252 |
List all available prompts.
|
| 253 |
|
| 254 |
|
| 255 |
-
#### `get_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 256 |
|
| 257 |
```python
|
| 258 |
get_prompt(self, key: str) -> Prompt
|
| 259 |
```
|
| 260 |
|
| 261 |
-
#### `custom_route` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 262 |
|
| 263 |
```python
|
| 264 |
custom_route(self, path: str, methods: list[str], name: str | None = None, include_in_schema: bool = True) -> Callable[[Callable[[Request], Awaitable[Response]]], Callable[[Request], Awaitable[Response]]]
|
|
@@ -279,7 +285,7 @@ Starlette's reverse URL lookup feature)
|
|
| 279 |
- `include_in_schema`: Whether to include in OpenAPI schema, defaults to True
|
| 280 |
|
| 281 |
|
| 282 |
-
#### `add_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 283 |
|
| 284 |
```python
|
| 285 |
add_tool(self, tool: Tool) -> Tool
|
|
@@ -297,7 +303,7 @@ with the Context type annotation. See the @tool decorator for examples.
|
|
| 297 |
- The tool instance that was added to the server.
|
| 298 |
|
| 299 |
|
| 300 |
-
#### `remove_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 301 |
|
| 302 |
```python
|
| 303 |
remove_tool(self, name: str) -> None
|
|
@@ -312,7 +318,7 @@ Remove a tool from the server.
|
|
| 312 |
- `NotFoundError`: If the tool is not found
|
| 313 |
|
| 314 |
|
| 315 |
-
#### `add_tool_transformation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 316 |
|
| 317 |
```python
|
| 318 |
add_tool_transformation(self, tool_name: str, transformation: ToolTransformConfig) -> None
|
|
@@ -321,7 +327,7 @@ add_tool_transformation(self, tool_name: str, transformation: ToolTransformConfi
|
|
| 321 |
Add a tool transformation.
|
| 322 |
|
| 323 |
|
| 324 |
-
#### `remove_tool_transformation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 325 |
|
| 326 |
```python
|
| 327 |
remove_tool_transformation(self, tool_name: str) -> None
|
|
@@ -330,19 +336,19 @@ remove_tool_transformation(self, tool_name: str) -> None
|
|
| 330 |
Remove a tool transformation.
|
| 331 |
|
| 332 |
|
| 333 |
-
#### `tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 334 |
|
| 335 |
```python
|
| 336 |
tool(self, name_or_fn: AnyFunction) -> FunctionTool
|
| 337 |
```
|
| 338 |
|
| 339 |
-
#### `tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 340 |
|
| 341 |
```python
|
| 342 |
tool(self, name_or_fn: str | None = None) -> Callable[[AnyFunction], FunctionTool]
|
| 343 |
```
|
| 344 |
|
| 345 |
-
#### `tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 346 |
|
| 347 |
```python
|
| 348 |
tool(self, name_or_fn: str | AnyFunction | None = None) -> Callable[[AnyFunction], FunctionTool] | FunctionTool
|
|
@@ -398,7 +404,7 @@ server.tool(my_function, name="custom_name")
|
|
| 398 |
```
|
| 399 |
|
| 400 |
|
| 401 |
-
#### `add_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 402 |
|
| 403 |
```python
|
| 404 |
add_resource(self, resource: Resource) -> Resource
|
|
@@ -413,7 +419,7 @@ Add a resource to the server.
|
|
| 413 |
- The resource instance that was added to the server.
|
| 414 |
|
| 415 |
|
| 416 |
-
#### `add_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 417 |
|
| 418 |
```python
|
| 419 |
add_template(self, template: ResourceTemplate) -> ResourceTemplate
|
|
@@ -428,7 +434,7 @@ Add a resource template to the server.
|
|
| 428 |
- The template instance that was added to the server.
|
| 429 |
|
| 430 |
|
| 431 |
-
#### `add_resource_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 432 |
|
| 433 |
```python
|
| 434 |
add_resource_fn(self, fn: AnyFunction, uri: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> None
|
|
@@ -448,7 +454,7 @@ has parameters, it will be registered as a template resource.
|
|
| 448 |
- `tags`: Optional set of tags for categorizing the resource
|
| 449 |
|
| 450 |
|
| 451 |
-
#### `resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 452 |
|
| 453 |
```python
|
| 454 |
resource(self, uri: str) -> Callable[[AnyFunction], Resource | ResourceTemplate]
|
|
@@ -508,7 +514,7 @@ async def get_weather(city: str) -> str:
|
|
| 508 |
```
|
| 509 |
|
| 510 |
|
| 511 |
-
#### `add_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 512 |
|
| 513 |
```python
|
| 514 |
add_prompt(self, prompt: Prompt) -> Prompt
|
|
@@ -523,19 +529,19 @@ Add a prompt to the server.
|
|
| 523 |
- The prompt instance that was added to the server.
|
| 524 |
|
| 525 |
|
| 526 |
-
#### `prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 527 |
|
| 528 |
```python
|
| 529 |
prompt(self, name_or_fn: AnyFunction) -> FunctionPrompt
|
| 530 |
```
|
| 531 |
|
| 532 |
-
#### `prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 533 |
|
| 534 |
```python
|
| 535 |
prompt(self, name_or_fn: str | None = None) -> Callable[[AnyFunction], FunctionPrompt]
|
| 536 |
```
|
| 537 |
|
| 538 |
-
#### `prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 539 |
|
| 540 |
```python
|
| 541 |
prompt(self, name_or_fn: str | AnyFunction | None = None) -> Callable[[AnyFunction], FunctionPrompt] | FunctionPrompt
|
|
@@ -613,7 +619,7 @@ Decorator to register a prompt.
|
|
| 613 |
```
|
| 614 |
|
| 615 |
|
| 616 |
-
#### `run_stdio_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 617 |
|
| 618 |
```python
|
| 619 |
run_stdio_async(self, show_banner: bool = True) -> None
|
|
@@ -622,7 +628,7 @@ run_stdio_async(self, show_banner: bool = True) -> None
|
|
| 622 |
Run the server using stdio transport.
|
| 623 |
|
| 624 |
|
| 625 |
-
#### `run_http_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 626 |
|
| 627 |
```python
|
| 628 |
run_http_async(self, show_banner: bool = True, transport: Literal['http', 'streamable-http', 'sse'] = 'http', host: str | None = None, port: int | None = None, log_level: str | None = None, path: str | None = None, uvicorn_config: dict[str, Any] | None = None, middleware: list[ASGIMiddleware] | None = None, stateless_http: bool | None = None) -> None
|
|
@@ -641,7 +647,7 @@ Run the server using HTTP transport.
|
|
| 641 |
- `stateless_http`: Whether to use stateless HTTP (defaults to settings.stateless_http)
|
| 642 |
|
| 643 |
|
| 644 |
-
#### `run_sse_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 645 |
|
| 646 |
```python
|
| 647 |
run_sse_async(self, host: str | None = None, port: int | None = None, log_level: str | None = None, path: str | None = None, uvicorn_config: dict[str, Any] | None = None) -> None
|
|
@@ -650,7 +656,7 @@ run_sse_async(self, host: str | None = None, port: int | None = None, log_level:
|
|
| 650 |
Run the server using SSE transport.
|
| 651 |
|
| 652 |
|
| 653 |
-
#### `sse_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 654 |
|
| 655 |
```python
|
| 656 |
sse_app(self, path: str | None = None, message_path: str | None = None, middleware: list[ASGIMiddleware] | None = None) -> StarletteWithLifespan
|
|
@@ -664,7 +670,7 @@ Create a Starlette app for the SSE server.
|
|
| 664 |
- `middleware`: A list of middleware to apply to the app
|
| 665 |
|
| 666 |
|
| 667 |
-
#### `streamable_http_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 668 |
|
| 669 |
```python
|
| 670 |
streamable_http_app(self, path: str | None = None, middleware: list[ASGIMiddleware] | None = None) -> StarletteWithLifespan
|
|
@@ -677,7 +683,7 @@ Create a Starlette app for the StreamableHTTP server.
|
|
| 677 |
- `middleware`: A list of middleware to apply to the app
|
| 678 |
|
| 679 |
|
| 680 |
-
#### `http_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 681 |
|
| 682 |
```python
|
| 683 |
http_app(self, path: str | None = None, middleware: list[ASGIMiddleware] | None = None, json_response: bool | None = None, stateless_http: bool | None = None, transport: Literal['http', 'streamable-http', 'sse'] = 'http') -> StarletteWithLifespan
|
|
@@ -694,13 +700,13 @@ Create a Starlette app using the specified HTTP transport.
|
|
| 694 |
- A Starlette application configured with the specified transport
|
| 695 |
|
| 696 |
|
| 697 |
-
#### `run_streamable_http_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 698 |
|
| 699 |
```python
|
| 700 |
run_streamable_http_async(self, host: str | None = None, port: int | None = None, log_level: str | None = None, path: str | None = None, uvicorn_config: dict[str, Any] | None = None) -> None
|
| 701 |
```
|
| 702 |
|
| 703 |
-
#### `mount` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 704 |
|
| 705 |
```python
|
| 706 |
mount(self, server: FastMCP[LifespanResultT], prefix: str | None = None, as_proxy: bool | None = None) -> None
|
|
@@ -754,7 +760,7 @@ automatically determined based on whether the server has a custom lifespan
|
|
| 754 |
- `prompt_separator`: Deprecated. Separator character for prompt names.
|
| 755 |
|
| 756 |
|
| 757 |
-
#### `import_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 758 |
|
| 759 |
```python
|
| 760 |
import_server(self, server: FastMCP[LifespanResultT], prefix: str | None = None, tool_separator: str | None = None, resource_separator: str | None = None, prompt_separator: str | None = None) -> None
|
|
@@ -795,7 +801,7 @@ applied using the protocol\://prefix/path format
|
|
| 795 |
- `prompt_separator`: Deprecated. Separator for prompt names.
|
| 796 |
|
| 797 |
|
| 798 |
-
#### `from_openapi` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 799 |
|
| 800 |
```python
|
| 801 |
from_openapi(cls, openapi_spec: dict[str, Any], client: httpx.AsyncClient, route_maps: list[RouteMap] | list[RouteMapNew] | None = None, route_map_fn: OpenAPIRouteMapFn | OpenAPIRouteMapFnNew | None = None, mcp_component_fn: OpenAPIComponentFn | OpenAPIComponentFnNew | None = None, mcp_names: dict[str, str] | None = None, tags: set[str] | None = None, **settings: Any) -> FastMCPOpenAPI | FastMCPOpenAPINew
|
|
@@ -804,7 +810,7 @@ from_openapi(cls, openapi_spec: dict[str, Any], client: httpx.AsyncClient, route
|
|
| 804 |
Create a FastMCP server from an OpenAPI specification.
|
| 805 |
|
| 806 |
|
| 807 |
-
#### `from_fastapi` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 808 |
|
| 809 |
```python
|
| 810 |
from_fastapi(cls, app: Any, name: str | None = None, route_maps: list[RouteMap] | list[RouteMapNew] | None = None, route_map_fn: OpenAPIRouteMapFn | OpenAPIRouteMapFnNew | None = None, mcp_component_fn: OpenAPIComponentFn | OpenAPIComponentFnNew | None = None, mcp_names: dict[str, str] | None = None, httpx_client_kwargs: dict[str, Any] | None = None, tags: set[str] | None = None, **settings: Any) -> FastMCPOpenAPI | FastMCPOpenAPINew
|
|
@@ -813,7 +819,7 @@ from_fastapi(cls, app: Any, name: str | None = None, route_maps: list[RouteMap]
|
|
| 813 |
Create a FastMCP server from a FastAPI application.
|
| 814 |
|
| 815 |
|
| 816 |
-
#### `as_proxy` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 817 |
|
| 818 |
```python
|
| 819 |
as_proxy(cls, backend: Client[ClientTransportT] | ClientTransport | FastMCP[Any] | AnyUrl | Path | MCPConfig | dict[str, Any] | str, **settings: Any) -> FastMCPProxy
|
|
@@ -827,7 +833,7 @@ instance or any value accepted as the `transport` argument of
|
|
| 827 |
`fastmcp.client.Client` constructor.
|
| 828 |
|
| 829 |
|
| 830 |
-
#### `from_client` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
| 831 |
|
| 832 |
```python
|
| 833 |
from_client(cls, client: Client[ClientTransportT], **settings: Any) -> FastMCPProxy
|
|
@@ -836,4 +842,4 @@ from_client(cls, client: Client[ClientTransportT], **settings: Any) -> FastMCPPr
|
|
| 836 |
Create a FastMCP proxy server from a FastMCP client.
|
| 837 |
|
| 838 |
|
| 839 |
-
### `MountedServer` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#
|
|
|
|
| 26 |
- An empty context object
|
| 27 |
|
| 28 |
|
| 29 |
+
### `add_resource_prefix` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L2162" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 30 |
|
| 31 |
```python
|
| 32 |
add_resource_prefix(uri: str, prefix: str, prefix_format: Literal['protocol', 'path'] | None = None) -> str
|
|
|
|
| 64 |
- `ValueError`: If the URI doesn't match the expected protocol\://path format
|
| 65 |
|
| 66 |
|
| 67 |
+
### `remove_resource_prefix` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L2222" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 68 |
|
| 69 |
```python
|
| 70 |
remove_resource_prefix(uri: str, prefix: str, prefix_format: Literal['protocol', 'path'] | None = None) -> str
|
|
|
|
| 103 |
- `ValueError`: If the URI doesn't match the expected protocol\://path format
|
| 104 |
|
| 105 |
|
| 106 |
+
### `has_resource_prefix` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L2289" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 107 |
|
| 108 |
```python
|
| 109 |
has_resource_prefix(uri: str, prefix: str, prefix_format: Literal['protocol', 'path'] | None = None) -> bool
|
|
|
|
| 147 |
|
| 148 |
**Methods:**
|
| 149 |
|
| 150 |
+
#### `settings` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L288" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 151 |
|
| 152 |
```python
|
| 153 |
settings(self) -> Settings
|
| 154 |
```
|
| 155 |
|
| 156 |
+
#### `name` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L299" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 157 |
|
| 158 |
```python
|
| 159 |
name(self) -> str
|
| 160 |
```
|
| 161 |
|
| 162 |
+
#### `instructions` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L303" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 163 |
|
| 164 |
```python
|
| 165 |
instructions(self) -> str | None
|
| 166 |
```
|
| 167 |
|
| 168 |
+
#### `version` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L307" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 169 |
+
|
| 170 |
+
```python
|
| 171 |
+
version(self) -> str | None
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
#### `run_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L310" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 175 |
|
| 176 |
```python
|
| 177 |
run_async(self, transport: Transport | None = None, show_banner: bool = True, **transport_kwargs: Any) -> None
|
|
|
|
| 183 |
- `transport`: Transport protocol to use ("stdio", "sse", or "streamable-http")
|
| 184 |
|
| 185 |
|
| 186 |
+
#### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L340" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 187 |
|
| 188 |
```python
|
| 189 |
run(self, transport: Transport | None = None, show_banner: bool = True, **transport_kwargs: Any) -> None
|
|
|
|
| 195 |
- `transport`: Transport protocol to use ("stdio", "sse", or "streamable-http")
|
| 196 |
|
| 197 |
|
| 198 |
+
#### `add_middleware` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L382" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 199 |
|
| 200 |
```python
|
| 201 |
add_middleware(self, middleware: Middleware) -> None
|
| 202 |
```
|
| 203 |
|
| 204 |
+
#### `get_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L385" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 205 |
|
| 206 |
```python
|
| 207 |
get_tools(self) -> dict[str, Tool]
|
|
|
|
| 210 |
Get all registered tools, indexed by registered key.
|
| 211 |
|
| 212 |
|
| 213 |
+
#### `get_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L389" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 214 |
|
| 215 |
```python
|
| 216 |
get_tool(self, key: str) -> Tool
|
| 217 |
```
|
| 218 |
|
| 219 |
+
#### `get_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L395" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 220 |
|
| 221 |
```python
|
| 222 |
get_resources(self) -> dict[str, Resource]
|
|
|
|
| 225 |
Get all registered resources, indexed by registered key.
|
| 226 |
|
| 227 |
|
| 228 |
+
#### `get_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L399" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 229 |
|
| 230 |
```python
|
| 231 |
get_resource(self, key: str) -> Resource
|
| 232 |
```
|
| 233 |
|
| 234 |
+
#### `get_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L405" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 235 |
|
| 236 |
```python
|
| 237 |
get_resource_templates(self) -> dict[str, ResourceTemplate]
|
|
|
|
| 240 |
Get all registered resource templates, indexed by registered key.
|
| 241 |
|
| 242 |
|
| 243 |
+
#### `get_resource_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L409" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 244 |
|
| 245 |
```python
|
| 246 |
get_resource_template(self, key: str) -> ResourceTemplate
|
|
|
|
| 249 |
Get a registered resource template by key.
|
| 250 |
|
| 251 |
|
| 252 |
+
#### `get_prompts` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L416" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 253 |
|
| 254 |
```python
|
| 255 |
get_prompts(self) -> dict[str, Prompt]
|
|
|
|
| 258 |
List all available prompts.
|
| 259 |
|
| 260 |
|
| 261 |
+
#### `get_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L422" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 262 |
|
| 263 |
```python
|
| 264 |
get_prompt(self, key: str) -> Prompt
|
| 265 |
```
|
| 266 |
|
| 267 |
+
#### `custom_route` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L428" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 268 |
|
| 269 |
```python
|
| 270 |
custom_route(self, path: str, methods: list[str], name: str | None = None, include_in_schema: bool = True) -> Callable[[Callable[[Request], Awaitable[Response]]], Callable[[Request], Awaitable[Response]]]
|
|
|
|
| 285 |
- `include_in_schema`: Whether to include in OpenAPI schema, defaults to True
|
| 286 |
|
| 287 |
|
| 288 |
+
#### `add_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L808" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 289 |
|
| 290 |
```python
|
| 291 |
add_tool(self, tool: Tool) -> Tool
|
|
|
|
| 303 |
- The tool instance that was added to the server.
|
| 304 |
|
| 305 |
|
| 306 |
+
#### `remove_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L833" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 307 |
|
| 308 |
```python
|
| 309 |
remove_tool(self, name: str) -> None
|
|
|
|
| 318 |
- `NotFoundError`: If the tool is not found
|
| 319 |
|
| 320 |
|
| 321 |
+
#### `add_tool_transformation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L853" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 322 |
|
| 323 |
```python
|
| 324 |
add_tool_transformation(self, tool_name: str, transformation: ToolTransformConfig) -> None
|
|
|
|
| 327 |
Add a tool transformation.
|
| 328 |
|
| 329 |
|
| 330 |
+
#### `remove_tool_transformation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L859" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 331 |
|
| 332 |
```python
|
| 333 |
remove_tool_transformation(self, tool_name: str) -> None
|
|
|
|
| 336 |
Remove a tool transformation.
|
| 337 |
|
| 338 |
|
| 339 |
+
#### `tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L864" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 340 |
|
| 341 |
```python
|
| 342 |
tool(self, name_or_fn: AnyFunction) -> FunctionTool
|
| 343 |
```
|
| 344 |
|
| 345 |
+
#### `tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L880" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 346 |
|
| 347 |
```python
|
| 348 |
tool(self, name_or_fn: str | None = None) -> Callable[[AnyFunction], FunctionTool]
|
| 349 |
```
|
| 350 |
|
| 351 |
+
#### `tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L895" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 352 |
|
| 353 |
```python
|
| 354 |
tool(self, name_or_fn: str | AnyFunction | None = None) -> Callable[[AnyFunction], FunctionTool] | FunctionTool
|
|
|
|
| 404 |
```
|
| 405 |
|
| 406 |
|
| 407 |
+
#### `add_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1026" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 408 |
|
| 409 |
```python
|
| 410 |
add_resource(self, resource: Resource) -> Resource
|
|
|
|
| 419 |
- The resource instance that was added to the server.
|
| 420 |
|
| 421 |
|
| 422 |
+
#### `add_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1048" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 423 |
|
| 424 |
```python
|
| 425 |
add_template(self, template: ResourceTemplate) -> ResourceTemplate
|
|
|
|
| 434 |
- The template instance that was added to the server.
|
| 435 |
|
| 436 |
|
| 437 |
+
#### `add_resource_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1070" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 438 |
|
| 439 |
```python
|
| 440 |
add_resource_fn(self, fn: AnyFunction, uri: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> None
|
|
|
|
| 454 |
- `tags`: Optional set of tags for categorizing the resource
|
| 455 |
|
| 456 |
|
| 457 |
+
#### `resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1108" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 458 |
|
| 459 |
```python
|
| 460 |
resource(self, uri: str) -> Callable[[AnyFunction], Resource | ResourceTemplate]
|
|
|
|
| 514 |
```
|
| 515 |
|
| 516 |
|
| 517 |
+
#### `add_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1245" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 518 |
|
| 519 |
```python
|
| 520 |
add_prompt(self, prompt: Prompt) -> Prompt
|
|
|
|
| 529 |
- The prompt instance that was added to the server.
|
| 530 |
|
| 531 |
|
| 532 |
+
#### `prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1268" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 533 |
|
| 534 |
```python
|
| 535 |
prompt(self, name_or_fn: AnyFunction) -> FunctionPrompt
|
| 536 |
```
|
| 537 |
|
| 538 |
+
#### `prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1281" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 539 |
|
| 540 |
```python
|
| 541 |
prompt(self, name_or_fn: str | None = None) -> Callable[[AnyFunction], FunctionPrompt]
|
| 542 |
```
|
| 543 |
|
| 544 |
+
#### `prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1293" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 545 |
|
| 546 |
```python
|
| 547 |
prompt(self, name_or_fn: str | AnyFunction | None = None) -> Callable[[AnyFunction], FunctionPrompt] | FunctionPrompt
|
|
|
|
| 619 |
```
|
| 620 |
|
| 621 |
|
| 622 |
+
#### `run_stdio_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1434" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 623 |
|
| 624 |
```python
|
| 625 |
run_stdio_async(self, show_banner: bool = True) -> None
|
|
|
|
| 628 |
Run the server using stdio transport.
|
| 629 |
|
| 630 |
|
| 631 |
+
#### `run_http_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1454" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 632 |
|
| 633 |
```python
|
| 634 |
run_http_async(self, show_banner: bool = True, transport: Literal['http', 'streamable-http', 'sse'] = 'http', host: str | None = None, port: int | None = None, log_level: str | None = None, path: str | None = None, uvicorn_config: dict[str, Any] | None = None, middleware: list[ASGIMiddleware] | None = None, stateless_http: bool | None = None) -> None
|
|
|
|
| 647 |
- `stateless_http`: Whether to use stateless HTTP (defaults to settings.stateless_http)
|
| 648 |
|
| 649 |
|
| 650 |
+
#### `run_sse_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1528" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 651 |
|
| 652 |
```python
|
| 653 |
run_sse_async(self, host: str | None = None, port: int | None = None, log_level: str | None = None, path: str | None = None, uvicorn_config: dict[str, Any] | None = None) -> None
|
|
|
|
| 656 |
Run the server using SSE transport.
|
| 657 |
|
| 658 |
|
| 659 |
+
#### `sse_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1556" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 660 |
|
| 661 |
```python
|
| 662 |
sse_app(self, path: str | None = None, message_path: str | None = None, middleware: list[ASGIMiddleware] | None = None) -> StarletteWithLifespan
|
|
|
|
| 670 |
- `middleware`: A list of middleware to apply to the app
|
| 671 |
|
| 672 |
|
| 673 |
+
#### `streamable_http_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1587" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 674 |
|
| 675 |
```python
|
| 676 |
streamable_http_app(self, path: str | None = None, middleware: list[ASGIMiddleware] | None = None) -> StarletteWithLifespan
|
|
|
|
| 683 |
- `middleware`: A list of middleware to apply to the app
|
| 684 |
|
| 685 |
|
| 686 |
+
#### `http_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1608" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 687 |
|
| 688 |
```python
|
| 689 |
http_app(self, path: str | None = None, middleware: list[ASGIMiddleware] | None = None, json_response: bool | None = None, stateless_http: bool | None = None, transport: Literal['http', 'streamable-http', 'sse'] = 'http') -> StarletteWithLifespan
|
|
|
|
| 700 |
- A Starlette application configured with the specified transport
|
| 701 |
|
| 702 |
|
| 703 |
+
#### `run_streamable_http_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1657" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 704 |
|
| 705 |
```python
|
| 706 |
run_streamable_http_async(self, host: str | None = None, port: int | None = None, log_level: str | None = None, path: str | None = None, uvicorn_config: dict[str, Any] | None = None) -> None
|
| 707 |
```
|
| 708 |
|
| 709 |
+
#### `mount` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1682" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 710 |
|
| 711 |
```python
|
| 712 |
mount(self, server: FastMCP[LifespanResultT], prefix: str | None = None, as_proxy: bool | None = None) -> None
|
|
|
|
| 760 |
- `prompt_separator`: Deprecated. Separator character for prompt names.
|
| 761 |
|
| 762 |
|
| 763 |
+
#### `import_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1803" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 764 |
|
| 765 |
```python
|
| 766 |
import_server(self, server: FastMCP[LifespanResultT], prefix: str | None = None, tool_separator: str | None = None, resource_separator: str | None = None, prompt_separator: str | None = None) -> None
|
|
|
|
| 801 |
- `prompt_separator`: Deprecated. Separator for prompt names.
|
| 802 |
|
| 803 |
|
| 804 |
+
#### `from_openapi` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1930" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 805 |
|
| 806 |
```python
|
| 807 |
from_openapi(cls, openapi_spec: dict[str, Any], client: httpx.AsyncClient, route_maps: list[RouteMap] | list[RouteMapNew] | None = None, route_map_fn: OpenAPIRouteMapFn | OpenAPIRouteMapFnNew | None = None, mcp_component_fn: OpenAPIComponentFn | OpenAPIComponentFnNew | None = None, mcp_names: dict[str, str] | None = None, tags: set[str] | None = None, **settings: Any) -> FastMCPOpenAPI | FastMCPOpenAPINew
|
|
|
|
| 810 |
Create a FastMCP server from an OpenAPI specification.
|
| 811 |
|
| 812 |
|
| 813 |
+
#### `from_fastapi` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L1979" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 814 |
|
| 815 |
```python
|
| 816 |
from_fastapi(cls, app: Any, name: str | None = None, route_maps: list[RouteMap] | list[RouteMapNew] | None = None, route_map_fn: OpenAPIRouteMapFn | OpenAPIRouteMapFnNew | None = None, mcp_component_fn: OpenAPIComponentFn | OpenAPIComponentFnNew | None = None, mcp_names: dict[str, str] | None = None, httpx_client_kwargs: dict[str, Any] | None = None, tags: set[str] | None = None, **settings: Any) -> FastMCPOpenAPI | FastMCPOpenAPINew
|
|
|
|
| 819 |
Create a FastMCP server from a FastAPI application.
|
| 820 |
|
| 821 |
|
| 822 |
+
#### `as_proxy` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L2042" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 823 |
|
| 824 |
```python
|
| 825 |
as_proxy(cls, backend: Client[ClientTransportT] | ClientTransport | FastMCP[Any] | AnyUrl | Path | MCPConfig | dict[str, Any] | str, **settings: Any) -> FastMCPProxy
|
|
|
|
| 833 |
`fastmcp.client.Client` constructor.
|
| 834 |
|
| 835 |
|
| 836 |
+
#### `from_client` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L2103" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 837 |
|
| 838 |
```python
|
| 839 |
from_client(cls, client: Client[ClientTransportT], **settings: Any) -> FastMCPProxy
|
|
|
|
| 842 |
Create a FastMCP proxy server from a FastMCP client.
|
| 843 |
|
| 844 |
|
| 845 |
+
### `MountedServer` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/server.py#L2156" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
docs/python-sdk/fastmcp-tools-tool.mdx
CHANGED
|
@@ -7,7 +7,7 @@ sidebarTitle: tool
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
-
### `default_serializer` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#
|
| 11 |
|
| 12 |
```python
|
| 13 |
default_serializer(data: Any) -> str
|
|
@@ -15,17 +15,17 @@ default_serializer(data: Any) -> str
|
|
| 15 |
|
| 16 |
## Classes
|
| 17 |
|
| 18 |
-
### `ToolResult` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#
|
| 19 |
|
| 20 |
**Methods:**
|
| 21 |
|
| 22 |
-
#### `to_mcp_result` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#
|
| 23 |
|
| 24 |
```python
|
| 25 |
to_mcp_result(self) -> list[ContentBlock] | tuple[list[ContentBlock], dict[str, Any]]
|
| 26 |
```
|
| 27 |
|
| 28 |
-
### `Tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#
|
| 29 |
|
| 30 |
|
| 31 |
Internal tool registration info.
|
|
@@ -33,34 +33,34 @@ Internal tool registration info.
|
|
| 33 |
|
| 34 |
**Methods:**
|
| 35 |
|
| 36 |
-
#### `enable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#
|
| 37 |
|
| 38 |
```python
|
| 39 |
enable(self) -> None
|
| 40 |
```
|
| 41 |
|
| 42 |
-
#### `disable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#
|
| 43 |
|
| 44 |
```python
|
| 45 |
disable(self) -> None
|
| 46 |
```
|
| 47 |
|
| 48 |
-
#### `to_mcp_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#
|
| 49 |
|
| 50 |
```python
|
| 51 |
to_mcp_tool(self, **overrides: Any) -> MCPTool
|
| 52 |
```
|
| 53 |
|
| 54 |
-
#### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#
|
| 55 |
|
| 56 |
```python
|
| 57 |
-
from_function(fn: Callable[..., Any], name: str | None = None, title: str | None = None, description: str | None = None, tags: set[str] | None = None, annotations: ToolAnnotations | None = None, exclude_args: list[str] | None = None, output_schema: dict[str, Any] | None | NotSetT
|
| 58 |
```
|
| 59 |
|
| 60 |
Create a Tool from a function.
|
| 61 |
|
| 62 |
|
| 63 |
-
#### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#
|
| 64 |
|
| 65 |
```python
|
| 66 |
run(self, arguments: dict[str, Any]) -> ToolResult
|
|
@@ -75,10 +75,10 @@ implemented by subclasses.
|
|
| 75 |
(list of ContentBlocks, dict of structured output).
|
| 76 |
|
| 77 |
|
| 78 |
-
#### `from_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#
|
| 79 |
|
| 80 |
```python
|
| 81 |
-
from_tool(cls, tool: Tool
|
| 82 |
```
|
| 83 |
|
| 84 |
### `FunctionTool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L232" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
@@ -88,7 +88,7 @@ from_tool(cls, tool: Tool, transform_fn: Callable[..., Any] | None = None, name:
|
|
| 88 |
#### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L236" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 89 |
|
| 90 |
```python
|
| 91 |
-
from_function(cls, fn: Callable[..., Any], name: str | None = None, title: str | None = None, description: str | None = None, tags: set[str] | None = None, annotations: ToolAnnotations | None = None, exclude_args: list[str] | None = None, output_schema: dict[str, Any] | None | NotSetT
|
| 92 |
```
|
| 93 |
|
| 94 |
Create a Tool from a function.
|
|
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
+
### `default_serializer` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L55" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 11 |
|
| 12 |
```python
|
| 13 |
default_serializer(data: Any) -> str
|
|
|
|
| 15 |
|
| 16 |
## Classes
|
| 17 |
|
| 18 |
+
### `ToolResult` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L59" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 19 |
|
| 20 |
**Methods:**
|
| 21 |
|
| 22 |
+
#### `to_mcp_result` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L90" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 23 |
|
| 24 |
```python
|
| 25 |
to_mcp_result(self) -> list[ContentBlock] | tuple[list[ContentBlock], dict[str, Any]]
|
| 26 |
```
|
| 27 |
|
| 28 |
+
### `Tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L98" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 29 |
|
| 30 |
|
| 31 |
Internal tool registration info.
|
|
|
|
| 33 |
|
| 34 |
**Methods:**
|
| 35 |
|
| 36 |
+
#### `enable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L116" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 37 |
|
| 38 |
```python
|
| 39 |
enable(self) -> None
|
| 40 |
```
|
| 41 |
|
| 42 |
+
#### `disable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L124" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 43 |
|
| 44 |
```python
|
| 45 |
disable(self) -> None
|
| 46 |
```
|
| 47 |
|
| 48 |
+
#### `to_mcp_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L132" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 49 |
|
| 50 |
```python
|
| 51 |
to_mcp_tool(self, **overrides: Any) -> MCPTool
|
| 52 |
```
|
| 53 |
|
| 54 |
+
#### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L157" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 55 |
|
| 56 |
```python
|
| 57 |
+
from_function(fn: Callable[..., Any], name: str | None = None, title: str | None = None, description: str | None = None, tags: set[str] | None = None, annotations: ToolAnnotations | None = None, exclude_args: list[str] | None = None, output_schema: dict[str, Any] | None | NotSetT = NotSet, serializer: Callable[[Any], str] | None = None, meta: dict[str, Any] | None = None, enabled: bool | None = None) -> FunctionTool
|
| 58 |
```
|
| 59 |
|
| 60 |
Create a Tool from a function.
|
| 61 |
|
| 62 |
|
| 63 |
+
#### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L185" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 64 |
|
| 65 |
```python
|
| 66 |
run(self, arguments: dict[str, Any]) -> ToolResult
|
|
|
|
| 75 |
(list of ContentBlocks, dict of structured output).
|
| 76 |
|
| 77 |
|
| 78 |
+
#### `from_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L198" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 79 |
|
| 80 |
```python
|
| 81 |
+
from_tool(cls, tool: Tool) -> TransformedTool
|
| 82 |
```
|
| 83 |
|
| 84 |
### `FunctionTool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L232" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
| 88 |
#### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool.py#L236" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 89 |
|
| 90 |
```python
|
| 91 |
+
from_function(cls, fn: Callable[..., Any], name: str | None = None, title: str | None = None, description: str | None = None, tags: set[str] | None = None, annotations: ToolAnnotations | None = None, exclude_args: list[str] | None = None, output_schema: dict[str, Any] | None | NotSetT = NotSet, serializer: Callable[[Any], str] | None = None, meta: dict[str, Any] | None = None, enabled: bool | None = None) -> FunctionTool
|
| 92 |
```
|
| 93 |
|
| 94 |
Create a Tool from a function.
|
docs/python-sdk/fastmcp-tools-tool_manager.mdx
CHANGED
|
@@ -24,7 +24,7 @@ mount(self, server: MountedServer) -> None
|
|
| 24 |
Adds a mounted server as a source for tools.
|
| 25 |
|
| 26 |
|
| 27 |
-
#### `has_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 28 |
|
| 29 |
```python
|
| 30 |
has_tool(self, key: str) -> bool
|
|
@@ -33,7 +33,7 @@ has_tool(self, key: str) -> bool
|
|
| 33 |
Check if a tool exists.
|
| 34 |
|
| 35 |
|
| 36 |
-
#### `get_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 37 |
|
| 38 |
```python
|
| 39 |
get_tool(self, key: str) -> Tool
|
|
@@ -42,7 +42,7 @@ get_tool(self, key: str) -> Tool
|
|
| 42 |
Get tool by key.
|
| 43 |
|
| 44 |
|
| 45 |
-
#### `get_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 46 |
|
| 47 |
```python
|
| 48 |
get_tools(self) -> dict[str, Tool]
|
|
@@ -51,7 +51,7 @@ get_tools(self) -> dict[str, Tool]
|
|
| 51 |
Gets the complete, unfiltered inventory of all tools.
|
| 52 |
|
| 53 |
|
| 54 |
-
#### `list_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 55 |
|
| 56 |
```python
|
| 57 |
list_tools(self) -> list[Tool]
|
|
@@ -60,7 +60,7 @@ list_tools(self) -> list[Tool]
|
|
| 60 |
Lists all tools, applying protocol filtering.
|
| 61 |
|
| 62 |
|
| 63 |
-
#### `add_tool_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 64 |
|
| 65 |
```python
|
| 66 |
add_tool_from_fn(self, fn: Callable[..., Any], name: str | None = None, description: str | None = None, tags: set[str] | None = None, annotations: ToolAnnotations | None = None, serializer: Callable[[Any], str] | None = None, exclude_args: list[str] | None = None) -> Tool
|
|
@@ -69,7 +69,7 @@ add_tool_from_fn(self, fn: Callable[..., Any], name: str | None = None, descript
|
|
| 69 |
Add a tool to the server.
|
| 70 |
|
| 71 |
|
| 72 |
-
#### `add_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 73 |
|
| 74 |
```python
|
| 75 |
add_tool(self, tool: Tool) -> Tool
|
|
@@ -78,7 +78,7 @@ add_tool(self, tool: Tool) -> Tool
|
|
| 78 |
Register a tool with the server.
|
| 79 |
|
| 80 |
|
| 81 |
-
#### `add_tool_transformation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 82 |
|
| 83 |
```python
|
| 84 |
add_tool_transformation(self, tool_name: str, transformation: ToolTransformConfig) -> None
|
|
@@ -87,7 +87,7 @@ add_tool_transformation(self, tool_name: str, transformation: ToolTransformConfi
|
|
| 87 |
Add a tool transformation.
|
| 88 |
|
| 89 |
|
| 90 |
-
#### `get_tool_transformation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 91 |
|
| 92 |
```python
|
| 93 |
get_tool_transformation(self, tool_name: str) -> ToolTransformConfig | None
|
|
@@ -96,7 +96,7 @@ get_tool_transformation(self, tool_name: str) -> ToolTransformConfig | None
|
|
| 96 |
Get a tool transformation.
|
| 97 |
|
| 98 |
|
| 99 |
-
#### `remove_tool_transformation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 100 |
|
| 101 |
```python
|
| 102 |
remove_tool_transformation(self, tool_name: str) -> None
|
|
@@ -105,7 +105,7 @@ remove_tool_transformation(self, tool_name: str) -> None
|
|
| 105 |
Remove a tool transformation.
|
| 106 |
|
| 107 |
|
| 108 |
-
#### `remove_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 109 |
|
| 110 |
```python
|
| 111 |
remove_tool(self, key: str) -> None
|
|
@@ -120,7 +120,7 @@ Remove a tool from the server.
|
|
| 120 |
- `NotFoundError`: If the tool is not found
|
| 121 |
|
| 122 |
|
| 123 |
-
#### `call_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#
|
| 124 |
|
| 125 |
```python
|
| 126 |
call_tool(self, key: str, arguments: dict[str, Any]) -> ToolResult
|
|
|
|
| 24 |
Adds a mounted server as a source for tools.
|
| 25 |
|
| 26 |
|
| 27 |
+
#### `has_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L101" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 28 |
|
| 29 |
```python
|
| 30 |
has_tool(self, key: str) -> bool
|
|
|
|
| 33 |
Check if a tool exists.
|
| 34 |
|
| 35 |
|
| 36 |
+
#### `get_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L106" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 37 |
|
| 38 |
```python
|
| 39 |
get_tool(self, key: str) -> Tool
|
|
|
|
| 42 |
Get tool by key.
|
| 43 |
|
| 44 |
|
| 45 |
+
#### `get_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L113" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 46 |
|
| 47 |
```python
|
| 48 |
get_tools(self) -> dict[str, Tool]
|
|
|
|
| 51 |
Gets the complete, unfiltered inventory of all tools.
|
| 52 |
|
| 53 |
|
| 54 |
+
#### `list_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L119" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 55 |
|
| 56 |
```python
|
| 57 |
list_tools(self) -> list[Tool]
|
|
|
|
| 60 |
Lists all tools, applying protocol filtering.
|
| 61 |
|
| 62 |
|
| 63 |
+
#### `add_tool_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L135" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 64 |
|
| 65 |
```python
|
| 66 |
add_tool_from_fn(self, fn: Callable[..., Any], name: str | None = None, description: str | None = None, tags: set[str] | None = None, annotations: ToolAnnotations | None = None, serializer: Callable[[Any], str] | None = None, exclude_args: list[str] | None = None) -> Tool
|
|
|
|
| 69 |
Add a tool to the server.
|
| 70 |
|
| 71 |
|
| 72 |
+
#### `add_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L164" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 73 |
|
| 74 |
```python
|
| 75 |
add_tool(self, tool: Tool) -> Tool
|
|
|
|
| 78 |
Register a tool with the server.
|
| 79 |
|
| 80 |
|
| 81 |
+
#### `add_tool_transformation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L181" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 82 |
|
| 83 |
```python
|
| 84 |
add_tool_transformation(self, tool_name: str, transformation: ToolTransformConfig) -> None
|
|
|
|
| 87 |
Add a tool transformation.
|
| 88 |
|
| 89 |
|
| 90 |
+
#### `get_tool_transformation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L187" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 91 |
|
| 92 |
```python
|
| 93 |
get_tool_transformation(self, tool_name: str) -> ToolTransformConfig | None
|
|
|
|
| 96 |
Get a tool transformation.
|
| 97 |
|
| 98 |
|
| 99 |
+
#### `remove_tool_transformation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L191" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 100 |
|
| 101 |
```python
|
| 102 |
remove_tool_transformation(self, tool_name: str) -> None
|
|
|
|
| 105 |
Remove a tool transformation.
|
| 106 |
|
| 107 |
|
| 108 |
+
#### `remove_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L196" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 109 |
|
| 110 |
```python
|
| 111 |
remove_tool(self, key: str) -> None
|
|
|
|
| 120 |
- `NotFoundError`: If the tool is not found
|
| 121 |
|
| 122 |
|
| 123 |
+
#### `call_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_manager.py#L210" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 124 |
|
| 125 |
```python
|
| 126 |
call_tool(self, key: str, arguments: dict[str, Any]) -> ToolResult
|
docs/python-sdk/fastmcp-tools-tool_transform.mdx
CHANGED
|
@@ -7,7 +7,7 @@ sidebarTitle: tool_transform
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
-
### `forward` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 11 |
|
| 12 |
```python
|
| 13 |
forward(**kwargs) -> ToolResult
|
|
@@ -36,7 +36,7 @@ tool has args `a` and `b`, and an `transform_args` was provided that maps `x` to
|
|
| 36 |
- `TypeError`: If provided arguments don't match the transformed schema.
|
| 37 |
|
| 38 |
|
| 39 |
-
### `forward_raw` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 40 |
|
| 41 |
```python
|
| 42 |
forward_raw(**kwargs) -> ToolResult
|
|
@@ -62,7 +62,7 @@ y=2)` will call the parent tool with `x=1` and `y=2`.
|
|
| 62 |
- `RuntimeError`: If called outside a transformed tool context.
|
| 63 |
|
| 64 |
|
| 65 |
-
### `apply_transformations_to_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 66 |
|
| 67 |
```python
|
| 68 |
apply_transformations_to_tools(tools: dict[str, Tool], transformations: dict[str, ToolTransformConfig]) -> dict[str, Tool]
|
|
@@ -75,7 +75,7 @@ are left unchanged.
|
|
| 75 |
|
| 76 |
## Classes
|
| 77 |
|
| 78 |
-
### `ArgTransform` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 79 |
|
| 80 |
|
| 81 |
Configuration for transforming a parent tool's argument.
|
|
@@ -137,7 +137,7 @@ ArgTransform(name="new_name", description="New desc", default=None, type=int)
|
|
| 137 |
```
|
| 138 |
|
| 139 |
|
| 140 |
-
### `ArgTransformConfig` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 141 |
|
| 142 |
|
| 143 |
A model for requesting a single argument transform.
|
|
@@ -145,7 +145,7 @@ A model for requesting a single argument transform.
|
|
| 145 |
|
| 146 |
**Methods:**
|
| 147 |
|
| 148 |
-
#### `to_arg_transform` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 149 |
|
| 150 |
```python
|
| 151 |
to_arg_transform(self) -> ArgTransform
|
|
@@ -154,7 +154,7 @@ to_arg_transform(self) -> ArgTransform
|
|
| 154 |
Convert the argument transform to a FastMCP argument transform.
|
| 155 |
|
| 156 |
|
| 157 |
-
### `TransformedTool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 158 |
|
| 159 |
|
| 160 |
A tool that is transformed from another tool.
|
|
@@ -171,7 +171,7 @@ inherited from the parent tool but can be overridden or disabled.
|
|
| 171 |
|
| 172 |
**Methods:**
|
| 173 |
|
| 174 |
-
#### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 175 |
|
| 176 |
```python
|
| 177 |
run(self, arguments: dict[str, Any]) -> ToolResult
|
|
@@ -190,10 +190,10 @@ functions.
|
|
| 190 |
- ToolResult object containing content and optional structured output.
|
| 191 |
|
| 192 |
|
| 193 |
-
#### `from_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 194 |
|
| 195 |
```python
|
| 196 |
-
from_tool(cls, tool: Tool, name: str | None = None, title: str | None | NotSetT = NotSet, description: str | None | NotSetT = NotSet, tags: set[str] | None = None, transform_fn: Callable[..., Any] | None = None, transform_args: dict[str, ArgTransform] | None = None, annotations: ToolAnnotations | None =
|
| 197 |
```
|
| 198 |
|
| 199 |
Create a transformed tool from a parent tool.
|
|
@@ -272,7 +272,7 @@ async def custom_output(**kwargs) -> ToolResult:
|
|
| 272 |
```
|
| 273 |
|
| 274 |
|
| 275 |
-
### `ToolTransformConfig` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 276 |
|
| 277 |
|
| 278 |
Provides a way to transform a tool.
|
|
@@ -280,7 +280,7 @@ Provides a way to transform a tool.
|
|
| 280 |
|
| 281 |
**Methods:**
|
| 282 |
|
| 283 |
-
#### `apply` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#
|
| 284 |
|
| 285 |
```python
|
| 286 |
apply(self, tool: Tool) -> TransformedTool
|
|
|
|
| 7 |
|
| 8 |
## Functions
|
| 9 |
|
| 10 |
+
### `forward` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L35" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 11 |
|
| 12 |
```python
|
| 13 |
forward(**kwargs) -> ToolResult
|
|
|
|
| 36 |
- `TypeError`: If provided arguments don't match the transformed schema.
|
| 37 |
|
| 38 |
|
| 39 |
+
### `forward_raw` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L65" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 40 |
|
| 41 |
```python
|
| 42 |
forward_raw(**kwargs) -> ToolResult
|
|
|
|
| 62 |
- `RuntimeError`: If called outside a transformed tool context.
|
| 63 |
|
| 64 |
|
| 65 |
+
### `apply_transformations_to_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L904" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 66 |
|
| 67 |
```python
|
| 68 |
apply_transformations_to_tools(tools: dict[str, Tool], transformations: dict[str, ToolTransformConfig]) -> dict[str, Tool]
|
|
|
|
| 75 |
|
| 76 |
## Classes
|
| 77 |
|
| 78 |
+
### `ArgTransform` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L92" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 79 |
|
| 80 |
|
| 81 |
Configuration for transforming a parent tool's argument.
|
|
|
|
| 137 |
```
|
| 138 |
|
| 139 |
|
| 140 |
+
### `ArgTransformConfig` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L206" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 141 |
|
| 142 |
|
| 143 |
A model for requesting a single argument transform.
|
|
|
|
| 145 |
|
| 146 |
**Methods:**
|
| 147 |
|
| 148 |
+
#### `to_arg_transform` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L224" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 149 |
|
| 150 |
```python
|
| 151 |
to_arg_transform(self) -> ArgTransform
|
|
|
|
| 154 |
Convert the argument transform to a FastMCP argument transform.
|
| 155 |
|
| 156 |
|
| 157 |
+
### `TransformedTool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L230" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 158 |
|
| 159 |
|
| 160 |
A tool that is transformed from another tool.
|
|
|
|
| 171 |
|
| 172 |
**Methods:**
|
| 173 |
|
| 174 |
+
#### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L257" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 175 |
|
| 176 |
```python
|
| 177 |
run(self, arguments: dict[str, Any]) -> ToolResult
|
|
|
|
| 190 |
- ToolResult object containing content and optional structured output.
|
| 191 |
|
| 192 |
|
| 193 |
+
#### `from_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L362" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 194 |
|
| 195 |
```python
|
| 196 |
+
from_tool(cls, tool: Tool, name: str | None = None, title: str | None | NotSetT = NotSet, description: str | None | NotSetT = NotSet, tags: set[str] | None = None, transform_fn: Callable[..., Any] | None = None, transform_args: dict[str, ArgTransform] | None = None, annotations: ToolAnnotations | None | NotSetT = NotSet, output_schema: dict[str, Any] | None | NotSetT = NotSet, serializer: Callable[[Any], str] | None | NotSetT = NotSet, meta: dict[str, Any] | None | NotSetT = NotSet, enabled: bool | None = None) -> TransformedTool
|
| 197 |
```
|
| 198 |
|
| 199 |
Create a transformed tool from a parent tool.
|
|
|
|
| 272 |
```
|
| 273 |
|
| 274 |
|
| 275 |
+
### `ToolTransformConfig` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L858" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 276 |
|
| 277 |
|
| 278 |
Provides a way to transform a tool.
|
|
|
|
| 280 |
|
| 281 |
**Methods:**
|
| 282 |
|
| 283 |
+
#### `apply` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L890" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 284 |
|
| 285 |
```python
|
| 286 |
apply(self, tool: Tool) -> TransformedTool
|
docs/python-sdk/fastmcp-utilities-components.mdx
CHANGED
|
@@ -41,13 +41,21 @@ If include_fastmcp_meta is True, a `_fastmcp` key will be added to the
|
|
| 41 |
meta, containing a `tags` field with the tags of the component.
|
| 42 |
|
| 43 |
|
| 44 |
-
#### `
|
| 45 |
|
| 46 |
```python
|
| 47 |
-
|
| 48 |
```
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
```python
|
| 53 |
enable(self) -> None
|
|
@@ -56,7 +64,7 @@ enable(self) -> None
|
|
| 56 |
Enable the component.
|
| 57 |
|
| 58 |
|
| 59 |
-
#### `disable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#
|
| 60 |
|
| 61 |
```python
|
| 62 |
disable(self) -> None
|
|
@@ -65,7 +73,7 @@ disable(self) -> None
|
|
| 65 |
Disable the component.
|
| 66 |
|
| 67 |
|
| 68 |
-
#### `copy` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#
|
| 69 |
|
| 70 |
```python
|
| 71 |
copy(self) -> Self
|
|
@@ -74,7 +82,7 @@ copy(self) -> Self
|
|
| 74 |
Create a copy of the component.
|
| 75 |
|
| 76 |
|
| 77 |
-
### `MirroredComponent` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#
|
| 78 |
|
| 79 |
|
| 80 |
Base class for components that are mirrored from a remote server.
|
|
@@ -85,7 +93,7 @@ to create a local version you can modify.
|
|
| 85 |
|
| 86 |
**Methods:**
|
| 87 |
|
| 88 |
-
#### `enable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#
|
| 89 |
|
| 90 |
```python
|
| 91 |
enable(self) -> None
|
|
@@ -94,7 +102,7 @@ enable(self) -> None
|
|
| 94 |
Enable the component.
|
| 95 |
|
| 96 |
|
| 97 |
-
#### `disable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#
|
| 98 |
|
| 99 |
```python
|
| 100 |
disable(self) -> None
|
|
@@ -103,7 +111,7 @@ disable(self) -> None
|
|
| 103 |
Disable the component.
|
| 104 |
|
| 105 |
|
| 106 |
-
#### `copy` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#
|
| 107 |
|
| 108 |
```python
|
| 109 |
copy(self) -> Self
|
|
|
|
| 41 |
meta, containing a `tags` field with the tags of the component.
|
| 42 |
|
| 43 |
|
| 44 |
+
#### `model_copy` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#L94" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 45 |
|
| 46 |
```python
|
| 47 |
+
model_copy(self) -> Self
|
| 48 |
```
|
| 49 |
|
| 50 |
+
Create a copy of the component.
|
| 51 |
+
|
| 52 |
+
**Args:**
|
| 53 |
+
- `update`: A dictionary of fields to update.
|
| 54 |
+
- `deep`: Whether to deep copy the component.
|
| 55 |
+
- `key`: The key to use for the copy.
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
#### `enable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#L126" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 59 |
|
| 60 |
```python
|
| 61 |
enable(self) -> None
|
|
|
|
| 64 |
Enable the component.
|
| 65 |
|
| 66 |
|
| 67 |
+
#### `disable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#L130" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 68 |
|
| 69 |
```python
|
| 70 |
disable(self) -> None
|
|
|
|
| 73 |
Disable the component.
|
| 74 |
|
| 75 |
|
| 76 |
+
#### `copy` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#L134" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 77 |
|
| 78 |
```python
|
| 79 |
copy(self) -> Self
|
|
|
|
| 82 |
Create a copy of the component.
|
| 83 |
|
| 84 |
|
| 85 |
+
### `MirroredComponent` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#L139" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 86 |
|
| 87 |
|
| 88 |
Base class for components that are mirrored from a remote server.
|
|
|
|
| 93 |
|
| 94 |
**Methods:**
|
| 95 |
|
| 96 |
+
#### `enable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#L152" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 97 |
|
| 98 |
```python
|
| 99 |
enable(self) -> None
|
|
|
|
| 102 |
Enable the component.
|
| 103 |
|
| 104 |
|
| 105 |
+
#### `disable` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#L161" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 106 |
|
| 107 |
```python
|
| 108 |
disable(self) -> None
|
|
|
|
| 111 |
Disable the component.
|
| 112 |
|
| 113 |
|
| 114 |
+
#### `copy` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/components.py#L170" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 115 |
|
| 116 |
```python
|
| 117 |
copy(self) -> Self
|
docs/python-sdk/fastmcp-utilities-inspect.mdx
CHANGED
|
@@ -10,7 +10,7 @@ Utilities for inspecting FastMCP instances.
|
|
| 10 |
|
| 11 |
## Functions
|
| 12 |
|
| 13 |
-
### `inspect_fastmcp_v2` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#
|
| 14 |
|
| 15 |
```python
|
| 16 |
inspect_fastmcp_v2(mcp: FastMCP[Any]) -> FastMCPInfo
|
|
@@ -26,10 +26,10 @@ Extract information from a FastMCP v2.x instance.
|
|
| 26 |
- FastMCPInfo dataclass containing the extracted information
|
| 27 |
|
| 28 |
|
| 29 |
-
### `inspect_fastmcp_v1` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#
|
| 30 |
|
| 31 |
```python
|
| 32 |
-
inspect_fastmcp_v1(mcp:
|
| 33 |
```
|
| 34 |
|
| 35 |
|
|
@@ -42,10 +42,10 @@ Extract information from a FastMCP v1.x instance using a Client.
|
|
| 42 |
- FastMCPInfo dataclass containing the extracted information
|
| 43 |
|
| 44 |
|
| 45 |
-
### `inspect_fastmcp` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#
|
| 46 |
|
| 47 |
```python
|
| 48 |
-
inspect_fastmcp(mcp: FastMCP[Any] |
|
| 49 |
```
|
| 50 |
|
| 51 |
|
|
@@ -63,31 +63,31 @@ and uses the appropriate extraction method.
|
|
| 63 |
|
| 64 |
## Classes
|
| 65 |
|
| 66 |
-
### `ToolInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#
|
| 67 |
|
| 68 |
|
| 69 |
Information about a tool.
|
| 70 |
|
| 71 |
|
| 72 |
-
### `PromptInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#
|
| 73 |
|
| 74 |
|
| 75 |
Information about a prompt.
|
| 76 |
|
| 77 |
|
| 78 |
-
### `ResourceInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#
|
| 79 |
|
| 80 |
|
| 81 |
Information about a resource.
|
| 82 |
|
| 83 |
|
| 84 |
-
### `TemplateInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#
|
| 85 |
|
| 86 |
|
| 87 |
Information about a resource template.
|
| 88 |
|
| 89 |
|
| 90 |
-
### `FastMCPInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#
|
| 91 |
|
| 92 |
|
| 93 |
Information extracted from a FastMCP instance.
|
|
|
|
| 10 |
|
| 11 |
## Functions
|
| 12 |
|
| 13 |
+
### `inspect_fastmcp_v2` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L83" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 14 |
|
| 15 |
```python
|
| 16 |
inspect_fastmcp_v2(mcp: FastMCP[Any]) -> FastMCPInfo
|
|
|
|
| 26 |
- FastMCPInfo dataclass containing the extracted information
|
| 27 |
|
| 28 |
|
| 29 |
+
### `inspect_fastmcp_v1` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L185" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 30 |
|
| 31 |
```python
|
| 32 |
+
inspect_fastmcp_v1(mcp: FastMCP1x) -> FastMCPInfo
|
| 33 |
```
|
| 34 |
|
| 35 |
|
|
|
|
| 42 |
- FastMCPInfo dataclass containing the extracted information
|
| 43 |
|
| 44 |
|
| 45 |
+
### `inspect_fastmcp` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L306" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 46 |
|
| 47 |
```python
|
| 48 |
+
inspect_fastmcp(mcp: FastMCP[Any] | FastMCP1x) -> FastMCPInfo
|
| 49 |
```
|
| 50 |
|
| 51 |
|
|
|
|
| 63 |
|
| 64 |
## Classes
|
| 65 |
|
| 66 |
+
### `ToolInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L17" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 67 |
|
| 68 |
|
| 69 |
Information about a tool.
|
| 70 |
|
| 71 |
|
| 72 |
+
### `PromptInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L30" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 73 |
|
| 74 |
|
| 75 |
Information about a prompt.
|
| 76 |
|
| 77 |
|
| 78 |
+
### `ResourceInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L42" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 79 |
|
| 80 |
|
| 81 |
Information about a resource.
|
| 82 |
|
| 83 |
|
| 84 |
+
### `TemplateInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L55" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 85 |
|
| 86 |
|
| 87 |
Information about a resource template.
|
| 88 |
|
| 89 |
|
| 90 |
+
### `FastMCPInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L68" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 91 |
|
| 92 |
|
| 93 |
Information extracted from a FastMCP instance.
|
docs/python-sdk/fastmcp-utilities-openapi.mdx
CHANGED
|
@@ -25,7 +25,7 @@ Format an array parameter according to OpenAPI specifications.
|
|
| 25 |
- String (comma-separated) or list (for query params with explode=True)
|
| 26 |
|
| 27 |
|
| 28 |
-
### `format_deep_object_parameter` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 29 |
|
| 30 |
```python
|
| 31 |
format_deep_object_parameter(param_value: dict, parameter_name: str) -> dict[str, str]
|
|
@@ -47,7 +47,7 @@ For example: `{"id": "123", "type": "user"}` becomes `param[id]=123¶m[type]=
|
|
| 47 |
- Dictionary with bracketed parameter names as keys
|
| 48 |
|
| 49 |
|
| 50 |
-
### `parse_openapi_to_http_routes` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 51 |
|
| 52 |
```python
|
| 53 |
parse_openapi_to_http_routes(openapi_dict: dict[str, Any]) -> list[HTTPRoute]
|
|
@@ -60,7 +60,7 @@ using the openapi-pydantic library.
|
|
| 60 |
Supports both OpenAPI 3.0.x and 3.1.x versions.
|
| 61 |
|
| 62 |
|
| 63 |
-
### `clean_schema_for_display` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 64 |
|
| 65 |
```python
|
| 66 |
clean_schema_for_display(schema: JsonSchema | None) -> JsonSchema | None
|
|
@@ -70,7 +70,7 @@ clean_schema_for_display(schema: JsonSchema | None) -> JsonSchema | None
|
|
| 70 |
Clean up a schema dictionary for display by removing internal/complex fields.
|
| 71 |
|
| 72 |
|
| 73 |
-
### `generate_example_from_schema` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 74 |
|
| 75 |
```python
|
| 76 |
generate_example_from_schema(schema: JsonSchema | None) -> Any
|
|
@@ -81,7 +81,7 @@ Generate a simple example value from a JSON schema dictionary.
|
|
| 81 |
Very basic implementation focusing on types.
|
| 82 |
|
| 83 |
|
| 84 |
-
### `format_json_for_description` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 85 |
|
| 86 |
```python
|
| 87 |
format_json_for_description(data: Any, indent: int = 2) -> str
|
|
@@ -91,7 +91,7 @@ format_json_for_description(data: Any, indent: int = 2) -> str
|
|
| 91 |
Formats Python data as a JSON string block for markdown.
|
| 92 |
|
| 93 |
|
| 94 |
-
### `format_description_with_responses` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 95 |
|
| 96 |
```python
|
| 97 |
format_description_with_responses(base_description: str, responses: dict[str, Any], parameters: list[ParameterInfo] | None = None, request_body: RequestBodyInfo | None = None) -> str
|
|
@@ -114,7 +114,7 @@ including its description, whether it is required, and its content schema.
|
|
| 114 |
- and the request body.
|
| 115 |
|
| 116 |
|
| 117 |
-
### `extract_output_schema_from_responses` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 118 |
|
| 119 |
```python
|
| 120 |
extract_output_schema_from_responses(responses: dict[str, ResponseInfo], schema_definitions: dict[str, Any] | None = None, openapi_version: str | None = None) -> dict[str, Any] | None
|
|
@@ -138,31 +138,31 @@ object type, it wraps it to comply with MCP requirements.
|
|
| 138 |
|
| 139 |
## Classes
|
| 140 |
|
| 141 |
-
### `ParameterInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 142 |
|
| 143 |
|
| 144 |
Represents a single parameter for an HTTP operation in our IR.
|
| 145 |
|
| 146 |
|
| 147 |
-
### `RequestBodyInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 148 |
|
| 149 |
|
| 150 |
Represents the request body for an HTTP operation in our IR.
|
| 151 |
|
| 152 |
|
| 153 |
-
### `ResponseInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 154 |
|
| 155 |
|
| 156 |
Represents response information in our IR.
|
| 157 |
|
| 158 |
|
| 159 |
-
### `HTTPRoute` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 160 |
|
| 161 |
|
| 162 |
Intermediate Representation for a single OpenAPI operation.
|
| 163 |
|
| 164 |
|
| 165 |
-
### `OpenAPIParser` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 166 |
|
| 167 |
|
| 168 |
Unified parser for OpenAPI schemas with generic type parameters to handle both 3.0 and 3.1.
|
|
@@ -170,7 +170,7 @@ Unified parser for OpenAPI schemas with generic type parameters to handle both 3
|
|
| 170 |
|
| 171 |
**Methods:**
|
| 172 |
|
| 173 |
-
#### `parse` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#
|
| 174 |
|
| 175 |
```python
|
| 176 |
parse(self) -> list[HTTPRoute]
|
|
|
|
| 25 |
- String (comma-separated) or list (for query params with explode=True)
|
| 26 |
|
| 27 |
|
| 28 |
+
### `format_deep_object_parameter` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L91" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 29 |
|
| 30 |
```python
|
| 31 |
format_deep_object_parameter(param_value: dict, parameter_name: str) -> dict[str, str]
|
|
|
|
| 47 |
- Dictionary with bracketed parameter names as keys
|
| 48 |
|
| 49 |
|
| 50 |
+
### `parse_openapi_to_http_routes` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L201" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 51 |
|
| 52 |
```python
|
| 53 |
parse_openapi_to_http_routes(openapi_dict: dict[str, Any]) -> list[HTTPRoute]
|
|
|
|
| 60 |
Supports both OpenAPI 3.0.x and 3.1.x versions.
|
| 61 |
|
| 62 |
|
| 63 |
+
### `clean_schema_for_display` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L741" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 64 |
|
| 65 |
```python
|
| 66 |
clean_schema_for_display(schema: JsonSchema | None) -> JsonSchema | None
|
|
|
|
| 70 |
Clean up a schema dictionary for display by removing internal/complex fields.
|
| 71 |
|
| 72 |
|
| 73 |
+
### `generate_example_from_schema` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L801" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 74 |
|
| 75 |
```python
|
| 76 |
generate_example_from_schema(schema: JsonSchema | None) -> Any
|
|
|
|
| 81 |
Very basic implementation focusing on types.
|
| 82 |
|
| 83 |
|
| 84 |
+
### `format_json_for_description` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L884" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 85 |
|
| 86 |
```python
|
| 87 |
format_json_for_description(data: Any, indent: int = 2) -> str
|
|
|
|
| 91 |
Formats Python data as a JSON string block for markdown.
|
| 92 |
|
| 93 |
|
| 94 |
+
### `format_description_with_responses` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L893" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 95 |
|
| 96 |
```python
|
| 97 |
format_description_with_responses(base_description: str, responses: dict[str, Any], parameters: list[ParameterInfo] | None = None, request_body: RequestBodyInfo | None = None) -> str
|
|
|
|
| 114 |
- and the request body.
|
| 115 |
|
| 116 |
|
| 117 |
+
### `extract_output_schema_from_responses` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L1419" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 118 |
|
| 119 |
```python
|
| 120 |
extract_output_schema_from_responses(responses: dict[str, ResponseInfo], schema_definitions: dict[str, Any] | None = None, openapi_version: str | None = None) -> dict[str, Any] | None
|
|
|
|
| 138 |
|
| 139 |
## Classes
|
| 140 |
|
| 141 |
+
### `ParameterInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L124" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 142 |
|
| 143 |
|
| 144 |
Represents a single parameter for an HTTP operation in our IR.
|
| 145 |
|
| 146 |
|
| 147 |
+
### `RequestBodyInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L136" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 148 |
|
| 149 |
|
| 150 |
Represents the request body for an HTTP operation in our IR.
|
| 151 |
|
| 152 |
|
| 153 |
+
### `ResponseInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L146" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 154 |
|
| 155 |
|
| 156 |
Represents response information in our IR.
|
| 157 |
|
| 158 |
|
| 159 |
+
### `HTTPRoute` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L154" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 160 |
|
| 161 |
|
| 162 |
Intermediate Representation for a single OpenAPI operation.
|
| 163 |
|
| 164 |
|
| 165 |
+
### `OpenAPIParser` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L255" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 166 |
|
| 167 |
|
| 168 |
Unified parser for OpenAPI schemas with generic type parameters to handle both 3.0 and 3.1.
|
|
|
|
| 170 |
|
| 171 |
**Methods:**
|
| 172 |
|
| 173 |
+
#### `parse` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/openapi.py#L619" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 174 |
|
| 175 |
```python
|
| 176 |
parse(self) -> list[HTTPRoute]
|
docs/python-sdk/fastmcp-utilities-types.mdx
CHANGED
|
@@ -23,7 +23,7 @@ However, this isn't feasible for user-generated functions. Instead, we use a
|
|
| 23 |
cache to minimize the cost of creating them as much as possible.
|
| 24 |
|
| 25 |
|
| 26 |
-
### `issubclass_safe` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#
|
| 27 |
|
| 28 |
```python
|
| 29 |
issubclass_safe(cls: type, base: type) -> bool
|
|
@@ -33,7 +33,7 @@ issubclass_safe(cls: type, base: type) -> bool
|
|
| 33 |
Check if cls is a subclass of base, even if cls is a type variable.
|
| 34 |
|
| 35 |
|
| 36 |
-
### `is_class_member_of_type` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#
|
| 37 |
|
| 38 |
```python
|
| 39 |
is_class_member_of_type(cls: type, base: type) -> bool
|
|
@@ -46,7 +46,7 @@ Base can be a type, a UnionType, or an Annotated type. Generic types are not
|
|
| 46 |
considered members (e.g. T is not a member of list\[T]).
|
| 47 |
|
| 48 |
|
| 49 |
-
### `find_kwarg_by_type` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#
|
| 50 |
|
| 51 |
```python
|
| 52 |
find_kwarg_by_type(fn: Callable, kwarg_type: type) -> str | None
|
|
@@ -58,7 +58,7 @@ Find the name of the kwarg that is of type kwarg_type.
|
|
| 58 |
Includes union types that contain the kwarg_type, as well as Annotated types.
|
| 59 |
|
| 60 |
|
| 61 |
-
### `replace_type` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#
|
| 62 |
|
| 63 |
```python
|
| 64 |
replace_type(type_, type_map: dict[type, type])
|
|
@@ -93,7 +93,7 @@ list[list[str]]
|
|
| 93 |
Base model for FastMCP models.
|
| 94 |
|
| 95 |
|
| 96 |
-
### `Image` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#
|
| 97 |
|
| 98 |
|
| 99 |
Helper class for returning images from tools.
|
|
@@ -101,7 +101,7 @@ Helper class for returning images from tools.
|
|
| 101 |
|
| 102 |
**Methods:**
|
| 103 |
|
| 104 |
-
#### `to_image_content` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#
|
| 105 |
|
| 106 |
```python
|
| 107 |
to_image_content(self, mime_type: str | None = None, annotations: Annotations | None = None) -> mcp.types.ImageContent
|
|
@@ -110,7 +110,7 @@ to_image_content(self, mime_type: str | None = None, annotations: Annotations |
|
|
| 110 |
Convert to MCP ImageContent.
|
| 111 |
|
| 112 |
|
| 113 |
-
### `Audio` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#
|
| 114 |
|
| 115 |
|
| 116 |
Helper class for returning audio from tools.
|
|
@@ -118,13 +118,13 @@ Helper class for returning audio from tools.
|
|
| 118 |
|
| 119 |
**Methods:**
|
| 120 |
|
| 121 |
-
#### `to_audio_content` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#
|
| 122 |
|
| 123 |
```python
|
| 124 |
to_audio_content(self, mime_type: str | None = None, annotations: Annotations | None = None) -> mcp.types.AudioContent
|
| 125 |
```
|
| 126 |
|
| 127 |
-
### `File` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#
|
| 128 |
|
| 129 |
|
| 130 |
Helper class for returning audio from tools.
|
|
@@ -132,7 +132,7 @@ Helper class for returning audio from tools.
|
|
| 132 |
|
| 133 |
**Methods:**
|
| 134 |
|
| 135 |
-
#### `to_resource_content` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#
|
| 136 |
|
| 137 |
```python
|
| 138 |
to_resource_content(self, mime_type: str | None = None, annotations: Annotations | None = None) -> mcp.types.EmbeddedResource
|
|
|
|
| 23 |
cache to minimize the cost of creating them as much as possible.
|
| 24 |
|
| 25 |
|
| 26 |
+
### `issubclass_safe` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#L114" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 27 |
|
| 28 |
```python
|
| 29 |
issubclass_safe(cls: type, base: type) -> bool
|
|
|
|
| 33 |
Check if cls is a subclass of base, even if cls is a type variable.
|
| 34 |
|
| 35 |
|
| 36 |
+
### `is_class_member_of_type` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#L124" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 37 |
|
| 38 |
```python
|
| 39 |
is_class_member_of_type(cls: type, base: type) -> bool
|
|
|
|
| 46 |
considered members (e.g. T is not a member of list\[T]).
|
| 47 |
|
| 48 |
|
| 49 |
+
### `find_kwarg_by_type` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#L146" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 50 |
|
| 51 |
```python
|
| 52 |
find_kwarg_by_type(fn: Callable, kwarg_type: type) -> str | None
|
|
|
|
| 58 |
Includes union types that contain the kwarg_type, as well as Annotated types.
|
| 59 |
|
| 60 |
|
| 61 |
+
### `replace_type` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#L375" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 62 |
|
| 63 |
```python
|
| 64 |
replace_type(type_, type_map: dict[type, type])
|
|
|
|
| 93 |
Base model for FastMCP models.
|
| 94 |
|
| 95 |
|
| 96 |
+
### `Image` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#L172" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 97 |
|
| 98 |
|
| 99 |
Helper class for returning images from tools.
|
|
|
|
| 101 |
|
| 102 |
**Methods:**
|
| 103 |
|
| 104 |
+
#### `to_image_content` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#L209" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 105 |
|
| 106 |
```python
|
| 107 |
to_image_content(self, mime_type: str | None = None, annotations: Annotations | None = None) -> mcp.types.ImageContent
|
|
|
|
| 110 |
Convert to MCP ImageContent.
|
| 111 |
|
| 112 |
|
| 113 |
+
### `Audio` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#L231" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 114 |
|
| 115 |
|
| 116 |
Helper class for returning audio from tools.
|
|
|
|
| 118 |
|
| 119 |
**Methods:**
|
| 120 |
|
| 121 |
+
#### `to_audio_content` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#L268" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 122 |
|
| 123 |
```python
|
| 124 |
to_audio_content(self, mime_type: str | None = None, annotations: Annotations | None = None) -> mcp.types.AudioContent
|
| 125 |
```
|
| 126 |
|
| 127 |
+
### `File` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#L289" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 128 |
|
| 129 |
|
| 130 |
Helper class for returning audio from tools.
|
|
|
|
| 132 |
|
| 133 |
**Methods:**
|
| 134 |
|
| 135 |
+
#### `to_resource_content` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/types.py#L328" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
| 136 |
|
| 137 |
```python
|
| 138 |
to_resource_content(self, mime_type: str | None = None, annotations: Annotations | None = None) -> mcp.types.EmbeddedResource
|
justfile
CHANGED
|
@@ -17,7 +17,6 @@ docs:
|
|
| 17 |
# Generate API reference documentation for all modules
|
| 18 |
api-ref-all:
|
| 19 |
uvx --with-editable . --refresh-package mdxify mdxify@latest --all --root-module fastmcp --anchor-name "Python SDK" --exclude fastmcp.contrib
|
| 20 |
-
|
| 21 |
# Generate API reference for specific modules (e.g., just api-ref prefect.flows prefect.tasks)
|
| 22 |
api-ref *MODULES:
|
| 23 |
uvx --with-editable . --refresh-package mdxify mdxify@latest {{MODULES}} --root-module fastmcp --anchor-name "Python SDK"
|
|
|
|
| 17 |
# Generate API reference documentation for all modules
|
| 18 |
api-ref-all:
|
| 19 |
uvx --with-editable . --refresh-package mdxify mdxify@latest --all --root-module fastmcp --anchor-name "Python SDK" --exclude fastmcp.contrib
|
|
|
|
| 20 |
# Generate API reference for specific modules (e.g., just api-ref prefect.flows prefect.tasks)
|
| 21 |
api-ref *MODULES:
|
| 22 |
uvx --with-editable . --refresh-package mdxify mdxify@latest {{MODULES}} --root-module fastmcp --anchor-name "Python SDK"
|
src/fastmcp/server/auth/providers/jwt.py
CHANGED
|
@@ -107,8 +107,6 @@ class RSAKeyPair:
|
|
| 107 |
additional_claims: Any additional claims to include
|
| 108 |
kid: Key ID to include in header
|
| 109 |
"""
|
| 110 |
-
import time
|
| 111 |
-
|
| 112 |
# Create header
|
| 113 |
header = {"alg": "RS256"}
|
| 114 |
if kid:
|
|
|
|
| 107 |
additional_claims: Any additional claims to include
|
| 108 |
kid: Key ID to include in header
|
| 109 |
"""
|
|
|
|
|
|
|
| 110 |
# Create header
|
| 111 |
header = {"alg": "RS256"}
|
| 112 |
if kid:
|