ExMCP.Client.Operations.Resources (ex_mcp v0.10.0)
View SourceResource operations for ExMCP client.
This module handles all resource-related operations including listing available resources, reading resource content, and managing resource subscriptions.
Summary
Functions
Lists all available resources from the MCP server.
Reads a specific resource by its URI.
Subscribes to changes for a specific resource.
Unsubscribes from changes for a specific resource.
Functions
@spec list_resources(ExMCP.Client.Types.client(), ExMCP.Client.Types.request_opts()) :: ExMCP.Client.Types.mcp_response()
Lists all available resources from the MCP server.
Options
:timeout- Request timeout (default: 5000):format- Response format (default: :map)
Examples
{:ok, resources} = ExMCP.Client.Operations.Resources.list_resources(client)
@spec read_resource( ExMCP.Client.Types.client(), ExMCP.Client.Types.uri(), ExMCP.Client.Types.request_opts() ) :: ExMCP.Client.Types.mcp_response()
Reads a specific resource by its URI.
Parameters
client- The MCP client process.uri- The URI of the resource to read.
Options
:timeout- Request timeout (default: 10000):format- Response format (default: :map)
Examples
{:ok, resource_content} = ExMCP.Client.Operations.Resources.read_resource(client, "mcp://example/resource")
@spec subscribe_resource( ExMCP.Client.Types.client(), ExMCP.Client.Types.uri(), ExMCP.Client.Types.request_opts() ) :: ExMCP.Client.Types.mcp_response()
Subscribes to changes for a specific resource.
The client will receive notifications when the resource is updated.
Parameters
client- The MCP client process.uri- The URI of the resource to subscribe to.
Options
:timeout- Request timeout (default: 5000):format- Response format (default: :map)
Examples
{:ok, subscription} = ExMCP.Client.Operations.Resources.subscribe_resource(client, "mcp://example/resource")
@spec unsubscribe_resource( ExMCP.Client.Types.client(), ExMCP.Client.Types.uri(), ExMCP.Client.Types.request_opts() ) :: ExMCP.Client.Types.mcp_response()
Unsubscribes from changes for a specific resource.
Parameters
client- The MCP client process.uri- The URI of the resource to unsubscribe from.
Options
:timeout- Request timeout (default: 5000):format- Response format (default: :map)
Examples
{:ok, result} = ExMCP.Client.Operations.Resources.unsubscribe_resource(client, "mcp://example/resource")