Skip to content

docs: streamable server sample - #595

Merged
devcrocod merged 8 commits into
mainfrom
devcrocod/streamable-server-sample
Mar 10, 2026
Merged

docs: streamable server sample#595
devcrocod merged 8 commits into
mainfrom
devcrocod/streamable-server-sample

Conversation

@devcrocod

Copy link
Copy Markdown
Contributor
  • add a simple streamable http server example with auth
  • update readme: replace quickstart example from sse server to streamable server
  • add readme files for samples, simple-streamable-server, notebooks

closes #170

How Has This Been Tested?

knit and inspector

Breaking Changes

NaN

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Copilot AI 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.

Pull request overview

Adds a new Streamable HTTP server sample (with optional bearer auth) and refreshes the repository docs/samples documentation to prefer Streamable HTTP over the older SSE quickstart path.

Changes:

  • Added simple-streamable-server sample showcasing Streamable HTTP, tools/prompts/resources, and logging notifications.
  • Updated existing sample READMEs and the root README quickstart to use Streamable HTTP.
  • Added/updated README files for the samples/ index and the notebook sample.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
samples/weather-stdio-server/README.md Simplifies and updates weather STDIO server documentation and integration steps.
samples/simple-streamable-server/src/main/kotlin/io/modelcontextprotocol/sample/server/server.kt Implements the Streamable HTTP Ktor server sample with optional authenticated routing.
samples/simple-streamable-server/src/main/kotlin/io/modelcontextprotocol/sample/server/main.kt Adds runnable entrypoint with optional --auth mode.
samples/simple-streamable-server/settings.gradle.kts Defines standalone Gradle build settings for the new sample.
samples/simple-streamable-server/gradlew.bat Adds Windows Gradle wrapper script for the new sample.
samples/simple-streamable-server/gradlew Adds POSIX Gradle wrapper script for the new sample.
samples/simple-streamable-server/gradle/wrapper/gradle-wrapper.properties Configures Gradle wrapper distribution for the new sample.
samples/simple-streamable-server/gradle/wrapper/gradle-wrapper.jar Adds the Gradle wrapper JAR for the new sample.
samples/simple-streamable-server/gradle/libs.versions.toml Declares dependency versions used by the new sample.
samples/simple-streamable-server/gradle.properties Enables Gradle performance flags for the new sample build.
samples/simple-streamable-server/build.gradle.kts Adds dependencies/plugins and application entrypoint for the new sample.
samples/simple-streamable-server/README.md Documents how to run and use the new Streamable HTTP server sample.
samples/notebooks/README.md Documents the notebook-based Streamable HTTP client walkthrough.
samples/kotlin-mcp-server/README.md Repositions SSE modes as backward-compatible and points readers to the new streamable sample.
samples/kotlin-mcp-client/README.md Simplifies and refreshes client sample documentation and links.
samples/README.md Adds a samples index/overview table and navigation entrypoints.
README.md Updates the main quickstart server example to Streamable HTTP and points to the samples overview.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread samples/kotlin-mcp-server/README.md Outdated
Comment thread samples/weather-stdio-server/README.md
Comment thread samples/kotlin-mcp-server/README.md
Comment thread samples/kotlin-mcp-client/README.md
Comment thread samples/simple-streamable-server/README.md
Comment thread samples/weather-stdio-server/README.md
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

… headers, and enforce required `MCP_AUTH_TOKEN` for authentication.
kpavlov
kpavlov previously approved these changes Mar 10, 2026

@kpavlov kpavlov 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.

Looks good in general; however, the example of a streamable server appears awkward.

Please check my comments before merging

Comment thread samples/kotlin-mcp-client/README.md
@@ -0,0 +1,28 @@
package io.modelcontextprotocol.sample.server

import io.ktor.server.cio.CIO

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.

On the JVM target, it's not a good idea to use an exotic server engine that doesn't support HTTP/2. Let's switch to something widely used like Netty or Jetty to showcase a production use case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This remains an example rather than part of the production code
For example, cors and auth are not configured as they would be in production
I can change the engine, that’s not a problem

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.

The file has a bit too much information. Let’s keep the server configuration here, and move the Ktor glue code to a different file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe, but for now I think I'll leave it as is
Later I would refactor part of the code, especially the auth. Then we could either remove it or move it to a separate file

Copilot AI review requested due to automatic review settings March 10, 2026 10:59

Copilot AI 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.

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Copilot AI review requested due to automatic review settings March 10, 2026 11:29
sample:
- kotlin-mcp-client
- kotlin-mcp-server
- simple-streamable-server

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.

👍🏻

@kpavlov kpavlov added the samples Sample projects and examples label Mar 10, 2026

Copilot AI 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.

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment on lines +128 to +135
val sessionId = call.request.header(MCP_SESSION_ID_HEADER)
if (sessionId != null) {
val transport = transports[sessionId]
if (transport == null) {
call.respond(HttpStatusCode.NotFound, "Session not found")
}
return transport
}

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

getOrCreateTransport treats an empty mcp-session-id header as a real session ID (it only checks for null), which leads to a misleading 404 "Session not found" instead of a 400 like findTransport does. Consider using the same isNullOrEmpty() validation (and returning 400) or treating blank as absent and creating a new session, to keep behavior consistent across endpoints.

Copilot uses AI. Check for mistakes.
Comment thread samples/weather-stdio-server/README.md
Comment thread samples/kotlin-mcp-server/README.md
@devcrocod
devcrocod merged commit 0b39f57 into main Mar 10, 2026
22 checks passed
@devcrocod
devcrocod deleted the devcrocod/streamable-server-sample branch March 10, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Sample projects and examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server example - streamable

4 participants