- Kotlin 98%
- TypeScript 1.7%
- Shell 0.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Bumps [dev.mokksy:mokksy](https://github.com/mokksy/ai-mocks) from 0.6.1 to 0.6.2. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/mokksy/ai-mocks/releases">dev.mokksy:mokksy's releases</a>.</em></p> <blockquote> <h2>0.6.2</h2> <h2>What's Changed</h2> <ul> <li>Add JSON Schema DSL for type-safe schema construction by <a href="https://github.com/kpavlov"><code>@kpavlov</code></a> in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/472">mokksy/ai-mocks#472</a></li> <li>fix(docs): Update KDocs, fix links and cross-references by <a href="https://github.com/kpavlov"><code>@kpavlov</code></a> in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/476">mokksy/ai-mocks#476</a></li> </ul> <h2>Dependency updates</h2> <ul> <li>fix(deps): update dependency com.anthropic:anthropic-java to v2.9.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/435">mokksy/ai-mocks#435</a></li> <li>fix(deps): update dependency io.netty:netty-bom to v4.2.7.final by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/434">mokksy/ai-mocks#434</a></li> <li>fix(deps): update dependency org.springframework:spring-framework-bom to v6.2.12 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/436">mokksy/ai-mocks#436</a></li> <li>fix(deps): update dependency com.openai:openai-java-client-okhttp to v4.4.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/439">mokksy/ai-mocks#439</a></li> <li>fix(deps): update dependency com.openai:openai-java to v4.4.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/438">mokksy/ai-mocks#438</a></li> <li>fix(deps): update dependency com.openai:openai-java-client-okhttp to v4.5.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/441">mokksy/ai-mocks#441</a></li> <li>chore(deps): update dependency org.jetbrains.kotlinx.kover to v0.9.3 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/437">mokksy/ai-mocks#437</a></li> <li>fix(deps): update dependency com.openai:openai-java to v4.5.0 - autoclosed by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/440">mokksy/ai-mocks#440</a></li> <li>chore(deps): update dependency org.openrewrite.rewrite to v7.19.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/445">mokksy/ai-mocks#445</a></li> <li>fix(deps): update dependency com.google.genai:google-genai to v1.24.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/444">mokksy/ai-mocks#444</a></li> <li>fix(deps): update dependency com.openai:openai-java-client-okhttp to v4.6.1 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/443">mokksy/ai-mocks#443</a></li> <li>fix(deps): update dependency com.openai:openai-java to v4.6.1 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/442">mokksy/ai-mocks#442</a></li> <li>fix(deps): update langchain4j monorepo to v1.8.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/447">mokksy/ai-mocks#447</a></li> <li>chore(deps): update gradle to v9.2.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/449">mokksy/ai-mocks#449</a></li> <li>fix(deps): update dependency net.datafaker:datafaker to v2.5.3 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/448">mokksy/ai-mocks#448</a></li> <li>fix(deps): update dependency com.google.genai:google-genai to v1.25.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/451">mokksy/ai-mocks#451</a></li> <li>chore(deps): update mikepenz/action-junit-report action to v6 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/453">mokksy/ai-mocks#453</a></li> <li>fix(deps): update junit-framework monorepo to v5.14.1 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/452">mokksy/ai-mocks#452</a></li> <li>fix(deps): update dependency com.openai:openai-java-client-okhttp to v4.7.1 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/455">mokksy/ai-mocks#455</a></li> <li>chore(deps): update dependency org.openrewrite.rewrite to v7.20.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/456">mokksy/ai-mocks#456</a></li> <li>fix(deps): update dependency io.ktor:ktor-bom to v3.3.2 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/457">mokksy/ai-mocks#457</a></li> <li>fix(deps): update junit-framework monorepo to v6 (major) by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/460">mokksy/ai-mocks#460</a></li> <li>fix(deps): update dependency com.openai:openai-java to v4.7.1 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/454">mokksy/ai-mocks#454</a></li> <li>fix(deps): update dependency com.google.genai:google-genai to v1.27.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/458">mokksy/ai-mocks#458</a></li> <li>fix(deps): update dependency org.springframework:spring-framework-bom to v6.2.13 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/464">mokksy/ai-mocks#464</a></li> <li>chore(deps): update plugin com.vanniktech.maven.publish to v0.35.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/462">mokksy/ai-mocks#462</a></li> <li>chore(deps): update dependency com.vanniktech:gradle-maven-publish-plugin to v0.35.0 - autoclosed by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/461">mokksy/ai-mocks#461</a></li> <li>fix(deps): update dependency com.openai:openai-java-client-okhttp to v4.8.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/467">mokksy/ai-mocks#467</a></li> <li>fix(deps): update dependency com.openai:openai-java to v4.8.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/466">mokksy/ai-mocks#466</a></li> <li>chore(deps): update gradle to v9.2.1 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/468">mokksy/ai-mocks#468</a></li> <li>fix(deps): update dependency com.google.genai:google-genai to v1.28.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/469">mokksy/ai-mocks#469</a></li> <li>chore(deps): update dependency com.diffplug.spotless:spotless-plugin-gradle to v8.1.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/471">mokksy/ai-mocks#471</a></li> <li>chore(deps): update dependency com.diffplug.spotless to v8.1.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/470">mokksy/ai-mocks#470</a></li> <li>fix(deps): update dependency org.springframework:spring-framework-bom to v6.2.14 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/473">mokksy/ai-mocks#473</a></li> <li>chore(deps): update dependency org.openrewrite.rewrite to v7.21.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/474">mokksy/ai-mocks#474</a></li> <li>chore(deps): update actions/checkout action to v6 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/475">mokksy/ai-mocks#475</a></li> <li>fix(deps): update dependency org.springframework.ai:spring-ai-bom to v1.1.0 by <a href="https://github.com/renovate"><code>@renovate</code></a>[bot] in <a href="https://redirect.github.com/mokksy/ai-mocks/pull/463">mokksy/ai-mocks#463</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/mokksy/ai-mocks/compare/v0.6.1...v0.6.2">https://github.com/mokksy/ai-mocks/compare/v0.6.1...v0.6.2</a></p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href=" |
||
| .github | ||
| buildSrc | ||
| docs | ||
| gradle | ||
| kotlin-sdk | ||
| kotlin-sdk-client | ||
| kotlin-sdk-core | ||
| kotlin-sdk-server | ||
| kotlin-sdk-test | ||
| samples | ||
| .editorconfig | ||
| .gitignore | ||
| AGENTS.md | ||
| build.gradle.kts | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| gradle.properties | ||
| gradlew | ||
| gradlew.bat | ||
| LICENSE | ||
| README.md | ||
| settings.gradle.kts | ||
MCP Kotlin SDK
Kotlin Multiplatform implementation of the Model Context Protocol (MCP), providing both client and server capabilities for integrating with LLM surfaces across various platforms.
Overview
The Model Context Protocol allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction. This SDK implements the MCP specification for Kotlin, enabling you to build applications that can communicate using MCP on the JVM, WebAssembly and iOS.
- Build MCP clients that can connect to any MCP server
- Create MCP servers that expose resources, prompts and tools
- Use standard transports like stdio, SSE, and WebSocket
- Handle all MCP protocol messages and lifecycle events
Samples
- kotlin-mcp-server: demonstrates a multiplatform (JVM, Wasm) MCP server setup with various features and transports.
- weather-stdio-server: shows how to build a Kotlin MCP server providing weather forecast and alerts using STDIO transport.
- kotlin-mcp-client: demonstrates building an interactive Kotlin MCP client that connects to an MCP server via STDIO and integrates with Anthropic’s API.
Installation
Add the new repository to your build file:
repositories {
mavenCentral()
}
Add the dependency:
dependencies {
// See the badge above for the latest version
implementation("io.modelcontextprotocol:kotlin-sdk:$mcpVersion")
}
MCP SDK uses Ktor, but does not come with a specific engine dependency. You should add Ktor client and/or Ktor server dependency to your project yourself, e.g.:
dependencies {
// for client:
implementation("io.ktor:ktor-client-cio:$ktorVersion")
// for server:
implementation("io.ktor:ktor-server-netty:$ktorVersion")
}
Quick Start
Creating a Client
import io.modelcontextprotocol.kotlin.sdk.client.Client
import io.modelcontextprotocol.kotlin.sdk.client.StdioClientTransport
import io.modelcontextprotocol.kotlin.sdk.Implementation
val client = Client(
clientInfo = Implementation(
name = "example-client",
version = "1.0.0"
)
)
val transport = StdioClientTransport(
inputStream = processInputStream,
outputStream = processOutputStream
)
// Connect to server
client.connect(transport)
// List available resources
val resources = client.listResources()
// Read a specific resource
val resourceContent = client.readResource(
ReadResourceRequest(uri = "file:///example.txt")
)
Creating a Server
import io.modelcontextprotocol.kotlin.sdk.server.Server
import io.modelcontextprotocol.kotlin.sdk.server.ServerOptions
import io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport
import io.modelcontextprotocol.kotlin.sdk.ServerCapabilities
val server = Server(
serverInfo = Implementation(
name = "example-server",
version = "1.0.0"
),
options = ServerOptions(
capabilities = ServerCapabilities(
resources = ServerCapabilities.Resources(
subscribe = true,
listChanged = true
)
)
)
){
"This server provides example resources and demonstrates MCP capabilities."
}
// Add a resource
server.addResource(
uri = "file:///example.txt",
name = "Example Resource",
description = "An example text file",
mimeType = "text/plain"
) { request ->
ReadResourceResult(
contents = listOf(
TextResourceContents(
text = "This is the content of the example resource.",
uri = request.uri,
mimeType = "text/plain"
)
)
)
}
// Start server with stdio transport
val transport = StdioServerTransport()
server.connect(transport)
Using SSE Transport
Directly in Ktor's Application:
import io.ktor.server.application.*
import io.modelcontextprotocol.kotlin.sdk.server.mcp
fun Application.module() {
mcp {
Server(
serverInfo = Implementation(
name = "example-sse-server",
version = "1.0.0"
),
options = ServerOptions(
capabilities = ServerCapabilities(
prompts = ServerCapabilities.Prompts(listChanged = null),
resources = ServerCapabilities.Resources(subscribe = null, listChanged = null)
)
),
) {
"This SSE server provides prompts and resources via Server-Sent Events."
}
}
}
Inside a custom Ktor's Route:
import io.ktor.server.application.*
import io.ktor.server.sse.SSE
import io.modelcontextprotocol.kotlin.sdk.server.mcp
fun Application.module() {
install(SSE)
routing {
route("myRoute") {
mcp {
Server(
serverInfo = Implementation(
name = "example-sse-server",
version = "1.0.0"
),
options = ServerOptions(
capabilities = ServerCapabilities(
prompts = ServerCapabilities.Prompts(listChanged = null),
resources = ServerCapabilities.Resources(subscribe = null, listChanged = null)
)
),
) {
"Connect via SSE to interact with this MCP server."
}
}
}
}
}
Contributing
Please see the contribution guide and the Code of conduct before contributing.
License
This project is licensed under the MIT License—see the LICENSE file for details.