mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-22 21:44:18 +02:00
chore: Update SDK documentation (#2834)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
This commit is contained in:
parent
a6cd764b5f
commit
1700bc360b
59 changed files with 3023 additions and 1406 deletions
196
docs/python-sdk/fastmcp-server-transforms-__init__.mdx
Normal file
196
docs/python-sdk/fastmcp-server-transforms-__init__.mdx
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
---
|
||||
title: __init__
|
||||
sidebarTitle: __init__
|
||||
---
|
||||
|
||||
# `fastmcp.server.transforms`
|
||||
|
||||
|
||||
Transform system for component transformations.
|
||||
|
||||
Transforms modify components (tools, resources, prompts) using a middleware pattern.
|
||||
Each transform wraps the next in the chain via `call_next`, allowing transforms to
|
||||
intercept, modify, or replace component queries.
|
||||
|
||||
Unlike middleware (which operates on requests), transforms are observable by the
|
||||
system for task registration, tag filtering, and component introspection.
|
||||
|
||||
Example:
|
||||
```python
|
||||
from fastmcp import FastMCP
|
||||
from fastmcp.server.transforms import Namespace
|
||||
|
||||
server = FastMCP("Server")
|
||||
mount = server.mount(other_server)
|
||||
mount.add_transform(Namespace("api")) # Tools become api_toolname
|
||||
```
|
||||
|
||||
|
||||
## Classes
|
||||
|
||||
### `GetToolNext` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L43" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Protocol for get_tool call_next functions.
|
||||
|
||||
|
||||
### `GetResourceNext` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L51" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Protocol for get_resource call_next functions.
|
||||
|
||||
|
||||
### `GetResourceTemplateNext` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L59" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Protocol for get_resource_template call_next functions.
|
||||
|
||||
|
||||
### `GetPromptNext` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L67" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Protocol for get_prompt call_next functions.
|
||||
|
||||
|
||||
### `Transform` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L75" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Base class for component transformations.
|
||||
|
||||
Transforms use a middleware pattern with `call_next` to chain operations.
|
||||
Each transform can intercept, modify, or pass through component queries.
|
||||
|
||||
For list operations, call `call_next()` to get components from downstream,
|
||||
then transform the result. For get operations, optionally transform the
|
||||
name/uri before calling `call_next`, then transform the result.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `list_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L106" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
list_tools(self, call_next: ListToolsNext) -> Sequence[Tool]
|
||||
```
|
||||
|
||||
List tools with transformation applied.
|
||||
|
||||
**Args:**
|
||||
- `call_next`: Callable to get tools from downstream transforms/provider.
|
||||
|
||||
**Returns:**
|
||||
- Transformed sequence of tools.
|
||||
|
||||
|
||||
#### `get_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L117" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
get_tool(self, name: str, call_next: GetToolNext) -> Tool | None
|
||||
```
|
||||
|
||||
Get a tool by name.
|
||||
|
||||
**Args:**
|
||||
- `name`: The requested tool name (may be transformed).
|
||||
- `call_next`: Callable to get tool from downstream.
|
||||
- `version`: Optional version filter to apply.
|
||||
|
||||
**Returns:**
|
||||
- The tool if found, None otherwise.
|
||||
|
||||
|
||||
#### `list_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L136" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
list_resources(self, call_next: ListResourcesNext) -> Sequence[Resource]
|
||||
```
|
||||
|
||||
List resources with transformation applied.
|
||||
|
||||
**Args:**
|
||||
- `call_next`: Callable to get resources from downstream transforms/provider.
|
||||
|
||||
**Returns:**
|
||||
- Transformed sequence of resources.
|
||||
|
||||
|
||||
#### `get_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L147" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
get_resource(self, uri: str, call_next: GetResourceNext) -> Resource | None
|
||||
```
|
||||
|
||||
Get a resource by URI.
|
||||
|
||||
**Args:**
|
||||
- `uri`: The requested resource URI (may be transformed).
|
||||
- `call_next`: Callable to get resource from downstream.
|
||||
- `version`: Optional version filter to apply.
|
||||
|
||||
**Returns:**
|
||||
- The resource if found, None otherwise.
|
||||
|
||||
|
||||
#### `list_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L170" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
list_resource_templates(self, call_next: ListResourceTemplatesNext) -> Sequence[ResourceTemplate]
|
||||
```
|
||||
|
||||
List resource templates with transformation applied.
|
||||
|
||||
**Args:**
|
||||
- `call_next`: Callable to get templates from downstream transforms/provider.
|
||||
|
||||
**Returns:**
|
||||
- Transformed sequence of resource templates.
|
||||
|
||||
|
||||
#### `get_resource_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L183" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
get_resource_template(self, uri: str, call_next: GetResourceTemplateNext) -> ResourceTemplate | None
|
||||
```
|
||||
|
||||
Get a resource template by URI.
|
||||
|
||||
**Args:**
|
||||
- `uri`: The requested template URI (may be transformed).
|
||||
- `call_next`: Callable to get template from downstream.
|
||||
- `version`: Optional version filter to apply.
|
||||
|
||||
**Returns:**
|
||||
- The resource template if found, None otherwise.
|
||||
|
||||
|
||||
#### `list_prompts` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L206" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
list_prompts(self, call_next: ListPromptsNext) -> Sequence[Prompt]
|
||||
```
|
||||
|
||||
List prompts with transformation applied.
|
||||
|
||||
**Args:**
|
||||
- `call_next`: Callable to get prompts from downstream transforms/provider.
|
||||
|
||||
**Returns:**
|
||||
- Transformed sequence of prompts.
|
||||
|
||||
|
||||
#### `get_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/__init__.py#L217" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
get_prompt(self, name: str, call_next: GetPromptNext) -> Prompt | None
|
||||
```
|
||||
|
||||
Get a prompt by name.
|
||||
|
||||
**Args:**
|
||||
- `name`: The requested prompt name (may be transformed).
|
||||
- `call_next`: Callable to get prompt from downstream.
|
||||
- `version`: Optional version filter to apply.
|
||||
|
||||
**Returns:**
|
||||
- The prompt if found, None otherwise.
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue