ExUtcp.Transports.Mcp.Connection (ex_utcp v0.3.2)

Copy Markdown View Source

Manages MCP connections with JSON-RPC 2.0 communication.

Summary

Functions

Calls a tool using JSON-RPC.

Calls a tool with streaming support.

Returns a specification to start this module under a supervisor.

Closes the connection.

Gets the last used timestamp.

Starts a new MCP connection.

Updates the last used timestamp.

Functions

call_tool(pid, tool_name, args, opts \\ [])

@spec call_tool(pid(), String.t(), map(), keyword()) :: ExUtcp.Types.call_result()

Calls a tool using JSON-RPC.

call_tool_stream(pid, tool_name, args, opts \\ [])

@spec call_tool_stream(pid(), String.t(), map(), keyword()) ::
  ExUtcp.Types.call_result()

Calls a tool with streaming support.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(pid)

@spec close(pid()) :: :ok

Closes the connection.

get_last_used(pid)

@spec get_last_used(pid()) :: integer()

Gets the last used timestamp.

send_notification(pid, method, params, opts \\ [])

@spec send_notification(pid(), String.t(), map(), keyword()) ::
  :ok | {:error, String.t()}

Sends a JSON-RPC notification.

send_request(pid, method, params, opts \\ [])

@spec send_request(pid(), String.t(), map(), keyword()) :: ExUtcp.Types.call_result()

Sends a JSON-RPC request.

start_link(provider, opts \\ [])

@spec start_link(
  ExUtcp.Types.mcp_provider(),
  keyword()
) :: GenServer.on_start()

Starts a new MCP connection.

update_last_used(pid)

@spec update_last_used(pid()) :: :ok

Updates the last used timestamp.