Skip to main content

dispatch_inbound_sampling

Function dispatch_inbound_sampling 

Source
pub async fn dispatch_inbound_sampling(
    server_name: &str,
    request: &Value,
) -> Value
Expand description

Dispatch an inbound server-to-client sampling/createMessage request (received while Harn is acting as an MCP client) and return the JSON-RPC response we should send back to the server.

The implementation order matches existing HITL primitives:

  1. If a host_mock("mcp", "sample", ...) matches, use that.
  2. Otherwise, dispatch through the installed HostCallBridge.
  3. If no host can take the call, decline with a structured error so the server can fall back to a sensible default.

On approval, the request is translated into Harn’s llm_call boundary (extract_llm_options + execute_llm_call) so providers pick up the same routing, capability gating, mock interception, and budget plumbing as a script-side llm_call.