kotlin-sdk/samples/simple-streamable-server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Konstantin Pavlov ad072325c9
samples: update mcp-kotlin to 0.10.0 across sample projects (#645)
## Update mcp-kotlin to 0.10.0 across sample projects

## How Has This Been Tested?
Locally, added ServerIntegrationTest to simple-streamable-server

## Breaking Changes
No

## 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)
- [x] Documentation update
- [x] Test update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [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
2026-03-30 23:47:31 +03:00
..
gradle samples: update mcp-kotlin to 0.10.0 across sample projects (#645) 2026-03-30 23:47:31 +03:00
src samples: update mcp-kotlin to 0.10.0 across sample projects (#645) 2026-03-30 23:47:31 +03:00
build.gradle.kts samples: update mcp-kotlin to 0.10.0 across sample projects (#645) 2026-03-30 23:47:31 +03:00
gradle.properties docs: streamable server sample (#595) 2026-03-10 12:45:21 +01:00
gradlew chore(deps): bump the other-dependencies group across 4 directories with 4 updates (#634) 2026-03-27 00:58:15 +00:00
gradlew.bat chore(deps): bump the other-dependencies group across 4 directories with 4 updates (#634) 2026-03-27 00:58:15 +00:00
README.md docs: streamable server sample (#595) 2026-03-10 12:45:21 +01:00
settings.gradle.kts docs: streamable server sample (#595) 2026-03-10 12:45:21 +01:00

Simple Streamable HTTP Server

A minimal MCP server using the recommended Streamable HTTP transport with optional Bearer token authentication.

Overview

This sample demonstrates a Streamable HTTP MCP server built with Ktor. It exposes tools, a prompt template, and a resource over HTTP, and optionally supports Bearer token authentication. The multi-greet tool showcases server-to-client logging notifications with streaming delays.

Prerequisites

  • JDK 17+

Build & Run

Without authentication

./gradlew run

The server starts on http://localhost:3001/mcp by default.

Connect with the MCP Inspector:

npx @modelcontextprotocol/inspector

In the Inspector UI, select Streamable HTTP transport and enter http://localhost:3001/mcp.

Pass a port number as an argument to change it:

./gradlew run --args="8080"

With authentication

MCP_AUTH_TOKEN=my-secret ./gradlew run --args="--auth"

When --auth is passed, clients must include an Authorization: Bearer <token> header. The token is read from the MCP_AUTH_TOKEN environment variable (required when --auth is used).

Authentication caveats

This sample is intended for demonstration only. In production you should:

  • Use a proper identity provider instead of a static token.
  • Restrict CORS origins to your deployment domain — the sample allows all origins.
  • Serve the endpoint over HTTPS.

MCP Capabilities

Tools

Name Description
greet Returns a greeting for a given name.
multi-greet Sends logging notifications between delayed greetings, demonstrating streaming.

Prompts

Name Description
greeting-template Generates a friendly greeting message for a given name.

Resources

Name URI Description
Default Greeting https://example.com/greetings/default Returns a static "Hello, world!" text.