ExMCP.Transport.HTTP.LegacySSE (ex_mcp v1.3.0)

Copy Markdown View Source

Client transport for the deprecated MCP 2024-11-05 HTTP+SSE protocol.

This is not Streamable HTTP. transport: :http, use_sse: true GETs the same MCP endpoint after initialize. This transport instead:

  1. GETs {base}/sse (or :sse_path) with Accept: text/event-stream
  2. Reads the first endpoint event (POST URI + sessionId)
  3. POSTs JSON-RPC to that advertised URI
  4. Receives responses and server requests on the GET SSE stream

Options

  • :url - server origin or mount prefix, e.g. "http://localhost:4000"
  • :sse_path - GET path (default "/sse")
  • :post_path - optional override of the advertised POST path; sessionId from the endpoint event is preserved
  • :headers - extra HTTP headers
  • :timeout / :request_timeout / :stream_handshake_timeout

Example

{:ok, client} =
  ExMCP.Client.start_link(
    transport: :sse,
    url: "http://localhost:4000"
  )

Summary

Types

t()

@type t() :: %ExMCP.Transport.HTTP.LegacySSE{
  allowed_private_hosts: [String.t()],
  base_url: String.t(),
  dns_resolver: module() | function(),
  dns_timeout_ms: pos_integer(),
  headers: [{String.t(), String.t()}],
  max_request_bytes: pos_integer(),
  max_response_bytes: pos_integer(),
  max_stream_buffer_bytes: pos_integer(),
  post_url: String.t(),
  session_id: String.t(),
  sse_pid: pid(),
  sse_url: String.t(),
  timeouts: map()
}