A client for MCP servers over Streamable HTTP, on both protocol eras.
{:ok, session} = Sake.Client.connect("https://mcp.example.com/mcp", headers: [{"authorization", "Bearer ..."}])
{:ok, tools, session} = Sake.Client.list_tools(session)
{:ok, result, session} = Sake.Client.call_tool(session, "search", %{"query" => "x"})The client is functional: every call returns the updated session. Pass
on_input: to answer elicitation requests; a 401 comes back as
{:error, {:unauthorized, %Sake.Client.Challenge{}}}.
Summary
Functions
@spec call_tool(Sake.Client.Session.t(), String.t(), map()) :: {:ok, Sake.Client.ToolResult.t(), Sake.Client.Session.t()} | {:error, term(), Sake.Client.Session.t()}
@spec close(Sake.Client.Session.t()) :: :ok
@spec complete( Sake.Client.Session.t(), {:prompt, String.t()} | {:resource, String.t()}, String.t(), String.t() ) :: {:ok, map(), Sake.Client.Session.t()} | {:error, term(), Sake.Client.Session.t()}
@spec connect(String.t(), keyword()) :: {:ok, Sake.Client.Session.t()} | {:error, term()}
@spec discover(Sake.Client.Session.t()) :: {:ok, map(), Sake.Client.Session.t()} | {:error, term(), Sake.Client.Session.t()}
@spec get_prompt(Sake.Client.Session.t(), String.t(), map()) :: {:ok, map(), Sake.Client.Session.t()} | {:error, term(), Sake.Client.Session.t()}
@spec list_prompts(Sake.Client.Session.t()) :: {:ok, [map()], Sake.Client.Session.t()} | {:error, term(), Sake.Client.Session.t()}
@spec list_resource_templates(Sake.Client.Session.t()) :: {:ok, [map()], Sake.Client.Session.t()} | {:error, term(), Sake.Client.Session.t()}
@spec list_resources(Sake.Client.Session.t()) :: {:ok, [map()], Sake.Client.Session.t()} | {:error, term(), Sake.Client.Session.t()}
@spec list_tools(Sake.Client.Session.t()) :: {:ok, [Sake.Tool.Spec.t()], Sake.Client.Session.t()} | {:error, term(), Sake.Client.Session.t()}
@spec ping(Sake.Client.Session.t()) :: {:ok, Sake.Client.Session.t()} | {:error, term(), Sake.Client.Session.t()}
@spec read_resource(Sake.Client.Session.t(), String.t()) :: {:ok, [Sake.Content.t()], Sake.Client.Session.t()} | {:error, term(), Sake.Client.Session.t()}