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:
Pavel Gorgulov 2026-04-02 12:37:33 +02:00 • committed by GitHub
commit e5e5ec206f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 186 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import io.modelcontextprotocol.kotlin.sdk.types.ElicitRequestFormParams
import io.modelcontextprotocol.kotlin.sdk.types.ElicitRequestParams
import io.modelcontextprotocol.kotlin.sdk.types.ElicitRequestURLParams
import io.modelcontextprotocol.kotlin.sdk.types.ElicitResult
import io.modelcontextprotocol.kotlin.sdk.types.ElicitationCompleteNotification
import io.modelcontextprotocol.kotlin.sdk.types.EmptyResult
import io.modelcontextprotocol.kotlin.sdk.types.ListRootsRequest
import io.modelcontextprotocol.kotlin.sdk.types.ListRootsResult
@ -165,6 +166,13 @@ public interface ClientConnection {
* Sends a notification to the client indicating that the list of prompts has changed.
*/
public suspend fun sendPromptListChanged()
/**
* Sends a notification to the client indicating that an out-of-band elicitation has completed.
*
* @param notification Details of the completed elicitation.
*/
public suspend fun sendElicitationComplete(notification: ElicitationCompleteNotification)
}
@Suppress("TooManyFunctions")
@ -270,6 +278,11 @@ internal class ClientConnectionImpl(private val session: ServerSession) : Client
notification(PromptListChangedNotification())
}
override suspend fun sendElicitationComplete(notification: ElicitationCompleteNotification) {
logger.debug { "Sending elicitation complete notification for: ${notification.params.elicitationId}" }
notification(notification)
}
/**
* Determines whether a message with the specified logging level is accepted
* based on the current logging level of the session.

View file

@ -10,6 +10,7 @@ import io.modelcontextprotocol.kotlin.sdk.types.CreateMessageRequest
import io.modelcontextprotocol.kotlin.sdk.types.CreateMessageResult
import io.modelcontextprotocol.kotlin.sdk.types.ElicitRequestParams
import io.modelcontextprotocol.kotlin.sdk.types.ElicitResult
import io.modelcontextprotocol.kotlin.sdk.types.ElicitationCompleteNotification
import io.modelcontextprotocol.kotlin.sdk.types.EmptyJsonObject
import io.modelcontextprotocol.kotlin.sdk.types.EmptyResult
import io.modelcontextprotocol.kotlin.sdk.types.GetPromptRequest
@ -850,6 +851,16 @@ public open class Server(
public suspend fun sendPromptListChanged(sessionId: String) {
clientConnection(sessionId).sendPromptListChanged()
}
/**
* Triggers [ClientConnection.sendElicitationComplete] for session by provided [sessionId].
*
* @param sessionId The session ID to send the elicitation complete notification to.
* @param notification Details of the completed elicitation.
*/
public suspend fun sendElicitationComplete(sessionId: String, notification: ElicitationCompleteNotification) {
clientConnection(sessionId).sendElicitationComplete(notification)
}
// End the ServerSession / ClientConnection redirection section
// Start the notification handling section

View file

@ -9,6 +9,7 @@ import io.modelcontextprotocol.kotlin.sdk.types.CreateMessageRequest
import io.modelcontextprotocol.kotlin.sdk.types.CreateMessageResult
import io.modelcontextprotocol.kotlin.sdk.types.ElicitRequestParams
import io.modelcontextprotocol.kotlin.sdk.types.ElicitResult
import io.modelcontextprotocol.kotlin.sdk.types.ElicitationCompleteNotification
import io.modelcontextprotocol.kotlin.sdk.types.EmptyJsonObject
import io.modelcontextprotocol.kotlin.sdk.types.EmptyResult
import io.modelcontextprotocol.kotlin.sdk.types.Implementation
@ -432,5 +433,13 @@ public open class ServerSession(
* Sends a notification to the client indicating that the list of prompts has changed.
*/
public suspend fun sendPromptListChanged(): Unit = clientConnection.sendPromptListChanged()
/**
* Sends a notification to the client indicating that an out-of-band elicitation has completed.
*
* @param notification Details of the completed elicitation.
*/
public suspend fun sendElicitationComplete(notification: ElicitationCompleteNotification): Unit =
clientConnection.sendElicitationComplete(notification)
// End the ClientConnection redirection section
}