MCPEx.Transport (MCPEx v0.1.0)

Defines the behavior for MCP transport implementations.

The transport layer handles the communication between the client and server, providing abstraction over different transport mechanisms (stdio, HTTP, etc.).

Summary

Functions

Closes the transport connection.

Creates a new transport instance.

Sends a message to the server.

Functions

close(transport)

@spec close(pid()) :: :ok | {:error, term()}

Closes the transport connection.

Parameters

  • transport - The transport to close

Returns

  • :ok - The connection was closed successfully
  • {:error, reason} - Failed to close the connection

create(transport_type, options)

@spec create(
  atom(),
  keyword()
) :: {:ok, pid()} | {:error, term()}

Creates a new transport instance.

Parameters

  • transport_type - The type of transport to create (:stdio, :http, :test)
  • options - Options specific to the transport type

Returns

  • {:ok, pid} - The transport was created successfully
  • {:error, reason} - Failed to create the transport

send(transport, message)

@spec send(pid(), String.t()) :: :ok | {:error, term()}

Sends a message to the server.

Parameters

  • transport - The transport process
  • message - The message to send

Returns

  • :ok - The message was sent successfully
  • {:error, reason} - Failed to send the message