ExMCP.Server.Transport (ex_mcp v0.9.2)
View SourceTransport configuration and lifecycle management for ExMCP servers.
This module provides unified transport startup and configuration for MCP servers, supporting stdio, HTTP, and Server-Sent Events (SSE) transports.
Usage
# Start with HTTP transport
{:ok, _pid} = ExMCP.Server.Transport.start_server(MyServer, server_info, tools, transport: :http, port: 4000)
# Start with stdio transport
{:ok, _pid} = ExMCP.Server.Transport.start_server(MyServer, server_info, tools, transport: :stdio)
# Start with SSE-enabled HTTP transport
{:ok, _pid} = ExMCP.Server.Transport.start_server(MyServer, server_info, tools, transport: :sse, port: 8080)
Summary
Functions
Lists all available transports and their status.
Gets information about a running server.
Starts an HTTP-based MCP server using Cowboy.
Starts a native Erlang process-based MCP server.
Starts a server with the specified transport configuration.
Starts a stdio-based MCP server.
Starts a test transport-based MCP server.
Stops a running MCP server.
Functions
@spec list_transports() :: map()
Lists all available transports and their status.
Gets information about a running server.
Starts an HTTP-based MCP server using Cowboy.
The HTTP transport allows integration with web applications and provides REST-like access to MCP functionality.
Starts a native Erlang process-based MCP server.
The native transport uses Erlang message passing for high-performance local communication between processes.
Starts a server with the specified transport configuration.
Options
:transport- The transport type (:stdio,:http,:sse,:native,:test):port- Port number for HTTP/SSE transports (default: 4000):host- Host for HTTP/SSE transports (default: "localhost"):cors_enabled- Enable CORS for HTTP transports (default: true):sse_enabled- Enable SSE for HTTP transports (default: false, true for :sse transport)
Examples
# HTTP server
ExMCP.Server.Transport.start_server(MyServer, %{name: "my-server", version: "1.0.0"}, [],
transport: :http, port: 4000)
# Stdio server
ExMCP.Server.Transport.start_server(MyServer, %{name: "my-server", version: "1.0.0"}, [],
transport: :stdio)
Starts a stdio-based MCP server.
The stdio transport communicates via standard input/output, making it suitable for command-line tools and scripting environments.
Starts a test transport-based MCP server.
The test transport uses in-memory communication for efficient testing without external processes or network connections.
Stops a running MCP server.