McpServer.Conn (HTTP MCP Server v0.6.0)
View SourceProtocol defining the MCP connection interface.
This protocol abstracts the connection details for different transport mechanisms (e.g., HTTP, STDIO, custom transports). It provides a unified way to access session information and other connection-specific data.
Summary
Functions
Retrieves private data associated with the connection.
This function allows you to access previously stored key-value pairs.
If the key does not exist, it returns the provided default value (or nil if no default is given).
Retrieves the session ID associated with the connection.
Stores private data into the connection for later usage. This function allows you to associate arbitrary key-value pairs with the connection.
Types
Functions
Retrieves private data associated with the connection.
This function allows you to access previously stored key-value pairs.
If the key does not exist, it returns the provided default value (or nil if no default is given).
Examples
iex> conn = %McpServer.Conn{private: %{user_role: :admin}}
iex> McpServer.Conn.get_private(conn, :user_role)
:admin
iex> McpServer.Conn.get_private(conn, :nonexistent_key, :default_value)
:default_value
Retrieves the session ID associated with the connection.
The session ID is a unique identifier for the current MCP session.
Examples
iex> conn = %McpServer.Conn{session_id: "abc123"}
iex> McpServer.Conn.get_session_id(conn)
"abc123"
Stores private data into the connection for later usage. This function allows you to associate arbitrary key-value pairs with the connection.
Examples
iex> conn = %McpServer.Conn{}
iex> conn = McpServer.Conn.put_private(conn, :user_role, :admin)
iex> conn.private
%{user_role: :admin}