Compare commits

..
Author SHA1 Message Date
Konstantin Pavlov
5ad049240b chore: bump project version to 0.10.0 in gradle.properties 2026-03-26 19:18:24 +02:00
246 changed files with 3358 additions and 19692 deletions

View file

@ -1,81 +0,0 @@
---
name: kdoc
description: "Add KDoc documentation to Kotlin public API. Use whenever the user asks to document Kotlin code, add KDoc, generate API docs, mentions undocumented public declarations, or wants to improve existing documentation. Also trigger when the user says 'add docs', 'document this class/file/module', 'write KDoc', or asks about missing documentation in Kotlin code."
---
# KDoc Generator
Add KDoc to all public Kotlin declarations (classes, interfaces, objects, functions, properties, enums, type aliases, annotations — including `@Deprecated`). Read the implementation, not just the signature, to write accurate descriptions.
## Tag placement
| Where the declaration lives | Tag |
|---|---|
| Primary-ctor `val` / `var` (public, internal, or protected) | `@property` in class KDoc |
| Primary-ctor `name: Type` (no `val`/`var`) | `@param` in class KDoc |
| Primary-ctor `private val` / `private var` | `@param` in class KDoc |
| Body of class/object/interface/sealed interface | inline `/** */` above the declaration |
| Function parameter | `@param` |
| Non-Unit return type | `@return` |
## Style
- Summary: one concise sentence, third-person verb ("Creates", "Returns", "Represents"). Expand to 2-3 sentences only when genuinely complex.
- **Example block**: mandatory for DSL builders (show full receiver-scope usage); add for complex functions or non-obvious extension functions; skip for one-liners and simple getters.
- KDoc links (`[ClassName]`, `[methodName]`) only where they add navigational value.
- Don't write `@throws` or "suspend" notes.
- Rewrite existing KDoc if incomplete or low quality.
## Examples
**Class with mixed primary-constructor parameters:**
````kotlin
/**
* Manages active client sessions and their lifecycle.
*
* @property maxSessions upper limit on concurrent sessions
* @param scope coroutine scope for session lifecycle tasks
* @param secret used internally for session token signing
*/
public class SessionManager(
public val maxSessions: Int, // public val → @property
scope: CoroutineScope, // no val/var → @param
private val secret: ByteArray, // private val → @param
)
````
**Body and interface properties (inline `/** */`):**
````kotlin
/** Represents an entity that includes additional metadata. */
public interface WithMeta {
/** Optional metadata attached to this entity. */
public val meta: JsonObject?
}
public class Connection(public val id: String) {
/** Capabilities negotiated during the handshake, or `null` before initialize completes. */
public val capabilities: ServerCapabilities? get() = ...
}
````
**Function with Example block:**
````kotlin
/**
* Registers a new tool with the given handler.
*
* Example:
* ```kotlin
* server.addTool(name = "echo", description = "Echoes input back") { request ->
* CallToolResult(content = listOf(TextContent("Echo: ${request.arguments}")))
* }
* ```
*
* @param name unique tool identifier
* @param description human-readable tool description
* @param handler suspend function invoked when the tool is called
* @return the registered tool definition
*/
````

View file

@ -1,109 +1,20 @@
# yaml-language-server: $schema=https://json.schemastore.org/dependabot-2.0.json # Configuration options:
# Configuration: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#about-the-dependabotyml-file
version: 2 version: 2
updates: updates:
# Root Gradle project (includes buildSrc)
- package-ecosystem: "gradle" - package-ecosystem: "gradle"
directory: "/" directory: "/"
schedule: schedule:
interval: "weekly" interval: "weekly"
day: "monday"
commit-message:
prefix: "chore(deps):"
labels: labels:
- "dependencies" - "dependencies"
- "kotlin" - "kotlin"
open-pull-requests-limit: 10
groups:
ktor:
patterns:
- "io.ktor:*"
kotlinx:
patterns:
- "org.jetbrains.kotlinx:*"
kotlin:
patterns:
- "org.jetbrains.kotlin:*"
kotest:
patterns:
- "io.kotest:*"
testing:
patterns:
- "io.mockk:*"
- "dev.mokksy:*"
- "org.awaitility:*"
- "org.junit.jupiter:*"
infrastructure:
patterns:
- "io.netty:*"
- "io.github.oshai:*"
- "org.slf4j:*"
gradle-plugins:
patterns:
- "dev.detekt"
- "org.jetbrains.kotlinx.kover"
- "org.jlleitschuh.gradle.ktlint"
- "org.jetbrains.kotlinx.knit"
- "org.jetbrains.kotlinx.binary-compatibility-validator"
- "org.openapi.generator"
- "org.jetbrains.dokka:*"
- "com.vanniktech:*"
# Samples (independent Gradle builds)
- package-ecosystem: "gradle"
directories:
- "/samples/*"
schedule:
interval: "weekly"
day: "monday"
commit-message:
prefix: "chore(deps):"
labels:
- "dependencies"
- "kotlin"
- "samples"
open-pull-requests-limit: 10
groups:
other-dependencies:
patterns:
- "*"
exclude-patterns:
- "io.ktor*"
- "org.jetbrains.kotlin*"
- "io.modelcontextprotocol*"
# npm (integration tests)
- package-ecosystem: "npm"
directory: "/integration-test/src/jvmTest/typescript"
schedule:
interval: "weekly"
day: "monday"
commit-message:
prefix: "chore(deps):"
labels:
- "dependencies"
- "javascript"
open-pull-requests-limit: 10
groups:
all-dependencies:
patterns:
- "*"
# GitHub Actions
- package-ecosystem: "github-actions" - package-ecosystem: "github-actions"
directory: "/" directory: "/"
schedule: schedule:
interval: "weekly" interval: "weekly"
day: "monday"
commit-message:
prefix: "chore(deps):"
labels: labels:
- "dependencies" - "dependencies"
- "github-actions" - "github-actions"
open-pull-requests-limit: 10
groups:
all-actions:
patterns:
- "*"

View file

@ -24,27 +24,27 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v6
- name: Set up JDK ${{ env.JAVA_VERSION }} - name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }} distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: gradle cache: gradle
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
- name: Generate Dokka Site - name: Generate Dokka Site
run: |- run: |-
./gradlew knit docs:classes docs:knitCheck dokkaGenerate ./gradlew knit docs:classes docs:knitCheck dokkaGenerate
- name: Upload artifact - name: Upload artifact
uses: actions/upload-pages-artifact@v5 uses: actions/upload-pages-artifact@v4
with: with:
path: build/dokka/html path: build/dokka/html
- name: Deploy to GitHub Pages - name: Deploy to GitHub Pages
id: deployment id: deployment
uses: actions/deploy-pages@v5 uses: actions/deploy-pages@v4

View file

@ -27,7 +27,7 @@ jobs:
name: Mark/unmark stale PRs and issues name: Mark/unmark stale PRs and issues
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@v11 - uses: actions/stale@v10
with: with:
debug-only: ${{ env.DRY_RUN }} debug-only: ${{ env.DRY_RUN }}
exempt-draft-pr: true exempt-draft-pr: true
@ -66,7 +66,7 @@ jobs:
name: Close stale PRs and issues name: Close stale PRs and issues
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@v11 - uses: actions/stale@v10
with: with:
debug-only: ${{ env.DRY_RUN }} debug-only: ${{ env.DRY_RUN }}
only-labels: 'stale' only-labels: 'stale'

View file

@ -43,17 +43,17 @@ jobs:
max-workers: 2 max-workers: 2
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v6
- name: Set up JDK ${{ env.JAVA_VERSION }} - name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }} distribution: ${{ env.JAVA_DISTRIBUTION }}
- name: Set up Node.js - name: Set up Node.js
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-latest'
uses: actions/setup-node@v7 uses: actions/setup-node@v6
with: with:
node-version: '22' # increase only after https://github.com/nodejs/node/issues/56645 will be fixed node-version: '22' # increase only after https://github.com/nodejs/node/issues/56645 will be fixed
@ -63,7 +63,7 @@ jobs:
run: npm ci run: npm ci
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
with: with:
validate-wrappers: true validate-wrappers: true
add-job-summary: 'always' add-job-summary: 'always'
@ -104,6 +104,22 @@ jobs:
report_paths: '**/test-results/**/TEST-*.xml' report_paths: '**/test-results/**/TEST-*.xml'
truncate_stack_traces: false truncate_stack_traces: false
- name: Upload coverage reports to Codecov
if: ${{ !cancelled() && matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
report_type: coverage
directory: ./build/reports/kover
files: report.xml
- name: Upload test results to Codecov
if: ${{ !cancelled() && matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
report_type: test_results
- name: Archive Maven Local Repository - name: Archive Maven Local Repository
if: ${{ success() && matrix.os == 'ubuntu-latest' }} if: ${{ success() && matrix.os == 'ubuntu-latest' }}
@ -126,16 +142,16 @@ jobs:
contents: read contents: read
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v6
- name: Set up JDK ${{ env.JAVA_VERSION }} - name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }} distribution: ${{ env.JAVA_DISTRIBUTION }}
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
with: with:
validate-wrappers: true validate-wrappers: true
add-job-summary: 'always' add-job-summary: 'always'
@ -168,16 +184,16 @@ jobs:
name: "Build Sample: ${{ matrix.sample }}" name: "Build Sample: ${{ matrix.sample }}"
timeout-minutes: 10 timeout-minutes: 10
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v6
- name: Set up JDK ${{ env.JAVA_VERSION }} - name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }} distribution: ${{ env.JAVA_DISTRIBUTION }}
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
with: with:
add-job-summary: 'always' add-job-summary: 'always'
cache-read-only: true cache-read-only: true

View file

@ -25,22 +25,22 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v6
- name: Set up JDK ${{ env.JAVA_VERSION }} - name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
distribution: ${{ env.JAVA_DISTRIBUTION }} distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v4.38.0 uses: github/codeql-action/init@v4
with: with:
languages: java-kotlin languages: java-kotlin
build-mode: manual build-mode: manual
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
with: with:
validate-wrappers: true validate-wrappers: true
cache-read-only: true cache-read-only: true
@ -52,6 +52,6 @@ jobs:
--no-daemon --rerun-tasks --stacktrace --no-daemon --rerun-tasks --stacktrace
- name: Analyze - name: Analyze
uses: github/codeql-action/analyze@v4.38.0 uses: github/codeql-action/analyze@v4
with: with:
category: '/language:java-kotlin' category: '/language:java-kotlin'

View file

@ -25,16 +25,16 @@ jobs:
timeout-minutes: 20 timeout-minutes: 20
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v6
- name: Set up JDK - name: Set up JDK
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }} distribution: ${{ env.JAVA_DISTRIBUTION }}
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
with: with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }} cache-read-only: ${{ github.ref != 'refs/heads/main' }}
@ -53,7 +53,7 @@ jobs:
done done
- name: Run conformance tests - name: Run conformance tests
uses: modelcontextprotocol/conformance@v0.1.16 uses: modelcontextprotocol/conformance@v0.1.15
with: with:
mode: server mode: server
url: http://localhost:3001/mcp url: http://localhost:3001/mcp
@ -76,16 +76,16 @@ jobs:
- sse-retry - sse-retry
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v6
- name: Set up JDK - name: Set up JDK
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }} distribution: ${{ env.JAVA_DISTRIBUTION }}
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
with: with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }} cache-read-only: ${{ github.ref != 'refs/heads/main' }}
@ -93,7 +93,7 @@ jobs:
run: ./gradlew :conformance-test:installDist run: ./gradlew :conformance-test:installDist
- name: Run conformance tests - name: Run conformance tests
uses: modelcontextprotocol/conformance@v0.1.16 uses: modelcontextprotocol/conformance@v0.1.15
with: with:
mode: client mode: client
command: conformance-test/build/install/conformance-test/bin/conformance-client command: conformance-test/build/install/conformance-test/bin/conformance-client
@ -107,16 +107,16 @@ jobs:
timeout-minutes: 20 timeout-minutes: 20
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v6
- name: Set up JDK - name: Set up JDK
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }} distribution: ${{ env.JAVA_DISTRIBUTION }}
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
with: with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }} cache-read-only: ${{ github.ref != 'refs/heads/main' }}
@ -124,7 +124,7 @@ jobs:
run: ./gradlew :conformance-test:installDist run: ./gradlew :conformance-test:installDist
- name: Run conformance tests - name: Run conformance tests
uses: modelcontextprotocol/conformance@v0.1.16 uses: modelcontextprotocol/conformance@v0.1.15
with: with:
mode: client mode: client
command: conformance-test/build/install/conformance-test/bin/conformance-client command: conformance-test/build/install/conformance-test/bin/conformance-client
@ -146,16 +146,16 @@ jobs:
- auth/cross-app-access-complete-flow - auth/cross-app-access-complete-flow
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v6
- name: Set up JDK - name: Set up JDK
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }} distribution: ${{ env.JAVA_DISTRIBUTION }}
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
with: with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }} cache-read-only: ${{ github.ref != 'refs/heads/main' }}
@ -163,7 +163,7 @@ jobs:
run: ./gradlew :conformance-test:installDist run: ./gradlew :conformance-test:installDist
- name: Run conformance tests - name: Run conformance tests
uses: modelcontextprotocol/conformance@v0.1.16 uses: modelcontextprotocol/conformance@v0.1.15
with: with:
mode: client mode: client
command: conformance-test/build/install/conformance-test/bin/conformance-client command: conformance-test/build/install/conformance-test/bin/conformance-client

View file

@ -1,23 +0,0 @@
name: Auto-merge Dependabot
on: pull_request
permissions:
contents: write
pull-requests: write
jobs:
auto-merge:
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: dependabot/fetch-metadata@v3
id: metadata
- if: >-
steps.metadata.outputs.package-ecosystem == 'github_actions' ||
steps.metadata.outputs.package-ecosystem == 'npm_and_yarn'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -17,23 +17,18 @@ jobs:
packages: write packages: write
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v6
- name: Set up JDK 21 - name: Set up JDK 21
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
java-version: '21' java-version: '21'
distribution: 'temurin' distribution: 'temurin'
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: '22' # increase only after https://github.com/nodejs/node/issues/56645 will be fixed
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
- name: Check - name: Build
run: ./gradlew check --no-configuration-cache run: ./gradlew build --rerun-tasks --max-workers 2 --continue
- name: Publish to Maven Central Portal - name: Publish to Maven Central Portal
id: publish id: publish

View file

@ -36,16 +36,16 @@ jobs:
name: Build Sample (${{ matrix.sample }}) name: Build Sample (${{ matrix.sample }})
timeout-minutes: 10 timeout-minutes: 10
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v6
- name: Set up JDK ${{ env.JAVA_VERSION }} - name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v6 uses: actions/setup-java@v5
with: with:
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }} distribution: ${{ env.JAVA_DISTRIBUTION }}
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0 uses: gradle/actions/setup-gradle@v5
with: with:
validate-wrappers: true validate-wrappers: true
add-job-summary: 'always' add-job-summary: 'always'

2
.gitignore vendored
View file

@ -56,7 +56,7 @@ node_modules
dist dist
### SWE agents ### ### SWE agents ###
.claude/ .claude/settings.local.json
.junie/ .junie/
### Conformance test results ### ### Conformance test results ###

9
.idea/detekt.xml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DetektPluginSettings">
<option name="enableDetekt" value="true" />
<option name="enableForProjectResult" value="Accepted" />
<option name="redirectChannels" value="true" />
<option name="treatAsErrors" value="true" />
</component>
</project>

7
.idea/externalDependencies.xml generated Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalDependencies">
<plugin id="detekt" />
<plugin id="com.nbadal.ktlint" />
</component>
</project>

7
.idea/ktlint-plugin.xml generated Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="com.nbadal.ktlint.KtlintProjectSettings">
<ktlintMode>DISTRACT_FREE</ktlintMode>
<ktlintRulesetVersion>DEFAULT</ktlintRulesetVersion>
</component>
</project>

View file

@ -19,34 +19,34 @@ standardized protocol interface.
* [Overview](#overview) * [Overview](#overview)
* [Installation](#installation) * [Installation](#installation)
* [Artifacts](#artifacts) * [Artifacts](#artifacts)
* [Gradle setup (JVM)](#gradle-setup-jvm) * [Gradle setup (JVM)](#gradle-setup-jvm)
* [Multiplatform](#multiplatform) * [Multiplatform](#multiplatform)
* [Ktor dependencies](#ktor-dependencies) * [Ktor dependencies](#ktor-dependencies)
* [Quickstart](#quickstart) * [Quickstart](#quickstart)
* [Creating a Client](#creating-a-client) * [Creating a Client](#creating-a-client)
* [Creating a Server](#creating-a-server) * [Creating a Server](#creating-a-server)
* [Core Concepts](#core-concepts) * [Core Concepts](#core-concepts)
* [MCP Primitives](#mcp-primitives) * [MCP Primitives](#mcp-primitives)
* [Capabilities](#capabilities) * [Capabilities](#capabilities)
* [Server Capabilities](#server-capabilities) * [Server Capabilities](#server-capabilities)
* [Client Capabilities](#client-capabilities) * [Client Capabilities](#client-capabilities)
* [Server Features](#server-features) * [Server Features](#server-features)
* [Prompts](#prompts) * [Prompts](#prompts)
* [Resources](#resources) * [Resources](#resources)
* [Tools](#tools) * [Tools](#tools)
* [Completion](#completion) * [Completion](#completion)
* [Logging](#logging) * [Logging](#logging)
* [Pagination](#pagination) * [Pagination](#pagination)
* [Client Features](#client-features) * [Client Features](#client-features)
* [Roots](#roots) * [Roots](#roots)
* [Sampling](#sampling) * [Sampling](#sampling)
* [Transports](#transports) * [Transports](#transports)
* [STDIO Transport](#stdio-transport) * [STDIO Transport](#stdio-transport)
* [Streamable HTTP Transport](#streamable-http-transport) * [Streamable HTTP Transport](#streamable-http-transport)
* [SSE Transport](#sse-transport) * [SSE Transport](#sse-transport)
* [WebSocket Transport](#websocket-transport) * [WebSocket Transport](#websocket-transport)
* [ChannelTransport (testing)](#channeltransport-testing) * [ChannelTransport (testing)](#channeltransport-testing)
* [Connecting your server](#connecting-your-server) * [Connecting your server](#connecting-your-server)
* [Examples](#examples) * [Examples](#examples)
* [Documentation](#documentation) * [Documentation](#documentation)
@ -188,19 +188,24 @@ the [simple-streamable-server](samples/simple-streamable-server) sample.
<!--- CLEAR --> <!--- CLEAR -->
```kotlin ```kotlin
import io.ktor.serialization.kotlinx.json.json
import io.ktor.server.application.install
import io.ktor.server.cio.CIO import io.ktor.server.cio.CIO
import io.ktor.server.engine.embeddedServer import io.ktor.server.engine.embeddedServer
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.modelcontextprotocol.kotlin.sdk.server.Server import io.modelcontextprotocol.kotlin.sdk.server.Server
import io.modelcontextprotocol.kotlin.sdk.server.ServerOptions import io.modelcontextprotocol.kotlin.sdk.server.ServerOptions
import io.modelcontextprotocol.kotlin.sdk.server.mcpStreamableHttp import io.modelcontextprotocol.kotlin.sdk.server.mcpStreamableHttp
import io.modelcontextprotocol.kotlin.sdk.types.CallToolResult import io.modelcontextprotocol.kotlin.sdk.types.CallToolResult
import io.modelcontextprotocol.kotlin.sdk.types.Implementation import io.modelcontextprotocol.kotlin.sdk.types.Implementation
import io.modelcontextprotocol.kotlin.sdk.types.McpJson
import io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities import io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities
import io.modelcontextprotocol.kotlin.sdk.types.TextContent import io.modelcontextprotocol.kotlin.sdk.types.TextContent
import io.modelcontextprotocol.kotlin.sdk.types.ToolSchema import io.modelcontextprotocol.kotlin.sdk.types.ToolSchema
import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put import kotlinx.serialization.json.put
fun main(args: Array<String>) { fun main(args: Array<String>) {
val port = args.firstOrNull()?.toIntOrNull() ?: 3000 val port = args.firstOrNull()?.toIntOrNull() ?: 3000
val mcpServer = Server( val mcpServer = Server(
@ -228,6 +233,9 @@ fun main(args: Array<String>) {
} }
embeddedServer(CIO, host = "127.0.0.1", port = port) { embeddedServer(CIO, host = "127.0.0.1", port = port) {
install(ContentNegotiation) {
json(McpJson)
}
mcpStreamableHttp { mcpStreamableHttp {
mcpServer mcpServer
} }
@ -729,7 +737,7 @@ val client = Client(
) )
client.setRequestHandler<CreateMessageRequest>(Method.Defined.SamplingCreateMessage) { request, _ -> client.setRequestHandler<CreateMessageRequest>(Method.Defined.SamplingCreateMessage) { request, _ ->
val content = request.messages.lastOrNull()?.content?.firstOrNull() val content = request.messages.lastOrNull()?.content
val prompt = if (content is TextContent) content.text else "your topic" val prompt = if (content is TextContent) content.text else "your topic"
CreateMessageResult( CreateMessageResult(
model = "gpt-4o-mini", model = "gpt-4o-mini",
@ -766,10 +774,8 @@ CLI tooling that spawns a helper process. No networking setup is required.
`StreamableHttpClientTransport` and the Ktor `mcpStreamableHttp()` / `mcpStatelessStreamableHttp()` helpers expose MCP `StreamableHttpClientTransport` and the Ktor `mcpStreamableHttp()` / `mcpStatelessStreamableHttp()` helpers expose MCP
over a single HTTP endpoint with optional JSON-only or SSE streaming responses. This is the recommended choice for over a single HTTP endpoint with optional JSON-only or SSE streaming responses. This is the recommended choice for
remote deployments and integrates nicely with proxies or service meshes. remote deployments and integrates nicely with proxies or service meshes. Both accept a `path` parameter (default:
`"/mcp"`) to mount the endpoint at any URL:
These helpers automatically install `ContentNegotiation` with `McpJson` — do not install it yourself, or a warning will
be logged. Both accept a `path` parameter (default: `"/mcp"`) to mount the endpoint at any URL:
<!--- CLEAR --> <!--- CLEAR -->
<!--- INCLUDE <!--- INCLUDE
@ -803,30 +809,11 @@ embeddedServer(CIO, port = 3000) {
--> -->
<!--- KNIT example-server-routes-01.kt --> <!--- KNIT example-server-routes-01.kt -->
**CORS for browser-based clients (e.g. MCP Inspector):** if you connect from a browser-based
client you need to install the Ktor CORS plugin so that MCP-specific headers are allowed and exposed:
```kotlin
install(CORS) {
anyHost() // restrict to specific origins in production
allowMethod(HttpMethod.Options)
allowMethod(HttpMethod.Get)
allowMethod(HttpMethod.Post)
allowMethod(HttpMethod.Delete)
allowNonSimpleContentTypes = true
allowHeader("Mcp-Session-Id")
allowHeader("Mcp-Protocol-Version")
exposeHeader("Mcp-Session-Id")
exposeHeader("Mcp-Protocol-Version")
}
```
### SSE Transport ### SSE Transport
Server-Sent Events remain available for backwards compatibility with older MCP clients. Two Ktor helpers are provided: Server-Sent Events remain available for backwards compatibility with older MCP clients. Two Ktor helpers are provided:
- **`Application.mcp { }`** — installs SSE and `ContentNegotiation` with `McpJson` automatically, then registers MCP - **`Application.mcp { }`** — installs the SSE plugin automatically and registers MCP endpoints at `/`.
endpoints at `/`. Do not install `ContentNegotiation` yourself — the SDK handles it.
- **`Route.mcp { }`** — registers MCP endpoints at the current route path; requires `install(SSE)` in the application - **`Route.mcp { }`** — registers MCP endpoints at the current route path; requires `install(SSE)` in the application
first. Use this to host MCP alongside other routes or under a path prefix: first. Use this to host MCP alongside other routes or under a path prefix:

View file

@ -1,5 +1,8 @@
import dev.detekt.gradle.extensions.FailOnSeverity
plugins { plugins {
id("mcp.dokka") id("mcp.dokka")
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint) alias(libs.plugins.ktlint)
alias(libs.plugins.kover) alias(libs.plugins.kover)
} }
@ -20,6 +23,16 @@ dependencies {
subprojects { subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint") apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "org.jetbrains.kotlinx.kover") apply(plugin = "org.jetbrains.kotlinx.kover")
if (name != "conformance-test" && name != "docs") {
apply(plugin = "dev.detekt")
detekt {
config = files("$rootDir/config/detekt/detekt.yml")
buildUponDefaultConfig = true
failOnSeverity.set(FailOnSeverity.Error)
}
}
} }
dokka { dokka {

View file

@ -8,7 +8,6 @@ repositories {
} }
dependencies { dependencies {
implementation(libs.detekt.gradle)
implementation(libs.kotlin.gradle) implementation(libs.kotlin.gradle)
implementation(libs.kotlin.serialization) implementation(libs.kotlin.serialization)
implementation(libs.kotlinx.atomicfu.gradle) implementation(libs.kotlinx.atomicfu.gradle)

View file

@ -1,23 +0,0 @@
import dev.detekt.gradle.Detekt
import dev.detekt.gradle.extensions.FailOnSeverity
plugins {
id("dev.detekt")
}
detekt {
config = files("$rootDir/config/detekt/detekt.yml")
buildUponDefaultConfig = false
parallel = true
failOnSeverity = FailOnSeverity.Error
}
tasks.withType<Detekt>().configureEach {
exclude("**/generated/**", "**/generated-sources/**", "**/build/**")
}
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
tasks.named("detekt").configure {
dependsOn("detektMainJvm")
}
}

View file

@ -45,8 +45,14 @@ kotlin {
events("failed") events("failed")
} }
systemProperty("kotest.output.ansi", "true") systemProperty("kotest.output.ansi", "true")
reports {
junitXml.required.set(true)
junitXml.includeSystemOutLog.set(true)
junitXml.includeSystemErrLog.set(true)
}
} }
} }
macosX64()
macosArm64() macosArm64()
linuxX64() linuxX64()
linuxArm64() linuxArm64()
@ -57,3 +63,12 @@ kotlin {
explicitApi = ExplicitApiMode.Strict explicitApi = ExplicitApiMode.Strict
jvmToolchain(21) jvmToolchain(21)
} }
tasks.named("detekt").configure {
dependsOn(
"detektMainJvm",
"detektCommonMainSourceSet",
"detektTestJvm",
"detektCommonTestSourceSet",
)
}

51
codecov.yml Normal file
View file

@ -0,0 +1,51 @@
# Codecov configuration for Mokksy and AI-Mocks
# https://docs.codecov.com/docs/codecov-yaml
codecov:
require_ci_to_pass: yes
coverage:
precision: 2
round: down
status:
project:
default:
target: auto
threshold: 1%
patch:
default:
target: auto
threshold: 1%
comment:
layout: "header, diff, flags, components"
behavior: default
require_changes: true
component_management:
default_rules:
statuses:
- type: project
target: auto
individual_components:
- component_id: kotlin-sdk-core
name: SDK Core
paths:
- kotlin-sdk-core/**
- component_id: kotlin-sdk-client
name: SDK Client
paths:
- kotlin-sdk-client/**
- component_id: kotlin-sdk-server
name: SDK Server
paths:
- kotlin-sdk-server/**
- component_id: kotlin-sdk-testing
name: SDK Testing
paths:
- kotlin-sdk-testing/**

Some files were not shown because too many files have changed in this diff Show more