ExMCP.Transport.Local (ex_mcp v1.0.0-rc.0)

View Source

Local BEAM transport for ExMCP.

This module provides a high-performance transport for BEAM-based communication. It carries MCP-shaped JSON-RPC messages as Elixir terms between local processes. The transport itself does not JSON encode or decode messages.

Features

  • MCP-shaped message passing without JSON serialization
  • Direct process-to-process communication
  • Built-in fault tolerance
  • Low latency for local communication

Configuration

This transport is configured via ExMCP.Client.start_link/1:

{:ok, client} = ExMCP.Client.start_link(
  transport: :beam,
  server: server_pid
)

Options:

  • :server - Required for client mode if connecting to a server process.
  • :timeout - Optional. Call timeout in milliseconds (default: 5000).

Summary

Functions

Subscribe to receive transport events (push model).

Types

t()

@type t() :: %ExMCP.Transport.Local{
  connected: boolean(),
  forwarder_pid: term(),
  role: :client | :server,
  server_pid: pid() | nil,
  subscriber: term(),
  timeout: pos_integer()
}

Functions

receive_message(transport, timeout)

subscribe(pid, state)

Subscribe to receive transport events (push model).

For the Local transport, the peer already sends {:transport_message, msg} to the client process. The Client GenServer handles these directly, so subscribe just signals that no receiver task is needed.