Skip to main content
Transforms modify components as they flow from providers to clients. When a client asks “what tools do you have?”, the request passes through each transform in the chain. Each transform can modify the components before passing them along.

Mental Model

Think of transforms as filters in a pipeline. Components flow from providers through transforms to reach clients:
When listing components, transforms receive sequences and return transformed sequences—a pure function pattern. When getting a specific component by name, transforms use a middleware pattern with call_next, working in reverse: mapping the client’s requested name back to the original, then transforming the result.

Built-in Transforms

FastMCP provides several transforms for common use cases:

Server vs Provider Transforms

Transforms can be added at two levels, each serving different purposes.

Provider-Level Transforms

Provider transforms apply to components from a specific provider. They run first, modifying components before they reach the server level.
When using mount(), the returned provider reference lets you add transforms directly.

Server-Level Transforms

Server transforms apply to all components from all providers. They run after provider transforms, seeing the already-transformed names.
Server-level transforms are useful for API versioning or applying consistent naming across your entire server.

Transform Order

Transforms stack in the order they’re added. The first transform added is innermost (closest to the provider), and subsequent transforms wrap it.
When a client requests “short”, the transforms reverse the mapping: ToolTransform maps “short” to “api_verbose_name”, then Namespace strips the prefix to find “verbose_name” in the provider.

Custom Transforms

Create custom transforms by subclassing Transform and overriding the methods you need.
The Transform base class provides default implementations that pass through unchanged. Override only the methods relevant to your transform. Each component type has two methods with different patterns: List methods receive sequences directly and return transformed sequences. Get methods use call_next for routing flexibility—when a client requests “new_name”, your transform maps it back to “original_name” before calling call_next().