feat: add notification for elicitation complete (#667)
closes #546 ## How Has This Been Tested? unit ## Breaking Changes none ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed
This commit is contained in:
parent
3617ce4e15
commit
e5e5ec206f
4 changed files with 186 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ public sealed interface Method {
|
|||
NotificationsToolsListChanged("notifications/tools/list_changed"),
|
||||
NotificationsRootsListChanged("notifications/roots/list_changed"),
|
||||
NotificationsPromptsListChanged("notifications/prompts/list_changed"),
|
||||
NotificationsElicitationComplete("notifications/elicitation/complete"),
|
||||
NotificationsTasksStatus("notifications/tasks/status"),
|
||||
ToolsList("tools/list"),
|
||||
ToolsCall("tools/call"),
|
||||
|
|
|
|||
|
|
@ -330,6 +330,36 @@ public data class RootsListChangedNotification(override val params: BaseNotifica
|
|||
override val method: Method = Method.Defined.NotificationsRootsListChanged
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Elicitation Complete Notification
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* An optional notification from the server to the client,
|
||||
* informing it of a completion of an out-of-band elicitation request.
|
||||
*
|
||||
* @property params Parameters identifying which elicitation completed.
|
||||
*/
|
||||
@Serializable
|
||||
public data class ElicitationCompleteNotification(override val params: ElicitationCompleteNotificationParams) :
|
||||
ServerNotification {
|
||||
@EncodeDefault
|
||||
override val method: Method = Method.Defined.NotificationsElicitationComplete
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for a notifications/elicitation/complete notification.
|
||||
*
|
||||
* @property elicitationId The ID of the elicitation that completed.
|
||||
* @property meta Optional metadata for this notification.
|
||||
*/
|
||||
@Serializable
|
||||
public data class ElicitationCompleteNotificationParams(
|
||||
val elicitationId: String,
|
||||
@SerialName("_meta")
|
||||
override val meta: JsonObject? = null,
|
||||
) : NotificationParams
|
||||
|
||||
// ============================================================================
|
||||
// Tools List Changed Notification
|
||||
// ============================================================================
|
||||
|
|
|
|||
|
|
@ -241,6 +241,7 @@ private val serverNotificationDeserializers: Map<String, DeserializationStrategy
|
|||
Method.Defined.NotificationsResourcesListChanged.value to ResourceListChangedNotification.serializer(),
|
||||
Method.Defined.NotificationsToolsListChanged.value to ToolListChangedNotification.serializer(),
|
||||
Method.Defined.NotificationsPromptsListChanged.value to PromptListChangedNotification.serializer(),
|
||||
Method.Defined.NotificationsElicitationComplete.value to ElicitationCompleteNotification.serializer(),
|
||||
Method.Defined.NotificationsTasksStatus.value to TaskStatusNotification.serializer(),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -311,6 +311,51 @@ class NotificationTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should serialize ElicitationCompleteNotification with meta`() {
|
||||
val notification = ElicitationCompleteNotification(
|
||||
ElicitationCompleteNotificationParams(
|
||||
elicitationId = "elicit-42",
|
||||
meta = buildJsonObject { put("source", "oauth-flow") },
|
||||
),
|
||||
)
|
||||
|
||||
verifySerialization(
|
||||
notification,
|
||||
McpJson,
|
||||
"""
|
||||
{
|
||||
"method": "notifications/elicitation/complete",
|
||||
"params": {
|
||||
"elicitationId": "elicit-42",
|
||||
"_meta": {
|
||||
"source": "oauth-flow"
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should deserialize ElicitationCompleteNotification`() {
|
||||
val json = """
|
||||
{
|
||||
"method": "notifications/elicitation/complete",
|
||||
"params": {
|
||||
"elicitationId": "elicit-99"
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
val notification = verifyDeserialization<ElicitationCompleteNotification>(McpJson, json)
|
||||
val params = notification.params
|
||||
|
||||
assertEquals(Method.Defined.NotificationsElicitationComplete, notification.method)
|
||||
assertEquals("elicit-99", params.elicitationId)
|
||||
assertNull(params.meta)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should serialize TaskStatusNotification with all fields`() {
|
||||
val notification = TaskStatusNotification(
|
||||
|
|
|
|||
Loading…
Reference in a new issue