Packages

Official-style Elixir SDK for the Model Context Protocol (MCP) — client and server with stdio and Streamable HTTP transports.

Current section

Files

Jump to
mcp_elixir_sdk lib mcp protocol capabilities root_capabilities.ex
Raw

lib/mcp/protocol/capabilities/root_capabilities.ex

defmodule MCP.Protocol.Capabilities.RootCapabilities do
@moduledoc """
Client capability for filesystem roots.
"""
@derive Jason.Encoder
defstruct [:list_changed]
@type t :: %__MODULE__{
list_changed: boolean() | nil
}
@spec from_map(map()) :: t()
def from_map(map) when is_map(map) do
%__MODULE__{
list_changed: Map.get(map, "listChanged")
}
end
defimpl Jason.Encoder, for: __MODULE__ do
def encode(struct, opts) do
struct
|> Map.from_struct()
|> Enum.reduce(%{}, fn
{_key, nil}, acc -> acc
{:list_changed, val}, acc -> Map.put(acc, :listChanged, val)
{key, val}, acc -> Map.put(acc, key, val)
end)
|> Jason.Encode.map(opts)
end
end
end