Skip to content

Commit e873118

Browse files
ochafikclaude
andcommitted
feat(kotlin-sdk): add timeout parameter to sendResourceTeardown
Expose an optional timeout parameter with a sensible 500ms default. This allows hosts to control how long to wait for the App to complete cleanup. `sendResourceTeardown(timeout: Duration = 500.milliseconds)` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent fc87ef5 commit e873118

File tree

1 file changed

+10
-2
lines changed
  • kotlin/src/main/kotlin/io/modelcontextprotocol/apps

1 file changed

+10
-2
lines changed

kotlin/src/main/kotlin/io/modelcontextprotocol/apps/AppBridge.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import io.modelcontextprotocol.apps.transport.McpAppsTransport
55

66
import io.modelcontextprotocol.apps.generated.*
77
import kotlinx.serialization.json.*
8+
import kotlin.time.Duration
9+
import kotlin.time.Duration.Companion.milliseconds
810

911
/**
1012
* Options for configuring AppBridge behavior.
@@ -217,12 +219,18 @@ class AppBridge(
217219
)
218220
}
219221

220-
suspend fun sendResourceTeardown(): McpUiResourceTeardownResult {
222+
/**
223+
* Request the App to perform cleanup before the resource is torn down.
224+
*
225+
* @param timeout Maximum time to wait for the App to respond (default 500ms)
226+
*/
227+
suspend fun sendResourceTeardown(timeout: Duration = 500.milliseconds): McpUiResourceTeardownResult {
221228
return request(
222229
method = "ui/resource-teardown",
223230
params = McpUiResourceTeardownParams(),
224231
paramsSerializer = { JsonObject(emptyMap()) },
225-
resultDeserializer = { McpUiResourceTeardownResult() }
232+
resultDeserializer = { McpUiResourceTeardownResult() },
233+
timeout = timeout
226234
)
227235
}
228236
}

0 commit comments

Comments
 (0)