ElGraph.MCP.Client.Capabilities (ElGraph v0.3.0)

Copy Markdown View Source

MCP 클라이언트 능력 — sampling / elicitation / roots (SPEC §4, 자주 누락되는 차별점).

서버가 클라이언트에게 역으로 요청하는 기능들이다:

  • sampling/createMessage — 서버가 클라이언트의 LLM으로 보완 생성을 요청.
  • elicitation/create — 서버가 사용자 입력을 요청.
  • roots/list — 서버가 클라이언트가 노출한 파일시스템 root 목록을 조회.

순수 디스패처다 — transport(예: ElGraph.MCP.Client.StreamableHTTP)가 서버 개시 요청을 받으면 handle/3로 응답을 만든다. advertise/1은 제공된 핸들러만 initialize에 광고한다.

핸들러 맵: %{sampling: (params -> map), elicitation: (params -> map), roots: (-> [map])}.

Summary

Functions

제공된 핸들러에 해당하는 클라이언트 capability 맵을 만든다(initialize용).

서버 개시 요청을 핸들러로 디스패치한다.

Types

handlers()

@type handlers() :: %{
  optional(:sampling) => (map() -> map()),
  optional(:elicitation) => (map() -> map()),
  optional(:roots) => (-> [map()])
}

result()

@type result() :: {:result, map()} | {:error, integer(), String.t()}

Functions

advertise(handlers)

@spec advertise(handlers()) :: map()

제공된 핸들러에 해당하는 클라이언트 capability 맵을 만든다(initialize용).

handle(method, params, handlers)

@spec handle(String.t(), map(), handlers()) :: result()

서버 개시 요청을 핸들러로 디스패치한다.