Packages

Gleam library for building Model Context Protocol servers and transports

Current section

Files

Jump to
mcp_toolkit src mcp_toolkit@transport@util.erl
Raw

src/mcp_toolkit@transport@util.erl

-module(mcp_toolkit@transport@util).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/mcp_toolkit/transport/util.gleam").
-export([json_response/2, string_join/1, method_not_allowed/1]).
-file("src/mcp_toolkit/transport/util.gleam", 14).
-spec json_response(integer(), binary()) -> gleam@http@response:response(mist:response_data()).
json_response(Status, Body) ->
_pipe = gleam@http@response:new(Status),
_pipe@1 = gleam@http@response:set_header(
_pipe,
<<"Content-Type"/utf8>>,
<<"application/json"/utf8>>
),
gleam@http@response:set_body(_pipe@1, {bytes, gleam_stdlib:wrap_list(Body)}).
-file("src/mcp_toolkit/transport/util.gleam", 23).
-spec string_join(list(binary())) -> binary().
string_join(Values) ->
gleam@string:join(Values, <<", "/utf8>>).
-file("src/mcp_toolkit/transport/util.gleam", 6).
-spec method_not_allowed(list(binary())) -> gleam@http@response:response(mist:response_data()).
method_not_allowed(Allowed) ->
_pipe = gleam@http@response:new(405),
_pipe@1 = gleam@http@response:set_header(
_pipe,
<<"Allow"/utf8>>,
string_join(Allowed)
),
gleam@http@response:set_body(
_pipe@1,
{bytes, gleam_stdlib:wrap_list(<<"method not allowed"/utf8>>)}
).