fastmcp.server.providers.local_provider
LocalProvider for locally-defined MCP components.
This module provides the LocalProvider class that manages tools, resources,
templates, and prompts registered via decorators or direct methods.
LocalProvider can be used standalone and attached to multiple servers:
Classes
LocalProvider
Provider for locally-defined components.
Supports decorator-based registration (@provider.tool, @provider.resource,
@provider.prompt) and direct object registration methods.
When used standalone, LocalProvider uses default settings. When attached
to a FastMCP server via the server’s decorators, server-level settings
like _tool_serializer and _support_tasks_by_default are injected.
Methods:
add_tool
remove_tool
add_resource
remove_resource
add_template
remove_template
add_prompt
remove_prompt
add_tool_transformation
tool_name: The name of the tool to transform.transformation: The transformation configuration.
get_tool_transformation
tool_name: The name of the tool.
- The transformation config, or None if not found.
remove_tool_transformation
tool_name: The name of the tool.
list_tools
get_tool
list_resources
get_resource
list_resource_templates
get_resource_template
list_prompts
get_prompt
get_component
get_tasks
tool
tool
tool
- @provider.tool (without parentheses)
- @provider.tool() (with empty parentheses)
- @provider.tool(“custom_name”) (with name as first argument)
- @provider.tool(name=“custom_name”) (with name as keyword argument)
- provider.tool(function, name=“custom_name”) (direct function call)
name_or_fn: Either a function (when used as @tool), a string name, or Nonename: Optional name for the tool (keyword-only, alternative to name_or_fn)title: Optional title for the tooldescription: Optional description of what the tool doesicons: Optional icons for the tooltags: Optional set of tags for categorizing the tooloutput_schema: Optional JSON schema for the tool’s outputannotations: Optional annotations about the tool’s behaviorexclude_args: Optional list of argument names to exclude from the tool schemameta: Optional meta information about the toolenabled: Whether the tool is enabled (default True). If False, adds to blocklist.task: Optional task configuration for background executionserializer: Deprecated. Return ToolResult from your tools for full control over serialization.
- The registered FunctionTool or a decorator function.
resource
uri: URI for the resource (e.g. “resource://my-resource” or “resource://”)name: Optional name for the resourcetitle: Optional title for the resourcedescription: Optional description of the resourceicons: Optional icons for the resourcemime_type: Optional MIME type for the resourcetags: Optional set of tags for categorizing the resourceenabled: Whether the resource is enabled (default True). If False, adds to blocklist.annotations: Optional annotations about the resource’s behaviormeta: Optional meta information about the resourcetask: Optional task configuration for background execution
- A decorator function.
prompt
prompt
prompt
- @provider.prompt (without parentheses)
- @provider.prompt() (with empty parentheses)
- @provider.prompt(“custom_name”) (with name as first argument)
- @provider.prompt(name=“custom_name”) (with name as keyword argument)
- provider.prompt(function, name=“custom_name”) (direct function call)
name_or_fn: Either a function (when used as @prompt), a string name, or Nonename: Optional name for the prompt (keyword-only, alternative to name_or_fn)title: Optional title for the promptdescription: Optional description of what the prompt doesicons: Optional icons for the prompttags: Optional set of tags for categorizing the promptenabled: Whether the prompt is enabled (default True). If False, adds to blocklist.meta: Optional meta information about the prompttask: Optional task configuration for background execution
- The registered FunctionPrompt or a decorator function.

