ExMCP.Transport.Test (ex_mcp v0.9.2)

View Source

In-memory transport for testing purposes.

This transport allows direct communication between client and server processes within the same Elixir VM, without requiring external subprocesses or network connections. It's designed specifically for unit and integration testing.

Usage

# Start a server with test transport
{:ok, server} = ExMCP.Server.start_link(
  transport: :test,
  handler: MyHandler
)

# Start a client connected to that server
{:ok, client} = ExMCP.Client.start_link(
  transport: :test,
  server: server
)

Summary

Functions

receive(state)

receive_message(state, timeout)

recv(state, timeout \\ 5000)

send(state, message)

subscribe(pid, state)

Subscribe to receive transport events (push model).

For the Test 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.