Sake.Server behaviour (Sake v0.1.0)

Copy Markdown View Source

The server module lists the components and their scopes.

defmodule MyApp.MCP do
  use Sake.Server, name: "myapp", version: "1.0.0", instructions: "..."
  scope "issues:read", "Read issues"
  tools [MyApp.MCP.SearchIssues]
  resources [MyApp.MCP.Issue]
  prompts [MyApp.MCP.Triage]
end

Options: name, version (required), instructions, ttl (default 300 000 ms), cache_scope (:public or :private; default: private when the endpoint has authorization, public otherwise), page_size (default 100), extensions (a map for extension negotiation).

On the modern protocol, list and read results carry ttlMs: the server's ttl, or less. A tool, resource or prompt with its own ttl: shortens the ttlMs of every list page that includes it, and a resource's ttl: also sets the ttlMs of its resources/read result (the shortest ttl always wins).

Summary

Functions

Whether the request may see or call the component: no token means no gating.

Tells listening clients that the list of tools, resources or prompts changed.

Tells subscribed clients that a resource changed.

Functions

allowed?(arg1, context)

@spec allowed?(struct(), Sake.Context.t()) :: boolean()

Whether the request may see or call the component: no token means no gating.

capabilities(server)

@spec capabilities(module()) :: map()

notify_list_changed(server, kind)

@spec notify_list_changed(module(), :tools | :resources | :prompts) :: :ok

Tells listening clients that the list of tools, resources or prompts changed.

prompt(server, name)

@spec prompt(module(), String.t()) :: {:ok, Sake.Prompt.Spec.t()} | :error

prompts(list)

(macro)

resource(server, uri)

@spec resource(module(), String.t()) :: {:ok, Sake.Resource.Spec.t(), map()} | :error

resource_updated(server, uri)

@spec resource_updated(module(), String.t()) :: :ok

Tells subscribed clients that a resource changed.

resources(list)

(macro)

scope(name, description)

(macro)

tool(server, name)

@spec tool(module(), String.t()) :: {:ok, Sake.Tool.Spec.t()} | :error

tools(list)

(macro)