ConduitMcp.Protocol (ConduitMCP v0.9.0)

Copy Markdown View Source

Core MCP (Model Context Protocol) definitions and message handling. Based on specification version 2025-11-25.

Summary

Functions

Core MCP methods as defined in the specification.

Returns the best matching protocol version for the given client version. Returns nil if no compatible version is found.

Creates a notification message.

Creates a success response.

Validates if a message is a valid JSON-RPC 2.0 notification.

Validates if a message is a valid JSON-RPC 2.0 request.

Types

error_object()

@type error_object() :: %{code: integer(), message: String.t(), data: any() | nil}

error_response()

@type error_response() :: %{
  jsonrpc: String.t(),
  id: json_rpc_id(),
  error: error_object()
}

json_rpc_id()

@type json_rpc_id() :: String.t() | integer()

method()

@type method() :: String.t()

notification()

@type notification() :: %{jsonrpc: String.t(), method: method(), params: map() | nil}

request()

@type request() :: %{
  jsonrpc: String.t(),
  id: json_rpc_id(),
  method: method(),
  params: map() | nil
}

response()

@type response() :: success_response() | error_response()

success_response()

@type success_response() :: %{jsonrpc: String.t(), id: json_rpc_id(), result: any()}

Functions

error_response(id, code, message, data \\ nil)

Creates an error response.

internal_error()

See ConduitMcp.Errors.internal_error/0.

invalid_params()

See ConduitMcp.Errors.invalid_params/0.

invalid_request()

See ConduitMcp.Errors.invalid_request/0.

method_not_found()

See ConduitMcp.Errors.method_not_found/0.

methods()

Core MCP methods as defined in the specification.

negotiate_version(client_version)

Returns the best matching protocol version for the given client version. Returns nil if no compatible version is found.

notification(method, params \\ nil)

Creates a notification message.

parse_error()

See ConduitMcp.Errors.parse_error/0.

protocol_version()

resource_not_found()

See ConduitMcp.Errors.resource_not_found/0.

success_response(id, result)

Creates a success response.

supported_versions()

valid_notification?(message)

Validates if a message is a valid JSON-RPC 2.0 notification.

valid_request?(message)

Validates if a message is a valid JSON-RPC 2.0 request.