ExMCP.MessageProcessor behaviour (ex_mcp v0.9.2)
View SourceCore message processing abstraction for ExMCP.
The MessageProcessor provides a simple, composable interface for processing MCP messages. It follows the Plug specification pattern used throughout the Elixir ecosystem.
Summary
Functions
Assigns a value to the connection.
Completes progress tracking for a connection.
Halts the plug pipeline.
Creates a new connection.
Process an MCP request using a handler module.
Sets the response on the connection.
Runs a list of plugs on the connection.
Starts progress tracking for a connection if it has a progress token.
Updates progress for a connection.
Types
Callbacks
Functions
@spec assign(ExMCP.MessageProcessor.Conn.t(), atom(), term()) :: ExMCP.MessageProcessor.Conn.t()
Assigns a value to the connection.
@spec complete_progress(ExMCP.MessageProcessor.Conn.t()) :: ExMCP.MessageProcessor.Conn.t()
Completes progress tracking for a connection.
This should be called when a long-running operation finishes, either successfully or with an error.
@spec halt(ExMCP.MessageProcessor.Conn.t()) :: ExMCP.MessageProcessor.Conn.t()
Halts the plug pipeline.
@spec new( map(), keyword() ) :: ExMCP.MessageProcessor.Conn.t()
Creates a new connection.
@spec process(ExMCP.MessageProcessor.Conn.t(), map()) :: ExMCP.MessageProcessor.Conn.t()
Process an MCP request using a handler module.
This is a convenience function that creates a connection, processes it through a handler, and returns the response.
@spec put_response(ExMCP.MessageProcessor.Conn.t(), map()) :: ExMCP.MessageProcessor.Conn.t()
Sets the response on the connection.
@spec run([{module(), opts()}], ExMCP.MessageProcessor.Conn.t()) :: ExMCP.MessageProcessor.Conn.t()
Runs a list of plugs on the connection.
@spec start_progress_tracking(ExMCP.MessageProcessor.Conn.t()) :: ExMCP.MessageProcessor.Conn.t()
Starts progress tracking for a connection if it has a progress token.
This should be called at the beginning of long-running operations.
@spec update_progress( ExMCP.MessageProcessor.Conn.t(), number(), number() | nil, String.t() | nil ) :: ExMCP.MessageProcessor.Conn.t()
Updates progress for a connection.
This is a helper function to send progress notifications during long-running operations.