The default provider for decorator-registered components
New in version 3.0.0LocalProvider 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.
Every FastMCP server has a LocalProvider as its first provider. Components registered via decorators or direct methods are stored here:
Copy
from fastmcp import FastMCPmcp = FastMCP("MyServer")# These are stored in the server's `LocalProvider`@mcp.tooldef greet(name: str) -> str: """Greet someone by name.""" return f"Hello, {name}!"@mcp.resource("data://config")def get_config() -> str: """Return configuration data.""" return '{"version": "1.0"}'@mcp.promptdef analyze(topic: str) -> str: """Create an analysis prompt.""" return f"Please analyze: {topic}"
The LocalProvider is always queried first when clients request components, ensuring that your directly-defined components take precedence over those from mounted or proxied servers.
from fastmcp.tools import Tool# Create a tool objectmy_tool = Tool.from_function(some_function, name="custom_tool")# Add it to the servermcp.add_tool(my_tool)mcp.add_resource(my_resource)mcp.add_prompt(my_prompt)
# Disable by keymcp.disable(keys=["tool:admin_action"])# Disable by tagmcp.disable(tags={"internal"})# Disable multiplemcp.disable(keys=["tool:debug"], tags={"deprecated"})
Use only=True to switch to allowlist mode, where only the specified components are visible:
Copy
# Only show public toolsmcp.enable(tags={"public"}, only=True)# Only show specific toolsmcp.enable(keys=["tool:safe_tool", "tool:read_only"], only=True)
When you enable or disable components, FastMCP automatically sends list_changed notifications to connected clients. Clients that support notifications will refresh their component lists automatically.
Visibility can be controlled at the provider level as well:
Copy
from fastmcp.server.providers import LocalProviderprovider = LocalProvider()@provider.tool(tags={"internal"})def internal_tool() -> str: return "Internal"# Disable at provider levelprovider.disable(tags={"internal"})# This affects all servers using this providermcp = FastMCP("Server", providers=[provider])
When a component is disabled at the provider level, it’s hidden from all servers using that provider. Server-level visibility adds another layer of filtering on top of provider-level visibility.