ExMCP.Protocol.RequestProcessor (ex_mcp v0.9.0)
View SourceProcesses JSON-RPC requests for MCP servers.
This module handles:
- Request routing based on method name
- Standard MCP method implementations
- Delegation to custom handlers
- Response building for each method type
Supported Methods
initialize- Protocol handshake and capability negotiationtools/list- List available toolstools/call- Execute a toolresources/list- List available resourcesresources/read- Read a resourceprompts/list- List available promptsprompts/get- Get a promptnotifications/initialized- Client initialization complete
Summary
Functions
Processes a JSON-RPC request and returns the appropriate response.
Types
Functions
@spec process(request(), state()) :: process_result()
Processes a JSON-RPC request and returns the appropriate response.
Returns:
{:response, response_map, new_state}- Synchronous response{:notification, new_state}- For notifications (no response needed){:async, new_state}- For async operations (response sent separately)
Examples
iex> request = %{"method" => "tools/list", "id" => 123}
iex> RequestProcessor.process(request, state)
{:response, %{"jsonrpc" => "2.0", "id" => 123, "result" => %{"tools" => []}}, state}