Server-to-client request helpers for bidirectional MCP communication.
These functions allow MCP servers to send requests back to clients for:
- Sampling — request LLM inference from the client
- Elicitation — request user input via forms or URLs
- Roots — query client filesystem boundaries
Important
Server-to-client requests require a bidirectional transport (SSE streaming or equivalent). The client must declare the corresponding capability during initialization.
These are building blocks for advanced MCP features. They construct the JSON-RPC request messages that need to be sent to the client via the active transport connection.
Summary
Functions
Builds a sampling/createMessage request to send to the client.
Builds an elicitation/create request (form mode) to send to the client.
Builds a roots/list request to send to the client.
Builds a log message notification to send to the client.
Builds a progress notification to send to the client.
Builds a prompt list changed notification.
Builds a resource list changed notification.
Builds a resource updated notification to send to the client.
Builds a tool list changed notification.
Functions
Builds a sampling/createMessage request to send to the client.
The client will use its LLM to generate a response based on the provided messages.
Options
:model_preferences- Model selection preferences:system_prompt- System prompt for the LLM:max_tokens- Maximum tokens in the response:tools- Tools available for the LLM to use:tool_choice- Tool selection mode ("auto", "required", "none")
Example
request = ConduitMcp.Client.create_message_request(
[%{"role" => "user", "content" => %{"type" => "text", "text" => "Hello"}}],
max_tokens: 1000
)
Builds an elicitation/create request (form mode) to send to the client.
The client will display a form to the user based on the provided JSON schema.
Example
request = ConduitMcp.Client.elicit_request(
"Please provide your API key",
%{
"type" => "object",
"properties" => %{"api_key" => %{"type" => "string", "title" => "API Key"}},
"required" => ["api_key"]
}
)
Builds a roots/list request to send to the client.
The client will respond with its filesystem root boundaries.
Builds a log message notification to send to the client.
Builds a progress notification to send to the client.
Builds a prompt list changed notification.
Builds a resource list changed notification.
Builds a resource updated notification to send to the client.
Builds a tool list changed notification.