Skip to content

Fix duplicate SSE plugin installation in Ktor application helpers (#1079) - #1092

Merged
devcrocod merged 3 commits into
modelcontextprotocol:mainfrom
soulkeykim:fix/1079-reuse-sse-plugin
Oct 15, 2026
Merged

devcrocod merged 3 commits into
modelcontextprotocol:mainfrom
soulkeykim:fix/1079-reuse-sse-plugin

Conversation

@soulkeykim

Copy link
Copy Markdown
Contributor

Fixes #1079.

Summary

  • Install Ktor's SSE plugin only when it is absent in Application.mcp and the shared Application.mcpStreamableHttp setup.
  • Preserve an application's existing SSE plugin while keeping automatic installation for the usual single-endpoint setup.
  • Add regression coverage for preinstalled SSE in both helpers and two Streamable HTTP endpoints in the same application. Each streamable endpoint completes an MCP initialization and closes its session.

The production change is one import and two guards. There are no public API changes.

Testing

Using JDK 21.0.12.1 and the repository's Gradle 9.8.0 wrapper:

  • Before the production fix, ./gradlew :kotlin-sdk-server:jvmTest --tests '*KtorExtensionsTest' ran 8 cases: the 3 duplicate-install regressions failed with DuplicatePluginException, and the other 5 passed.
  • After the fix, the same command passed all 8 cases.
  • ./gradlew :kotlin-sdk-server:jvmTest passed all 167 server JVM tests, with no failures or skips.
  • ./gradlew :kotlin-sdk-server:ktlintCheck passed.
  • ./gradlew :kotlin-sdk-server:detekt passed, including detektMainJvm.
  • git diff --check passed.

Full :kotlin-sdk-server:checkKotlinAbi could not complete in the validation environment: Kotlin/Native's MinGW dependency download (msys2-mingw-w64-x86_64-2.tar.gz) was blocked by an HTTP 403 from the environment proxy. The ABI result is therefore unverified and should be checked in CI. JS and Wasm compilation completed during the first ABI attempt; non-JVM runtime tests and the full repository build were not run.

@soulkeykim
soulkeykim marked this pull request as ready for review October 1, 2026 23:28
@e5l
e5l requested a review from devcrocod October 13, 2026 07:52
jetbrains-air[bot]
jetbrains-air Bot previously approved these changes Oct 15, 2026

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — the guards match the issue's expected fix and the regression tests cover all three scenarios, so this is approved.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=aa937596-498f-4cde-9fb7-816ea3c3b948

…encies, and improve endpoint handling. Clarify reuse of the `SSE` plugin in `KtorServer` documentation.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — the guards reuse an existing SSE plugin exactly as the issue asked, and the new tests genuinely fail without them, so this is approved.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=0e1d110a-3cbc-45ab-aaaf-22b668f48284

@devcrocod devcrocod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@devcrocod
devcrocod merged commit bb4353f into modelcontextprotocol:main Oct 15, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcpStreamableHttp fails when the SSE plugin is already installed

2 participants