3.0.0
LocalProvider stores components that you define directly on your server. When you use @mcp.tool, @mcp.resource, or @mcp.prompt, you’re adding components to your server’s LocalProvider.
How It Works
Every FastMCP server has aLocalProvider as its first provider. Components registered via decorators or direct methods are stored here:
LocalProvider is always queried first when clients request components, ensuring that your directly-defined components take precedence over those from mounted or proxied servers.
Component Registration
Using Decorators
The most common way to register components:Using Direct Methods
You can also add pre-built component objects:Removing Components
Remove components by name or URI:Duplicate Handling
When you try to add a component that already exists, the behavior depends on theon_duplicate setting:
| Mode | Behavior |
|---|---|
"error" (default) | Raise ValueError |
"warn" | Log warning and replace |
"replace" | Silently replace |
"ignore" | Keep existing component |
Component Visibility
New in version3.0.0
Components can be dynamically enabled or disabled at runtime. Disabled components don’t appear in listings and can’t be called.
Standalone LocalProvider
You can create a LocalProvider independently and attach it to multiple servers:- Sharing components across servers
- Testing components in isolation
- Building reusable component libraries
enable() and disable(). See Visibility for details.
