-module(mcp_toolkit@transport@interface). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/mcp_toolkit/transport/interface.gleam"). -export([create_transport/1]). -export_type([transport/0, stdio_transport/0, transport_message/0, transport_event/0, transport_interface/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -type transport() :: {stdio, stdio_transport()}. -type stdio_transport() :: stdio_transport. -type transport_message() :: {transport_message, binary(), gleam@option:option(binary())}. -type transport_event() :: {message_received, transport_message()} | {client_connected, binary()} | {client_disconnected, binary()} | {transport_error, binary()}. -type transport_interface() :: {transport_interface, fun((transport_message()) -> {ok, nil} | {error, binary()}), fun(() -> {ok, transport_event()} | {error, binary()}), fun(() -> {ok, gleam@erlang@process:subject(transport_event())} | {error, binary()}), fun(() -> {ok, nil} | {error, binary()})}. -file("src/mcp_toolkit/transport/interface.gleam", 62). -spec stdio_send(transport_message()) -> {ok, nil} | {error, binary()}. stdio_send(Message) -> gleam_stdlib:println(erlang:element(2, Message)), {ok, nil}. -file("src/mcp_toolkit/transport/interface.gleam", 68). -spec stdio_receive() -> {ok, transport_event()} | {error, binary()}. stdio_receive() -> case mcp_toolkit@transport@stdio:read_message() of {ok, Content} -> Transport_msg = {transport_message, Content, none}, {ok, {message_received, Transport_msg}}; {error, _} -> {error, <<"Failed to read from stdin"/utf8>>} end. -file("src/mcp_toolkit/transport/interface.gleam", 78). -spec stdio_start() -> {ok, gleam@erlang@process:subject(transport_event())} | {error, binary()}. stdio_start() -> Event_subject = gleam@erlang@process:new_subject(), {ok, Event_subject}. -file("src/mcp_toolkit/transport/interface.gleam", 84). -spec stdio_stop() -> {ok, nil} | {error, binary()}. stdio_stop() -> {ok, nil}. -file("src/mcp_toolkit/transport/interface.gleam", 52). ?DOC(" Create stdio transport interface\n"). -spec create_stdio_transport() -> {ok, transport_interface()} | {error, binary()}. create_stdio_transport() -> {ok, {transport_interface, fun stdio_send/1, fun stdio_receive/0, fun stdio_start/0, fun stdio_stop/0}}. -file("src/mcp_toolkit/transport/interface.gleam", 43). ?DOC(" Create a transport interface for the given transport type\n"). -spec create_transport(transport()) -> {ok, transport_interface()} | {error, binary()}. create_transport(Transport) -> case Transport of {stdio, _} -> create_stdio_transport() end.