docs/python-sdk/fastmcp-client-mixins-resources.mdx
fastmcp.client.mixins.resourcesResource-related methods for FastMCP Client.
ClientResourcesMixin <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/resources.py#L30" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Mixin providing resource-related methods for Client.
Methods:
list_resources_mcp <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/resources.py#L35" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>list_resources_mcp(self: Client) -> mcp.types.ListResourcesResult
Send a resources/list request and return the complete MCP protocol result.
Args:
cursor: Optional pagination cursor from a previous request's nextCursor.Returns:
Raises:
RuntimeError: If called while the client is not connected.McpError: If the request results in a TimeoutError | JSONRPCErrorlist_resources <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/resources.py#L58" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>list_resources(self: Client, max_pages: int = AUTO_PAGINATION_MAX_PAGES) -> list[mcp.types.Resource]
Retrieve all resources available on the server.
This method automatically fetches all pages if the server paginates results, returning the complete list. For manual pagination control (e.g., to handle large result sets incrementally), use list_resources_mcp() with the cursor parameter.
Args:
max_pages: Maximum number of pages to fetch before raising. Defaults to 250.Returns:
Raises:
RuntimeError: If the page limit is reached before pagination completes.McpError: If the request results in a TimeoutError | JSONRPCErrorlist_resource_templates_mcp <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/resources.py#L105" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>list_resource_templates_mcp(self: Client) -> mcp.types.ListResourceTemplatesResult
Send a resources/listResourceTemplates request and return the complete MCP protocol result.
Args:
cursor: Optional pagination cursor from a previous request's nextCursor.Returns:
Raises:
RuntimeError: If called while the client is not connected.McpError: If the request results in a TimeoutError | JSONRPCErrorlist_resource_templates <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/resources.py#L128" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>list_resource_templates(self: Client, max_pages: int = AUTO_PAGINATION_MAX_PAGES) -> list[mcp.types.ResourceTemplate]
Retrieve all resource templates available on the server.
This method automatically fetches all pages if the server paginates results, returning the complete list. For manual pagination control (e.g., to handle large result sets incrementally), use list_resource_templates_mcp() with the cursor parameter.
Args:
max_pages: Maximum number of pages to fetch before raising. Defaults to 250.Returns:
Raises:
RuntimeError: If the page limit is reached before pagination completes.McpError: If the request results in a TimeoutError | JSONRPCErrorread_resource_mcp <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/resources.py#L177" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_resource_mcp(self: Client, uri: AnyUrl | str, meta: dict[str, Any] | None = None) -> mcp.types.ReadResourceResult
Send a resources/read request and return the complete MCP protocol result.
Args:
uri: The URI of the resource to read. Can be a string or an AnyUrl object.meta: Request metadata (e.g., for SEP-1686 tasks). Defaults to None.Returns:
Raises:
RuntimeError: If called while the client is not connected.McpError: If the request results in a TimeoutError | JSONRPCErrorread_resource <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/resources.py#L233" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_resource(self: Client, uri: AnyUrl | str) -> list[mcp.types.TextResourceContents | mcp.types.BlobResourceContents]
read_resource <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/resources.py#L243" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_resource(self: Client, uri: AnyUrl | str) -> ResourceTask
read_resource <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/resources.py#L254" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_resource(self: Client, uri: AnyUrl | str) -> list[mcp.types.TextResourceContents | mcp.types.BlobResourceContents] | ResourceTask
Read the contents of a resource or resolved template.
Args:
uri: The URI of the resource to read. Can be a string or an AnyUrl object.version: Specific version to read. If None, reads highest version.meta: Optional request-level metadata.task: If True, execute as background task (SEP-1686). Defaults to False.task_id: Optional client-provided task ID (auto-generated if not provided).ttl: Time to keep results available in milliseconds (default 60s).Returns:
Raises:
RuntimeError: If called while the client is not connected.McpError: If the request results in a TimeoutError | JSONRPCError