3.0.0
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: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:- Namespace - Prefix component names to prevent conflicts when composing servers
- Tool Transformation - Rename tools, modify descriptions, reshape arguments
- Enabled - Control which components are visible at runtime
- Resources as Tools - Expose resources to tool-only clients
- Prompts as Tools - Expose prompts to tool-only clients
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.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.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.Custom Transforms
Create custom transforms by subclassingTransform and overriding the methods you need.
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:
| Method | Pattern | Purpose |
|---|---|---|
list_tools(tools) | Pure function | Transform the sequence of tools |
get_tool(name, call_next) | Middleware | Transform lookup by name |
list_resources(resources) | Pure function | Transform the sequence of resources |
get_resource(uri, call_next) | Middleware | Transform lookup by URI |
list_resource_templates(templates) | Pure function | Transform the sequence of templates |
get_resource_template(uri, call_next) | Middleware | Transform template lookup by URI |
list_prompts(prompts) | Pure function | Transform the sequence of prompts |
get_prompt(name, call_next) | Middleware | Transform lookup by name |
call_next for routing flexibility—when a client requests “new_name”, your transform maps it back to “original_name” before calling call_next().

