Skip to content

MCP Elicitation

Elicitation is a way for an MCP server to request required information from the user in order to continue.

Elicitation Example

Let's say you are using a travel AI agent, requesting it to book a flight to Mumbai next Tuesday morning before 9am. The agent may know a lot about you, e.g. employer travel policy, your preferred airline, frequent flyer number etc, but it does not know which Mumbai airport.

The MCP server would need to ask you which airport do you prefer. It needs to be translated into a UI popup asking to choose the airport: Mumbai (BOM) or Navi Mumbai (NMI). When you choose an option it gets communicated to the server, booking continues. This is Elicitation.

Note that there may be only one Elicitation handler per MCP client. So, any branching or routing across request types needs to be handled by the elicitation handler.

Code example

(ns hello-mcp-clj.client.elicitation
  (:require
   [plumcp.core.api.capability :as cap]
   [plumcp.core.api.entity-gen :as eg]
   [plumcp.core.schema.schema-defs :as sd]))


(defn ^{:mcp-type :elicitation} elicitation-handler
  [{:as kwargs}]
  (let [;; ...ask user input...
        input {:airport "BOM"
               :name "Mumbai"}
        result (eg/make-elicit-result sd/elicit-action-accept
                                      {:content input})]
    result))


(defn make-elicitation-handler
  "This is the manual equivalent of creating an elicitation handler as
   in the `elicitation-handler` function above."
  []
  (cap/make-elicitation-handler elicitation-handler))