fastmcp.resources.resource_manager
Resource manager functionality.
Classes
ResourceManager
Manages FastMCP resources.
Methods:
mount
get_resources
get_resource_templates
list_resources
list_resource_templates
add_resource_or_template_from_fn
fn
: The function to register as a resource or templateuri
: The URI for the resource or templatename
: Optional name for the resource or templatedescription
: Optional description of the resource or templatemime_type
: Optional MIME type for the resource or templatetags
: Optional set of tags for categorizing the resource or template
- The added resource or template. If a resource or template with the same URI already exists,
- returns the existing resource or template.
add_resource_from_fn
fn
: The function to register as a resourceuri
: The URI for the resourcename
: Optional name for the resourcedescription
: Optional description of the resourcemime_type
: Optional MIME type for the resourcetags
: Optional set of tags for categorizing the resource
- The added resource. If a resource with the same URI already exists,
- returns the existing resource.
add_resource
resource
: A Resource instance to add. The resource’s .key attribute will be used as the storage key. To overwrite it, call Resource.model_copy(key=new_key) before calling this method.
add_template_from_fn
add_template
template
: A ResourceTemplate instance to add. The template’s .key attribute will be used as the storage key. To overwrite it, call ResourceTemplate.model_copy(key=new_key) before calling this method.
- The added template. If a template with the same URI already exists,
- returns the existing template.
has_resource
get_resource
uri
: The URI of the resource to get
NotFoundError
: If no resource or template matching the URI is found.