feat/Issue-13: elicitation support (#188)
fixes: #13 Implements elicitation functionality from MCP 2025-06-18 specification. Changes - Add ElicitParams and ElicitResult protocol types - Add ServerSession.Elicit() method and ClientOptions.ElicitationHandler - Schema validation enforces top-level properties only - Support for accept/decline/cancel actions with progress tokens Tests - Integration test in TestEndToEnd - Schema validation, error handling, and capability declaration tests
This commit is contained in:
parent
62db914082
commit
c058c6a93b
1 changed files with 836 additions and 1 deletions
|
|
@ -968,7 +968,39 @@ func (*ResourceUpdatedNotificationParams) isParams() {}
|
|||
|
||||
// TODO(jba): add CompleteRequest and related types.
|
||||
|
||||
// TODO(jba): add ElicitRequest and related types.
|
||||
// A request from the server to elicit additional information from the user via the client.
|
||||
type ElicitParams struct {
|
||||
// This property is reserved by the protocol to allow clients and servers to
|
||||
// attach additional metadata to their responses.
|
||||
Meta `json:"_meta,omitempty"`
|
||||
// The message to present to the user.
|
||||
Message string `json:"message"`
|
||||
// A restricted subset of JSON Schema.
|
||||
// Only top-level properties are allowed, without nesting.
|
||||
RequestedSchema *jsonschema.Schema `json:"requestedSchema"`
|
||||
}
|
||||
|
||||
func (x *ElicitParams) isParams() {}
|
||||
|
||||
func (x *ElicitParams) GetProgressToken() any { return getProgressToken(x) }
|
||||
func (x *ElicitParams) SetProgressToken(t any) { setProgressToken(x, t) }
|
||||
|
||||
// The client's response to an elicitation/create request from the server.
|
||||
type ElicitResult struct {
|
||||
// This property is reserved by the protocol to allow clients and servers to
|
||||
// attach additional metadata to their responses.
|
||||
Meta `json:"_meta,omitempty"`
|
||||
// The user action in response to the elicitation.
|
||||
// - "accept": User submitted the form/confirmed the action
|
||||
// - "decline": User explicitly declined the action
|
||||
// - "cancel": User dismissed without making an explicit choice
|
||||
Action string `json:"action"`
|
||||
// The submitted form data, only present when action is "accept".
|
||||
// Contains values matching the requested schema.
|
||||
Content map[string]any `json:"content,omitempty"`
|
||||
}
|
||||
|
||||
func (*ElicitResult) isResult() {}
|
||||
|
||||
// An Implementation describes the name and version of an MCP implementation, with an optional
|
||||
// title for UI representation.
|
||||
|
|
|
|||
Loading…
Reference in a new issue