ExMCP.Client.Operations.Resources (ex_mcp v0.10.0)

View Source

Resource 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

list_resources(client, opts \\ [])

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)

read_resource(client, uri, opts \\ [])

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")

subscribe_resource(client, uri, opts \\ [])

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")

unsubscribe_resource(client, uri, opts \\ [])

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")