[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-modelcontextprotocol--kotlin-sdk":3,"tool-modelcontextprotocol--kotlin-sdk":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":80,"owner_location":80,"owner_email":80,"owner_twitter":80,"owner_website":81,"owner_url":82,"languages":83,"stars":96,"forks":97,"last_commit_at":98,"license":99,"difficulty_score":23,"env_os":100,"env_gpu":101,"env_ram":101,"env_deps":102,"category_tags":111,"github_topics":112,"view_count":23,"oss_zip_url":80,"oss_zip_packed_at":80,"status":16,"created_at":115,"updated_at":116,"faqs":117,"releases":146},3046,"modelcontextprotocol\u002Fkotlin-sdk","kotlin-sdk","The official Kotlin SDK for Model Context Protocol servers and clients. Maintained in collaboration with JetBrains","kotlin-sdk 是 Model Context Protocol (MCP) 的官方 Kotlin 开发工具包，由社区与 JetBrains 共同维护。它旨在帮助开发者轻松构建符合 MCP 标准的客户端与服务端应用，让大语言模型（LLM）能够以统一、标准化的方式获取外部上下文信息，从而将“提供上下文”与“模型交互”这两个环节解耦。\n\n通过 kotlin-sdk，开发者只需编写一套代码，即可同时面向 JVM、Native、JavaScript 以及 WebAssembly 等多种平台发布应用，极大地提升了开发效率与代码复用率。该工具包内置了对 stdio、SSE、Streamable HTTP 和 WebSocket 等多种标准传输协议的支持，并提供了一套对协程友好的 API，方便处理复杂的消息流转与生命周期事件。无论是需要暴露资源、提示词和工具的服务端开发者，还是希望连接各类 MCP 服务的客户端构建者，都能从中获益。\n\n这款工具特别适合熟悉 Kotlin 生态的后端工程师、全栈开发者以及多平台应用架构师使用。如果你正在寻求一种规范化的方式来增强 AI 应用的数据交互能力，或者希","kotlin-sdk 是 Model Context Protocol (MCP) 的官方 Kotlin 开发工具包，由社区与 JetBrains 共同维护。它旨在帮助开发者轻松构建符合 MCP 标准的客户端与服务端应用，让大语言模型（LLM）能够以统一、标准化的方式获取外部上下文信息，从而将“提供上下文”与“模型交互”这两个环节解耦。\n\n通过 kotlin-sdk，开发者只需编写一套代码，即可同时面向 JVM、Native、JavaScript 以及 WebAssembly 等多种平台发布应用，极大地提升了开发效率与代码复用率。该工具包内置了对 stdio、SSE、Streamable HTTP 和 WebSocket 等多种标准传输协议的支持，并提供了一套对协程友好的 API，方便处理复杂的消息流转与生命周期事件。无论是需要暴露资源、提示词和工具的服务端开发者，还是希望连接各类 MCP 服务的客户端构建者，都能从中获益。\n\n这款工具特别适合熟悉 Kotlin 生态的后端工程师、全栈开发者以及多平台应用架构师使用。如果你正在寻求一种规范化的方式来增强 AI 应用的数据交互能力，或者希望在不同的运行环境中无缝集成 MCP 协议，kotlin-sdk 都将是一个专业且高效的选择。","# MCP Kotlin SDK\n\n[![Maven Central](https:\u002F\u002Fimg.shields.io\u002Fmaven-central\u002Fv\u002Fio.modelcontextprotocol\u002Fkotlin-sdk.svg?label=Maven%20Central)](https:\u002F\u002Fcentral.sonatype.com\u002Fartifact\u002Fio.modelcontextprotocol\u002Fkotlin-sdk)\n[![Build](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Factions\u002Fworkflows\u002Fbuild.yml\u002Fbadge.svg?branch=main)](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Factions\u002Fworkflows\u002Fbuild.yml)\n\n[![Kotlin](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fkotlin-2.2+-blueviolet.svg?logo=kotlin)](http:\u002F\u002Fkotlinlang.org)\n[![Kotlin Multiplatform](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPlatforms-%20JVM%20%7C%20Wasm%2FJS%20%7C%20Native%20-blueviolet?logo=kotlin)](https:\u002F\u002Fkotlinlang.org\u002Fdocs\u002Fmultiplatform.html)\n[![JVM](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FJVM-11+-red.svg?logo=jvm)](http:\u002F\u002Fjava.com)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache_2.0-blue.svg)](LICENSE)\n\n\nKotlin Multiplatform SDK for the [Model Context Protocol](https:\u002F\u002Fmodelcontextprotocol.io).\nIt enables Kotlin applications targeting JVM, Native, JS, and Wasm to implement MCP clients and servers using a\nstandardized protocol interface.\n\n## Table of Contents\n\n\u003C!--- TOC -->\n\n* [Overview](#overview)\n* [Installation](#installation)\n  * [Artifacts](#artifacts)\n  * [Gradle setup (JVM)](#gradle-setup-jvm)\n  * [Multiplatform](#multiplatform)\n  * [Ktor dependencies](#ktor-dependencies)\n* [Quickstart](#quickstart)\n  * [Creating a Client](#creating-a-client)\n  * [Creating a Server](#creating-a-server)\n* [Core Concepts](#core-concepts)\n  * [MCP Primitives](#mcp-primitives)\n  * [Capabilities](#capabilities)\n    * [Server Capabilities](#server-capabilities)\n    * [Client Capabilities](#client-capabilities)\n  * [Server Features](#server-features)\n    * [Prompts](#prompts)\n    * [Resources](#resources)\n    * [Tools](#tools)\n    * [Completion](#completion)\n    * [Logging](#logging)\n    * [Pagination](#pagination)\n  * [Client Features](#client-features)\n    * [Roots](#roots)\n    * [Sampling](#sampling)\n* [Transports](#transports)\n  * [STDIO Transport](#stdio-transport)\n  * [Streamable HTTP Transport](#streamable-http-transport)\n  * [SSE Transport](#sse-transport)\n  * [WebSocket Transport](#websocket-transport)\n  * [ChannelTransport (testing)](#channeltransport-testing)\n* [Connecting your server](#connecting-your-server)\n* [Examples](#examples)\n* [Documentation](#documentation)\n* [Contributing](#contributing)\n* [License](#license)\n\n\u003C!--- END -->\n\n## Overview\n\nThe Model Context Protocol allows applications to provide context for LLMs in a standardized way,\nseparating the concerns of providing context from the actual LLM interaction.\nThis Kotlin SDK implements the MCP specification, making it easy to:\n\n- Build MCP **clients** that can connect to any MCP server\n- Create MCP **servers** that expose resources, prompts, and tools\n- Target **JVM, Native, JS, and Wasm** from a single codebase\n- Use standard transports like **stdio**, **SSE**, **Streamable HTTP**, and **WebSocket**\n- Handle MCP protocol messages and lifecycle events with coroutine-friendly APIs\n\n## Installation\n\n### Artifacts\n\n- `io.modelcontextprotocol:kotlin-sdk` – umbrella SDK (client + server APIs)\n- `io.modelcontextprotocol:kotlin-sdk-client` – client-only APIs\n- `io.modelcontextprotocol:kotlin-sdk-server` – server-only APIs\n\n### Gradle setup (JVM)\n\nAdd the Maven Central repository and the SDK dependency:\n\n```kotlin\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    \u002F\u002F See the badge above for the latest version\n    implementation(\"io.modelcontextprotocol:kotlin-sdk:$mcpVersion\")\n}\n```\n\nUse _kotlin-sdk-client_ or _kotlin-sdk-server_ if you only need one side of the API:\n\n```kotlin\ndependencies {\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-client:$mcpVersion\")\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-server:$mcpVersion\")\n}\n```\n\n### Multiplatform\n\nIn a Kotlin Multiplatform project you can add the SDK to commonMain:\n\n```kotlin\ncommonMain {\n    dependencies {\n        \u002F\u002F Works as a common dependency as well as the platform one\n        implementation(\"io.modelcontextprotocol:kotlin-sdk:$mcpVersion\")\n    }\n}\n```\n\n### Ktor dependencies\n\nThe Kotlin MCP SDK uses [Ktor](https:\u002F\u002Fktor.io\u002F), but it does not add Ktor engine dependencies transitively.\nYou need to declare\nKtor [client](https:\u002F\u002Fktor.io\u002Fdocs\u002Fclient-dependencies.html#engine-dependency)\u002F[server](https:\u002F\u002Fktor.io\u002Fdocs\u002Fserver-dependencies.html)\ndependencies yourself (or reuse the ones already used in your project),\nfor example:\n\n```kotlin\ndependencies {\n    \u002F\u002F MCP client with Ktor\n    implementation(\"io.ktor:ktor-client-cio:$ktorVersion\")\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-client:$mcpVersion\")\n\n    \u002F\u002F MCP server with Ktor\n    implementation(\"io.ktor:ktor-server-netty:$ktorVersion\")\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-server:$mcpVersion\")\n}\n```\n\n## Quickstart\n\nLet's create a simple MCP client and server to demonstrate the basic usage of the Kotlin SDK.\n\n\u003C!--- CLEAR -->\n\n### Creating a Client\n\nCreate an MCP client that connects to a server via Streamable HTTP transport and lists available tools:\n\n```kotlin\nimport io.ktor.client.HttpClient\nimport io.ktor.client.plugins.sse.SSE\nimport io.modelcontextprotocol.kotlin.sdk.client.Client\nimport io.modelcontextprotocol.kotlin.sdk.client.StreamableHttpClientTransport\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport kotlinx.coroutines.runBlocking\n\nfun main(args: Array\u003CString>) = runBlocking {\n    val url = args.firstOrNull() ?: \"http:\u002F\u002Flocalhost:3000\u002Fmcp\"\n\n    val httpClient = HttpClient { install(SSE) }\n\n    val client = Client(\n        clientInfo = Implementation(\n            name = \"example-client\",\n            version = \"1.0.0\"\n        )\n    )\n\n    val transport = StreamableHttpClientTransport(\n        client = httpClient,\n        url = url\n    )\n\n    \u002F\u002F Connect to server\n    client.connect(transport)\n\n    \u002F\u002F List available tools\n    val tools = client.listTools().tools\n\n    println(tools)\n}\n```\n\n\u003C!--- KNIT example-quickstart-client-01.kt -->\n\n### Creating a Server\n\nCreate an MCP server that exposes a simple tool and runs on an embedded Ktor server with Streamable HTTP transport.\nFor a full working project with all required dependencies, see\nthe [simple-streamable-server](samples\u002Fsimple-streamable-server) sample.\n\n\u003C!--- CLEAR -->\n\n```kotlin\nimport io.ktor.server.cio.CIO\nimport io.ktor.server.engine.embeddedServer\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.mcpStreamableHttp\nimport io.modelcontextprotocol.kotlin.sdk.types.CallToolResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.TextContent\nimport io.modelcontextprotocol.kotlin.sdk.types.ToolSchema\nimport kotlinx.serialization.json.buildJsonObject\nimport kotlinx.serialization.json.put\n\nfun main(args: Array\u003CString>) {\n    val port = args.firstOrNull()?.toIntOrNull() ?: 3000\n    val mcpServer = Server(\n        serverInfo = Implementation(\n            name = \"example-server\",\n            version = \"1.0.0\"\n        ),\n        options = ServerOptions(\n            capabilities = ServerCapabilities(\n                tools = ServerCapabilities.Tools(listChanged = true),\n            ),\n        )\n    )\n\n    mcpServer.addTool(\n        name = \"example-tool\",\n        description = \"An example tool\",\n        inputSchema = ToolSchema(\n            properties = buildJsonObject {\n                put(\"input\", buildJsonObject { put(\"type\", \"string\") })\n            }\n        )\n    ) { request ->\n        CallToolResult(content = listOf(TextContent(\"Hello, world!\")))\n    }\n    \n    embeddedServer(CIO, host = \"127.0.0.1\", port = port) {\n        mcpStreamableHttp {\n            mcpServer\n        }\n    }.start(wait = true)\n}\n```\n\n\u003C!--- KNIT example-quickstart-server-01.kt -->\n\nYou can run the server and then connect to it using the client or test with the MCP Inspector:\n\n```bash\nnpx -y @modelcontextprotocol\u002Finspector\n```\n\nIn the inspector UI, connect to `http:\u002F\u002Flocalhost:3000\u002Fmcp`.\n\n## Core Concepts\n\n### MCP Primitives\n\nThe MCP protocol defines core primitives that enable communication between servers and clients:\n\n| Primitive     | Server Role                                       | Client Role                            | Description                                       |\n|---------------|---------------------------------------------------|----------------------------------------|---------------------------------------------------|\n| **Prompts**   | Provides prompt templates with optional arguments | Requests and uses prompts              | Interactive templates for LLM interactions        |\n| **Resources** | Exposes data sources (files, API responses, etc.) | Reads and subscribes to resources      | Contextual data for augmenting LLM context        |\n| **Tools**     | Defines executable functions                      | Calls tools to perform actions         | Functions the LLM can invoke to take actions      |\n| **Sampling**  | Requests LLM completions from client              | Executes LLM calls and returns results | Server-initiated LLM requests (reverse direction) |\n\n### Capabilities\n\nCapabilities define what features a server or client supports. They are declared during initialization and determine\nwhat operations are available.\n\n#### Server Capabilities\n\nServers declare their capabilities to inform clients what features they provide:\n\n| Capability     | Feature Flags                 | Description                                                |\n|----------------|-------------------------------|------------------------------------------------------------|\n| `prompts`      | `listChanged`                 | Prompt template management and notifications               |\n| `resources`    | `subscribe`\u003Cbr\u002F>`listChanged` | Resource exposure, subscriptions, and update notifications |\n| `tools`        | `listChanged`                 | Tool discovery, execution, and list change notifications   |\n| `logging`      | -                             | Server logging to client console                           |\n| `completions`  | -                             | Argument autocompletion suggestions                        |\n| `experimental` | Custom properties             | Non-standard experimental features                         |\n\n#### Client Capabilities\n\nClients declare their capabilities to inform servers what features they support:\n\n| Capability     | Feature Flags     | Description                                                 |\n|----------------|-------------------|-------------------------------------------------------------|\n| `sampling`     | -                 | Client can sample from an LLM (execute model requests)      |\n| `roots`        | `listChanged`     | Client exposes root directories and can notify of changes   |\n| `elicitation`  | -                 | Client can display schema\u002Fform dialogs for structured input |\n| `experimental` | Custom properties | Non-standard experimental features                          |\n\n### Server Features\n\nThe `Server` API lets you wire prompts, resources, and tools with only a few lines of Kotlin. Each feature is registered\nup front and then resolved lazily when a client asks for it, so your handlers stay small and suspendable.\n\n#### Prompts\n\nPrompts are user-controlled templates that clients discover via `prompts\u002Flist` and fetch with `prompts\u002Fget` when a user\nchooses one (think slash commands or saved flows). They’re best for repeatable, structured starters rather than ad-hoc\nmodel calls.\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.types.GetPromptResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.PromptArgument\nimport io.modelcontextprotocol.kotlin.sdk.types.PromptMessage\nimport io.modelcontextprotocol.kotlin.sdk.types.Role\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.TextContent\n\nfun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\n        name = \"example-server\",\n        version = \"1.0.0\"\n    ),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            prompts = ServerCapabilities.Prompts(listChanged = true),\n        ),\n    )\n)\n\nserver.addPrompt(\n    name = \"code-review\",\n    description = \"Ask the model to review a diff\",\n    arguments = listOf(\n        PromptArgument(name = \"diff\", description = \"Unified diff\", required = true),\n    ),\n) { request ->\n    GetPromptResult(\n        description = \"Quick code review helper\",\n        messages = listOf(\n            PromptMessage(\n                role = Role.User,\n                content = TextContent(text = \"Review this change:\\n${request.arguments?.get(\"diff\")}\"),\n            ),\n        ),\n    )\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-prompts-01.kt -->\n\nUse prompts for anything that deserves a template: bug triage questions, onboarding checklists, or saved searches. Set\n`listChanged = true` only if your prompt catalog can change at runtime and your server will emit\n`notifications\u002Fprompts\u002Flist_changed` when it does.\n\n#### Resources\n\nResources are application-driven context that clients discover via `resources\u002Flist` or `resources\u002Ftemplates\u002Flist`, then\nfetch with `resources\u002Fread`. Register each one with a stable URI and return a `ReadResourceResult` when asked—contents\ncan be text or binary blobs.\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ReadResourceResult\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.TextResourceContents\n\nfun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\n        name = \"example-server\",\n        version = \"1.0.0\"\n    ),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            resources = ServerCapabilities.Resources(subscribe = true, listChanged = true),\n        ),\n    )\n)\n\nserver.addResource(\n    uri = \"note:\u002F\u002Frelease\u002Flatest\",\n    name = \"Release notes\",\n    description = \"Last deployment summary\",\n    mimeType = \"text\u002Fmarkdown\",\n) { request ->\n    ReadResourceResult(\n        contents = listOf(\n            TextResourceContents(\n                text = \"Ship 42 reached production successfully.\",\n                uri = request.uri,\n                mimeType = \"text\u002Fmarkdown\",\n            ),\n        ),\n    )\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-resources-01.kt -->\n\nResources can be static text, generated JSON, or blobs—anything the client can surface to the user or inject into the\nmodel context. Set `subscribe = true` if you emit `notifications\u002Fresources\u002Fupdated` for changes to specific URIs, and\n`listChanged = true` if you’ll send `notifications\u002Fresources\u002Flist_changed` when the catalog itself changes.\n\n#### Tools\n\nTools are model-controlled capabilities the client exposes to the model. Clients discover them via `tools\u002Flist`, invoke\nthem with `tools\u002Fcall`, and your handlers receive JSON arguments, can emit streaming logs or progress, and return a\n`CallToolResult`. Keep a human in the loop for sensitive operations.\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.types.CallToolResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.TextContent\nimport kotlinx.serialization.json.jsonPrimitive\n\nfun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\n        name = \"example-server\",\n        version = \"1.0.0\"\n    ),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            tools = ServerCapabilities.Tools(listChanged = true),\n        ),\n    )\n)\n\nserver.addTool(\n    name = \"echo\",\n    description = \"Return whatever the user sent back to them\",\n) { request ->\n    val text = request.arguments?.get(\"text\")?.jsonPrimitive?.content ?: \"(empty)\"\n    CallToolResult(content = listOf(TextContent(text = \"Echo: $text\")))\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-tools-01.kt -->\n\nRegister as many tools as you need—long-running jobs can report progress via the request context, and tools can also\ntrigger sampling (see below) when they need the client’s LLM. Set `listChanged = true` only if your tool catalog can\nchange at runtime and your server will emit `notifications\u002Ftools\u002Flist_changed` when it does.\n\n#### Completion\n\nCompletion provides argument suggestions for prompts or resource templates. Declare the `completions` capability and\nhandle `completion\u002Fcomplete` requests to return up to 100 ranked values (include `total`\u002F`hasMore` if you paginate).\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport\nimport io.modelcontextprotocol.kotlin.sdk.types.CompleteRequest\nimport io.modelcontextprotocol.kotlin.sdk.types.CompleteResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.Method\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport kotlinx.io.asSink\nimport kotlinx.io.asSource\nimport kotlinx.io.buffered\n\nsuspend fun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\n        name = \"example-server\",\n        version = \"1.0.0\"\n    ),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            completions = ServerCapabilities.Completions,\n        ),\n    )\n)\n\nval session = server.createSession(\n    StdioServerTransport(\n        inputStream = System.`in`.asSource().buffered(),\n        outputStream = System.out.asSink().buffered()\n    )\n)\n\nsession.setRequestHandler\u003CCompleteRequest>(Method.Defined.CompletionComplete) { request, _ ->\n    val options = listOf(\"kotlin\", \"compose\", \"coroutine\")\n    val matches = options.filter { it.startsWith(request.argument.value.lowercase()) }\n\n    CompleteResult(\n        completion = CompleteResult.Completion(\n            values = matches.take(3),\n            total = matches.size,\n            hasMore = matches.size > 3,\n        ),\n    )\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-util-completions-01.kt -->\n\nUse `context.arguments` to refine suggestions for dependent fields (e.g., framework list filtered by chosen language).\n\n#### Logging\n\nLogging lets the server stream structured log notifications to the client using RFC 5424 levels (`debug` → `emergency`).\nDeclare the `logging` capability; clients can raise the minimum level with `logging\u002FsetLevel`, and the server emits\n`notifications\u002Fmessage` with severity, optional logger name, and JSON data.\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.LoggingLevel\nimport io.modelcontextprotocol.kotlin.sdk.types.LoggingMessageNotification\nimport io.modelcontextprotocol.kotlin.sdk.types.LoggingMessageNotificationParams\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport kotlinx.io.asSink\nimport kotlinx.io.asSource\nimport kotlinx.io.buffered\nimport kotlinx.serialization.json.buildJsonObject\nimport kotlinx.serialization.json.put\n\nsuspend fun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\"example-server\", \"1.0.0\"),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            logging = ServerCapabilities.Logging,\n        ),\n    )\n)\n\nval session = server.createSession(\n    StdioServerTransport(\n        inputStream = System.`in`.asSource().buffered(),\n        outputStream = System.out.asSink().buffered()\n    )\n)\n\nsession.sendLoggingMessage(\n    LoggingMessageNotification(\n        LoggingMessageNotificationParams(\n            level = LoggingLevel.Info,\n            logger = \"startup\",\n            data = buildJsonObject { put(\"message\", \"Server started\") },\n        ),\n    ),\n)\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-util-logging-01.kt -->\n\nKeep logs free of sensitive data, and expect clients to surface them in their own UI.\n\n#### Pagination\n\nList operations return paginated results with an opaque `nextCursor`, clients echo that cursor to fetch the next page.\nSupported list calls: `resources\u002Flist`, `resources\u002Ftemplates\u002Flist`, `prompts\u002Flist`, and `tools\u002Flist`.\nTreat cursors as opaque—don’t parse or persist them across sessions.\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ListResourcesRequest\nimport io.modelcontextprotocol.kotlin.sdk.types.ListResourcesResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Method\nimport io.modelcontextprotocol.kotlin.sdk.types.Resource\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport kotlinx.io.asSink\nimport kotlinx.io.asSource\nimport kotlinx.io.buffered\n\nsuspend fun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\"example-server\", \"1.0.0\"),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            resources = ServerCapabilities.Resources(),\n        ),\n    )\n)\n\nval session = server.createSession(\n    StdioServerTransport(\n        inputStream = System.`in`.asSource().buffered(),\n        outputStream = System.out.asSink().buffered()\n    )\n)\n\nval resources = listOf(\n    Resource(uri = \"note:\u002F\u002F1\", name = \"Note 1\", description = \"First\"),\n    Resource(uri = \"note:\u002F\u002F2\", name = \"Note 2\", description = \"Second\"),\n    Resource(uri = \"note:\u002F\u002F3\", name = \"Note 3\", description = \"Third\"),\n)\nval pageSize = 2\n\nsession.setRequestHandler\u003CListResourcesRequest>(Method.Defined.ResourcesList) { request, _ ->\n    val start = request.params?.cursor?.toIntOrNull() ?: 0\n    val page = resources.drop(start).take(pageSize)\n    val next = if (start + page.size \u003C resources.size) (start + page.size).toString() else null\n\n    ListResourcesResult(\n        resources = page,\n        nextCursor = next,\n    )\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-util-pagination-01.kt -->\n\nInclude `nextCursor` only when more items remain an absent cursor ends pagination.\n\n### Client Features\n\nClients advertise their capabilities (roots, sampling, elicitation, etc.) during initialization. After that they can\nserve requests from the server while still initiating calls such as `listTools` or `callTool`.\n\n#### Roots\n\nRoots let the client declare where the server is allowed to operate. Declare the `roots` capability, respond to\n`roots\u002Flist`, and emit `notifications\u002Froots\u002Flist_changed` if you set `listChanged = true`. URIs **must** be `file:\u002F\u002F`\npaths.\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.client.Client\nimport io.modelcontextprotocol.kotlin.sdk.client.ClientOptions\nimport io.modelcontextprotocol.kotlin.sdk.types.ClientCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\n\nsuspend fun main() {\n-->\n\n```kotlin\nval client = Client(\n    clientInfo = Implementation(\"demo-client\", \"1.0.0\"),\n    options = ClientOptions(\n        capabilities = ClientCapabilities(roots = ClientCapabilities.Roots(listChanged = true)),\n    ),\n)\n\nclient.addRoot(\n    uri = \"file:\u002F\u002F\u002FUsers\u002Fdemo\u002Fprojects\",\n    name = \"Projects\",\n)\nclient.sendRootsListChanged()\n```\n\n\u003C!--- SUFFIX \n}    \n-->\n\n\u003C!--- KNIT example-client-roots-01.kt -->\n\nCall `addRoot`\u002F`removeRoot` whenever your file system view changes, and use `sendRootsListChanged()` to notify the\nserver. Keep root lists user-controlled and revoke entries that are no longer authorized.\n\n#### Sampling\n\nSampling lets the server ask the client to call its preferred LLM. Declare the `sampling` capability (and\n`sampling.tools` if you allow tool-enabled sampling), and handle `sampling\u002FcreateMessage`. Keep a human in the loop for\napprovals.\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.client.Client\nimport io.modelcontextprotocol.kotlin.sdk.client.ClientOptions\nimport io.modelcontextprotocol.kotlin.sdk.types.ClientCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.CreateMessageRequest\nimport io.modelcontextprotocol.kotlin.sdk.types.CreateMessageResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.Method\nimport io.modelcontextprotocol.kotlin.sdk.types.Role\nimport io.modelcontextprotocol.kotlin.sdk.types.TextContent\nimport kotlinx.serialization.json.buildJsonObject\nimport kotlinx.serialization.json.putJsonObject\n\nfun main() {\n-->\n\n```kotlin\nval client = Client(\n    clientInfo = Implementation(\"demo-client\", \"1.0.0\"),\n    options = ClientOptions(\n        capabilities = ClientCapabilities(\n            sampling = buildJsonObject { putJsonObject(\"tools\") { } }, \u002F\u002F drop tools if you don't support tool use\n        ),\n    ),\n)\n\nclient.setRequestHandler\u003CCreateMessageRequest>(Method.Defined.SamplingCreateMessage) { request, _ ->\n    val content = request.messages.lastOrNull()?.content\n    val prompt = if (content is TextContent) content.text else \"your topic\"\n    CreateMessageResult(\n        model = \"gpt-4o-mini\",\n        role = Role.Assistant,\n        content = TextContent(text = \"Here is a short note about $prompt\"),\n    )\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-client-sampling-01.kt -->\n\nInside the handler you can pick any model\u002Fprovider, require approvals, or reject the request. If you don’t support tool\nuse, omit `sampling.tools` from capabilities.\n\n[\u002F\u002F]: # (TODO: add elicitation section)\n\n[\u002F\u002F]: # (#### Elicitation)\n\n## Transports\n\nAll transports share the same API surface, so you can change deployment style without touching business logic. Pick the\ntransport that best matches where the server runs.\n\n### STDIO Transport\n\n`StdioClientTransport` and `StdioServerTransport` tunnel MCP messages over stdin\u002Fstdout—perfect for editor plugins or\nCLI tooling that spawns a helper process. No networking setup is required.\n\n### Streamable HTTP Transport\n\n`StreamableHttpClientTransport` and the Ktor `mcpStreamableHttp()` \u002F `mcpStatelessStreamableHttp()` helpers expose MCP\nover a single HTTP endpoint with optional JSON-only or SSE streaming responses. This is the recommended choice for\nremote deployments and integrates nicely with proxies or service meshes.\n\nThese helpers automatically install `ContentNegotiation` with `McpJson` — do not install it yourself, or a warning will\nbe logged. Both accept a `path` parameter (default: `\"\u002Fmcp\"`) to mount the endpoint at any URL:\n\n\u003C!--- CLEAR -->\n\u003C!--- INCLUDE \nimport io.ktor.server.cio.CIO\nimport io.ktor.server.engine.embeddedServer\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.mcpStreamableHttp\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\n\nprivate class MyServer :\n    Server(\n        serverInfo = Implementation(name = \"ExampleServer\", version = \"1.0\"),\n        options = ServerOptions(capabilities = ServerCapabilities()),\n    )\n\nfun main() {\n-->\n\n```kotlin\nembeddedServer(CIO, port = 3000) {\n    mcpStreamableHttp(path = \"\u002Fapi\u002Fmcp\") {\n        MyServer()\n    }\n}.start(wait = true)\n```\n\n\u003C!--- SUFFIX \n}\n-->\n\u003C!--- KNIT example-server-routes-01.kt -->\n\n**CORS for browser-based clients (e.g. MCP Inspector):** if you connect from a browser-based\nclient you need to install the Ktor CORS plugin so that MCP-specific headers are allowed and exposed:\n\n```kotlin\ninstall(CORS) {\n    anyHost() \u002F\u002F restrict to specific origins in production\n    allowMethod(HttpMethod.Options)\n    allowMethod(HttpMethod.Get)\n    allowMethod(HttpMethod.Post)\n    allowMethod(HttpMethod.Delete)\n    allowNonSimpleContentTypes = true\n    allowHeader(\"Mcp-Session-Id\")\n    allowHeader(\"Mcp-Protocol-Version\")\n    exposeHeader(\"Mcp-Session-Id\")\n    exposeHeader(\"Mcp-Protocol-Version\")\n}\n```\n\n### SSE Transport\n\nServer-Sent Events remain available for backwards compatibility with older MCP clients. Two Ktor helpers are provided:\n\n- **`Application.mcp { }`** — installs SSE and `ContentNegotiation` with `McpJson` automatically, then registers MCP\n  endpoints at `\u002F`. Do not install `ContentNegotiation` yourself — the SDK handles it.\n- **`Route.mcp { }`** — registers MCP endpoints at the current route path; requires `install(SSE)` in the application\n  first. Use this to host MCP alongside other routes or under a path prefix:\n\n\u003C!--- CLEAR -->\n\u003C!--- INCLUDE \nimport io.ktor.server.application.install\nimport io.ktor.server.cio.CIO\nimport io.ktor.server.engine.embeddedServer\nimport io.ktor.server.response.respondText\nimport io.ktor.server.routing.get\nimport io.ktor.server.routing.route\nimport io.ktor.server.routing.routing\nimport io.ktor.server.sse.SSE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.mcp\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\n\nprivate class MyServer :\n    Server(\n        serverInfo = Implementation(name = \"ExampleServer\", version = \"1.0\"),\n        options = ServerOptions(capabilities = ServerCapabilities()),\n    )\n\nfun main() {\n-->\n\n```kotlin\nembeddedServer(CIO, port = 3000) {\n    install(SSE)\n    routing {\n        route(\"\u002Fapi\u002Fmcp\") {\n            mcp { MyServer() }\n        }\n    }\n}.start(wait = true)\n```\n\n\u003C!--- SUFFIX \n}\n-->\n\u003C!--- KNIT example-server-routes-02.kt -->\n\nPrefer Streamable HTTP for new projects.\n\n### WebSocket Transport\n\n`WebSocketClientTransport` plus the matching server utilities provide full-duplex, low-latency connections—useful when\nyou expect lots of notifications or long-running sessions behind a reverse proxy that already terminates WebSockets.\n\n### ChannelTransport (testing)\n\n`ChannelTransport` provides a simple, non-networked transport for testing and local development.\nIt uses Kotlin coroutines channels to provide a full-duplex connection between a client and server,\nallowing for easy testing of MCP functionality without the need for network setup.\n\n## Connecting your server\n\n1. Start a sample HTTP server on port 3000:\n\n    ```bash\n    .\u002Fgradlew :samples:kotlin-mcp-server:run\n    ```\n\n2. Connect with the [MCP Inspector](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Finspector) or Claude Desktop\u002FCode:\n\n   ```bash\n   npx -y @modelcontextprotocol\u002Finspector --connect http:\u002F\u002Flocalhost:3000\n   # or\n   claude mcp add --transport http kotlin-mcp http:\u002F\u002Flocalhost:3000\n   ```\n\n3. In the Inspector, confirm prompts, tools, resources, completions, and logs show up. Iterate locally until you’re\n   ready to host the server wherever you prefer.\n\n## Examples\n\nThe [samples](.\u002Fsamples) directory contains runnable projects demonstrating\nMCP server and client implementations with various transports.\nSee the [samples overview](.\u002Fsamples\u002FREADME.md) for a comparison table and detailed descriptions.\n\n## Documentation\n[![Ask DeepWiki](https:\u002F\u002Fdeepwiki.com\u002Fbadge.svg)](https:\u002F\u002Fdeepwiki.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk)\n\n- [API Reference](https:\u002F\u002Fkotlin.sdk.modelcontextprotocol.io\u002F)\n- [Model Context Protocol documentation](https:\u002F\u002Fmodelcontextprotocol.io)\n- [MCP specification](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002Flatest)\n\n## Contributing\n\nPlease see the [contribution guide](CONTRIBUTING.md) and the [Code of conduct](CODE_OF_CONDUCT.md) before contributing.\n\n## License\n\nThis project is licensed under Apache 2.0 for new contributions, with existing code under MIT—see the [LICENSE](LICENSE)\nfile for details.\n","# MCP Kotlin SDK\n\n[![Maven Central](https:\u002F\u002Fimg.shields.io\u002Fmaven-central\u002Fv\u002Fio.modelcontextprotocol\u002Fkotlin-sdk.svg?label=Maven%20Central)](https:\u002F\u002Fcentral.sonatype.com\u002Fartifact\u002Fio.modelcontextprotocol\u002Fkotlin-sdk)\n[![Build](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Factions\u002Fworkflows\u002Fbuild.yml\u002Fbadge.svg?branch=main)](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Factions\u002Fworkflows\u002Fbuild.yml)\n\n[![Kotlin](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fkotlin-2.2+-blueviolet.svg?logo=kotlin)](http:\u002F\u002Fkotlinlang.org)\n[![Kotlin Multiplatform](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPlatforms-%20JVM%20%7C%20Wasm%2FJS%20%7C%20Native%20-blueviolet?logo=kotlin)](https:\u002F\u002Fkotlinlang.org\u002Fdocs\u002Fmultiplatform.html)\n[![JVM](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FJVM-11+-red.svg?logo=jvm)](http:\u002F\u002Fjava.com)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache_2.0-blue.svg)](LICENSE)\n\n\n适用于 [Model Context Protocol](https:\u002F\u002Fmodelcontextprotocol.io) 的 Kotlin 多平台 SDK。\n它使面向 JVM、Native、JS 和 Wasm 的 Kotlin 应用程序能够使用标准化的协议接口实现 MCP 客户端和服务器。\n\n## 目录\n\n\u003C!--- TOC -->\n\n* [概述](#overview)\n* [安装](#installation)\n  * [构件](#artifacts)\n  * [Gradle 配置 (JVM)](#gradle-setup-jvm)\n  * [多平台](#multiplatform)\n  * [Ktor 依赖项](#ktor-dependencies)\n* [快速入门](#quickstart)\n  * [创建客户端](#creating-a-client)\n  * [创建服务器](#creating-a-server)\n* [核心概念](#core-concepts)\n  * [MCP 原语](#mcp-primitives)\n  * [能力](#capabilities)\n    * [服务器能力](#server-capabilities)\n    * [客户端能力](#client-capabilities)\n  * [服务器功能](#server-features)\n    * [提示](#prompts)\n    * [资源](#resources)\n    * [工具](#tools)\n    * [完成](#completion)\n    * [日志记录](#logging)\n    * [分页](#pagination)\n  * [客户端功能](#client-features)\n    * [根节点](#roots)\n    * [采样](#sampling)\n* [传输层](#transports)\n  * [STDIO 传输](#stdio-transport)\n  * [可流式 HTTP 传输](#streamable-http-transport)\n  * [SSE 传输](#sse-transport)\n  * [WebSocket 传输](#websocket-transport)\n  * [ChannelTransport（测试）](#channeltransport-testing)\n* [连接你的服务器](#connecting-your-server)\n* [示例](#examples)\n* [文档](#documentation)\n* [贡献](#contributing)\n* [许可证](#license)\n\n\u003C!--- END -->\n\n## 概述\n\nModel Context Protocol 允许应用程序以标准化的方式为 LLM 提供上下文，\n将提供上下文的关注点与实际的 LLM 交互分离。\n该 Kotlin SDK 实现了 MCP 规范，使其易于：\n\n- 构建可以连接到任何 MCP 服务器的 MCP **客户端**\n- 创建公开资源、提示和工具的 MCP **服务器**\n- 从单个代码库针对 **JVM、Native、JS 和 Wasm** 进行开发\n- 使用标准传输层，如 **stdio**、**SSE**、**可流式 HTTP** 和 **WebSocket**\n- 使用协程友好的 API 处理 MCP 协议消息和生命周期事件\n\n## 安装\n\n### 构件\n\n- `io.modelcontextprotocol:kotlin-sdk` – 总体 SDK（客户端 + 服务器 API）\n- `io.modelcontextprotocol:kotlin-sdk-client` – 仅客户端 API\n- `io.modelcontextprotocol:kotlin-sdk-server` – 仅服务器 API\n\n### Gradle 配置 (JVM)\n\n添加 Maven Central 仓库和 SDK 依赖项：\n\n```kotlin\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    \u002F\u002F 请参阅上方徽章以获取最新版本\n    implementation(\"io.modelcontextprotocol:kotlin-sdk:$mcpVersion\")\n}\n```\n\n如果您只需要其中一方的 API，请使用 _kotlin-sdk-client_ 或 _kotlin-sdk-server_：\n\n```kotlin\ndependencies {\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-client:$mcpVersion\")\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-server:$mcpVersion\")\n}\n```\n\n### 多平台\n\n在 Kotlin 多平台项目中，您可以将 SDK 添加到 commonMain：\n\n```kotlin\ncommonMain {\n    dependencies {\n        \u002F\u002F 既可用作公共依赖，也可用作平台特定依赖\n        implementation(\"io.modelcontextprotocol:kotlin-sdk:$mcpVersion\")\n    }\n}\n```\n\n### Ktor 依赖项\n\nKotlin MCP SDK 使用 [Ktor](https:\u002F\u002Fktor.io\u002F)，但不会传递性地添加 Ktor 引擎依赖。\n您需要自行声明 Ktor [客户端](https:\u002F\u002Fktor.io\u002Fdocs\u002Fclient-dependencies.html#engine-dependency)\u002F[服务器](https:\u002F\u002Fktor.io\u002Fdocs\u002Fserver-dependencies.html)\n依赖项（或复用项目中已有的依赖项），例如：\n\n```kotlin\ndependencies {\n    \u002F\u002F 带有 Ktor 的 MCP 客户端\n    implementation(\"io.ktor:ktor-client-cio:$ktorVersion\")\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-client:$mcpVersion\")\n\n    \u002F\u002F 带有 Ktor 的 MCP 服务器\n    implementation(\"io.ktor:ktor-server-netty:$ktorVersion\")\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-server:$mcpVersion\")\n}\n```\n\n## 快速入门\n\n让我们创建一个简单的 MCP 客户端和服务器，以演示 Kotlin SDK 的基本用法。\n\n\u003C!--- CLEAR -->\n\n### 创建客户端\n\n创建一个通过可流式 HTTP 传输连接到服务器并列出可用工具的 MCP 客户端：\n\n```kotlin\nimport io.ktor.client.HttpClient\nimport io.ktor.client.plugins.sse.SSE\nimport io.modelcontextprotocol.kotlin.sdk.client.Client\nimport io.modelcontextprotocol.kotlin.sdk.client.StreamableHttpClientTransport\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport kotlinx.coroutines.runBlocking\n\nfun main(args: Array\u003CString>) = runBlocking {\n    val url = args.firstOrNull() ?: \"http:\u002F\u002Flocalhost:3000\u002Fmcp\"\n\n    val httpClient = HttpClient { install(SSE) }\n\n    val client = Client(\n        clientInfo = Implementation(\n            name = \"example-client\",\n            version = \"1.0.0\"\n        )\n    )\n\n    val transport = StreamableHttpClientTransport(\n        client = httpClient,\n        url = url\n    )\n\n    \u002F\u002F 连接到服务器\n    client.connect(transport)\n\n    \u002F\u002F 列出可用工具\n    val tools = client.listTools().tools\n\n    println(tools)\n}\n```\n\n\u003C!--- KNIT example-quickstart-client-01.kt -->\n\n### 创建服务器\n\n创建一个 MCP 服务器，该服务器公开一个简单工具，并在嵌入式 Ktor 服务器上运行，使用 Streamable HTTP 传输协议。\n有关包含所有必需依赖项的完整工作项目，请参阅 [simple-streamable-server](samples\u002Fsimple-streamable-server) 示例。\n\n\u003C!--- 清除 -->\n\n```kotlin\nimport io.ktor.server.cio.CIO\nimport io.ktor.server.engine.embeddedServer\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.mcpStreamableHttp\nimport io.modelcontextprotocol.kotlin.sdk.types.CallToolResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.TextContent\nimport io.modelcontextprotocol.kotlin.sdk.types.ToolSchema\nimport kotlinx.serialization.json.buildJsonObject\nimport kotlinx.serialization.json.put\n\nfun main(args: Array\u003CString>) {\n    val port = args.firstOrNull()?.toIntOrNull() ?: 3000\n    val mcpServer = Server(\n        serverInfo = Implementation(\n            name = \"example-server\",\n            version = \"1.0.0\"\n        ),\n        options = ServerOptions(\n            capabilities = ServerCapabilities(\n                tools = ServerCapabilities.Tools(listChanged = true),\n            ),\n        )\n    )\n\n    mcpServer.addTool(\n        name = \"example-tool\",\n        description = \"一个示例工具\",\n        inputSchema = ToolSchema(\n            properties = buildJsonObject {\n                put(\"input\", buildJsonObject { put(\"type\", \"string\") })\n            }\n        )\n    ) { request ->\n        CallToolResult(content = listOf(TextContent(\"你好，世界！\")))\n    }\n    \n    embeddedServer(CIO, host = \"127.0.0.1\", port = port) {\n        mcpStreamableHttp {\n            mcpServer\n        }\n    }.start(wait = true)\n}\n```\n\n\u003C!--- KNIT example-quickstart-server-01.kt -->\n\n你可以运行该服务器，然后使用客户端连接到它，或者使用 MCP Inspector 进行测试：\n\n```bash\nnpx -y @modelcontextprotocol\u002Finspector\n```\n\n在 Inspector 的 UI 中，连接到 `http:\u002F\u002Flocalhost:3000\u002Fmcp`。\n\n## 核心概念\n\n### MCP 原语\n\nMCP 协议定义了用于实现服务器与客户端之间通信的核心原语：\n\n| 原语     | 服务器角色                                       | 客户端角色                            | 描述                                       |\n|---------------|---------------------------------------------------|----------------------------------------|---------------------------------------------------|\n| **提示**   | 提供带有可选参数的提示模板 | 请求并使用提示              | 用于 LLM 交互的交互式模板        |\n| **资源** | 公开数据源（文件、API 响应等） | 读取并订阅资源      | 用于增强 LLM 上下文的上下文数据        |\n| **工具**     | 定义可执行函数                      | 调用工具以执行操作         | LLM 可以调用以执行动作的函数      |\n| **采样**  | 向客户端请求 LLM 补全               | 执行 LLM 调用并返回结果 | 由服务器发起的 LLM 请求（反向方向） |\n\n### 功能\n\n功能定义了服务器或客户端支持哪些特性。它们在初始化时声明，并决定可用的操作。\n\n#### 服务器功能\n\n服务器会声明其功能，以告知客户端它们提供的特性：\n\n| 功能     | 特性标志                 | 描述                                                |\n|----------------|-------------------------------|------------------------------------------------------------|\n| `prompts`      | `listChanged`                 | 提示模板管理和通知               |\n| `resources`    | `subscribe`\u003Cbr\u002F>`listChanged` | 资源暴露、订阅及更新通知           |\n| `tools`        | `listChanged`                 | 工具发现、执行及列表变更通知       |\n| `logging`      | -                             | 服务器日志记录到客户端控制台       |\n| `completions`  | -                             | 参数自动补全建议                   |\n| `experimental` | 自定义属性             | 非标准实验性功能                         |\n\n#### 客户端功能\n\n客户端会声明其功能，以告知服务器它们支持的特性：\n\n| 功能     | 特性标志     | 描述                                                 |\n|----------------|-------------------|-------------------------------------------------------------|\n| `sampling`     | -                 | 客户端可以从 LLM 中采样（执行模型请求）      |\n| `roots`        | `listChanged`     | 客户端暴露根目录并能通知更改   |\n| `elicitation`  | -                 | 客户端可以显示模式\u002F表单对话框以获取结构化输入 |\n| `experimental` | 自定义属性 | 非标准实验性功能                          |\n\n### 服务器功能\n\n`Server` API 使你只需几行 Kotlin 代码即可将提示、资源和工具连接起来。每个功能都在一开始就注册好，然后在客户端请求时才被延迟解析，因此你的处理程序可以保持简洁且可挂起。\n\n#### 提示\n\n提示是用户可控的模板，客户端可以通过 `prompts\u002Flist` 发现它们，并在用户选择其中一个时通过 `prompts\u002Fget` 获取（类似于斜杠命令或保存的工作流）。它们最适合重复性的、结构化的起点，而不是临时的模型调用。\n\n\u003C!--- 包含\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.types.GetPromptResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.PromptArgument\nimport io.modelcontextprotocol.kotlin.sdk.types.PromptMessage\nimport io.modelcontextprotocol.kotlin.sdk.types.Role\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.TextContent\n\nfun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\n        name = \"example-server\",\n        version = \"1.0.0\"\n    ),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            prompts = ServerCapabilities.Prompts(listChanged = true),\n        ),\n    )\n)\n\nserver.addPrompt(\n    name = \"code-review\",\n    description = \"请求模型审查一个差异文件\",\n    arguments = listOf(\n        PromptArgument(name = \"diff\", description = \"统一格式的差异文件\", required = true),\n    ),\n) { request ->\n    GetPromptResult(\n        description = \"快速代码审查助手\",\n        messages = listOf(\n            PromptMessage(\n                role = Role.User,\n                content = TextContent(text = \"请审查以下更改：\\n${request.arguments?.get(\"diff\")}\"),\n            ),\n        ),\n    )\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-prompts-01.kt -->\n\n将任何需要模板化的内容都使用提示词来处理：例如错误分类问题、入职检查清单或保存的搜索。仅当您的提示词目录可以在运行时发生变化，并且服务器会在发生变更时发出 `notifications\u002Fprompts\u002Flist_changed` 通知时，才设置 `listChanged = true`。\n\n#### 资源\n\n资源是由应用程序驱动的上下文，客户端可以通过 `resources\u002Flist` 或 `resources\u002Ftemplates\u002Flist` 发现它们，然后使用 `resources\u002Fread` 获取。为每个资源注册一个稳定的 URI，并在被请求时返回 `ReadResourceResult`——内容可以是文本或二进制数据块。\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ReadResourceResult\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.TextResourceContents\n\nfun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\n        name = \"example-server\",\n        version = \"1.0.0\"\n    ),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            resources = ServerCapabilities.Resources(subscribe = true, listChanged = true),\n        ),\n    )\n)\n\nserver.addResource(\n    uri = \"note:\u002F\u002Frelease\u002Flatest\",\n    name = \"发布说明\",\n    description = \"最近一次部署摘要\",\n    mimeType = \"text\u002Fmarkdown\",\n) { request ->\n    ReadResourceResult(\n        contents = listOf(\n            TextResourceContents(\n                text = \"版本42已成功部署到生产环境。\",\n                uri = request.uri,\n                mimeType = \"text\u002Fmarkdown\",\n            ),\n        ),\n    )\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-resources-01.kt -->\n\n资源可以是静态文本、生成的 JSON 数据或二进制数据——任何客户端可以呈现给用户或注入到模型上下文中去的内容。如果您会针对特定 URI 的变化发出 `notifications\u002Fresources\u002Fupdated` 通知，则设置 `subscribe = true`；如果资源目录本身会发生变化，则设置 `listChanged = true`，以便在目录变更时发送 `notifications\u002Fresources\u002Flist_changed` 通知。\n\n#### 工具\n\n工具是客户端向模型暴露的由模型控制的功能。客户端通过 `tools\u002Flist` 发现这些工具，使用 `tools\u002Fcall` 调用它们，而您的处理器会接收 JSON 格式的参数，可以输出流式日志或进度信息，并返回 `CallToolResult`。对于敏感操作，请务必保留人工干预环节。\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.types.CallToolResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.TextContent\nimport kotlinx.serialization.json.jsonPrimitive\n\nfun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\n        name = \"example-server\",\n        version = \"1.0.0\"\n    ),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            tools = ServerCapabilities.Tools(listChanged = true),\n        ),\n    )\n)\n\nserver.addTool(\n    name = \"echo\",\n    description = \"将用户发送的内容原样返回给他们\",\n) { request ->\n    val text = request.arguments?.get(\"text\")?.jsonPrimitive?.content ?: \"(空)\"\n    CallToolResult(content = listOf(TextContent(text = \"回声：$text\")))\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-tools-01.kt -->\n\n根据需要注册任意数量的工具——长时间运行的任务可以通过请求上下文报告进度，而工具也可以在需要客户端的 LLM 时触发采样（见下文）。仅当您的工具目录可以在运行时发生变化，并且服务器会在发生变更时发出 `notifications\u002Ftools\u002Flist_changed` 通知时，才设置 `listChanged = true`。\n\n#### 补全功能\n\n补全功能为提示词或资源模板提供参数建议。声明 `completions` 功能，并处理 `completion\u002Fcomplete` 请求，以返回最多 100 个排序后的值（如果分页显示，则应包含 `total` 和 `hasMore`）。\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport\nimport io.modelcontextprotocol.kotlin.sdk.types.CompleteRequest\nimport io.modelcontextprotocol.kotlin.sdk.types.CompleteResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.Method\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport kotlinx.io.asSink\nimport kotlinx.io.asSource\nimport kotlinx.io.buffered\n\nsuspend fun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\n        name = \"example-server\",\n        version = \"1.0.0\"\n    ),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            completions = ServerCapabilities.Completions,\n        ),\n    )\n)\n\nval session = server.createSession(\n    StdioServerTransport(\n        inputStream = System.`in`.asSource().buffered(),\n        outputStream = System.out.asSink().buffered()\n    )\n)\n\nsession.setRequestHandler\u003CCompleteRequest>(Method.Defined.CompletionComplete) { request, _ ->\n    val options = listOf(\"kotlin\", \"compose\", \"coroutine\")\n    val matches = options.filter { it.startsWith(request.argument.value.lowercase()) }\n\n    CompleteResult(\n        completion = CompleteResult.Completion(\n            values = matches.take(3),\n            total = matches.size,\n            hasMore = matches.size > 3,\n        ),\n    )\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-util-completions-01.kt -->\n\n使用 `context.arguments` 来优化依赖字段的建议（例如，根据所选语言筛选框架列表）。\n\n#### 日志记录\n\n日志记录允许服务器使用 RFC 5424 级别（从 `debug` 到 `emergency`）向客户端流式传输结构化日志通知。声明 `logging` 功能；客户端可以通过 `logging\u002FsetLevel` 提升最低日志级别，而服务器则会发出带有严重性、可选的日志记录器名称和 JSON 数据的 `notifications\u002Fmessage` 通知。\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.LoggingLevel\nimport io.modelcontextprotocol.kotlin.sdk.types.LoggingMessageNotification\nimport io.modelcontextprotocol.kotlin.sdk.types.LoggingMessageNotificationParams\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport kotlinx.io.asSink\nimport kotlinx.io.asSource\nimport kotlinx.io.buffered\nimport kotlinx.serialization.json.buildJsonObject\nimport kotlinx.serialization.json.put\n\nsuspend fun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\"example-server\", \"1.0.0\"),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            logging = ServerCapabilities.Logging,\n        ),\n    )\n)\n\nval session = server.createSession(\n    StdioServerTransport(\n        inputStream = System.`in`.asSource().buffered(),\n        outputStream = System.out.asSink().buffered()\n    )\n)\n\nsession.sendLoggingMessage(\n    LoggingMessageNotification(\n        LoggingMessageNotificationParams(\n            level = LoggingLevel.Info,\n            logger = \"startup\",\n            data = buildJsonObject { put(\"message\", \"Server started\") },\n        ),\n    ),\n)\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-util-logging-01.kt -->\n\n日志中应避免包含敏感数据，客户端应在自己的用户界面中展示这些日志。\n\n#### 分页\n\n列表操作会返回分页结果，并附带一个不透明的 `nextCursor`。客户端需要将该游标传递回去以获取下一页内容。支持的列表调用包括：`resources\u002Flist`、`resources\u002Ftemplates\u002Flist`、`prompts\u002Flist` 和 `tools\u002Flist`。请将游标视为不透明对象——不要解析或在不同会话之间持久化它们。\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ListResourcesRequest\nimport io.modelcontextprotocol.kotlin.sdk.types.ListResourcesResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Method\nimport io.modelcontextprotocol.kotlin.sdk.types.Resource\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport kotlinx.io.asSink\nimport kotlinx.io.asSource\nimport kotlinx.io.buffered\n\nsuspend fun main() {\n-->\n\n```kotlin\nval server = Server(\n    serverInfo = Implementation(\"example-server\", \"1.0.0\"),\n    options = ServerOptions(\n        capabilities = ServerCapabilities(\n            resources = ServerCapabilities.Resources(),\n        ),\n    )\n)\n\nval session = server.createSession(\n    StdioServerTransport(\n        inputStream = System.`in`.asSource().buffered(),\n        outputStream = System.out.asSink().buffered()\n    )\n)\n\nval resources = listOf(\n    Resource(uri = \"note:\u002F\u002F1\", name = \"Note 1\", description = \"First\"),\n    Resource(uri = \"note:\u002F\u002F2\", name = \"Note 2\", description = \"Second\"),\n    Resource(uri = \"note:\u002F\u002F3\", name = \"Note 3\", description = \"Third\"),\n)\nval pageSize = 2\n\nsession.setRequestHandler\u003CListResourcesRequest>(Method.Defined.ResourcesList) { request, _ ->\n    val start = request.params?.cursor?.toIntOrNull() ?: 0\n    val page = resources.drop(start).take(pageSize)\n    val next = if (start + page.size \u003C resources.size) (start + page.size).toString() else null\n\n    ListResourcesResult(\n        resources = page,\n        nextCursor = next,\n    )\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-server-util-pagination-01.kt -->\n\n仅当还有更多项目时才包含 `nextCursor`；如果游标为空，则表示分页结束。\n\n### 客户端功能\n\n客户端在初始化时会公布其能力（如根目录、采样、诱导等）。此后，它们可以在响应来自服务器的请求的同时，继续发起诸如 `listTools` 或 `callTool` 之类的调用。\n\n#### 根目录\n\n根目录允许客户端声明服务器被允许操作的范围。声明 `roots` 能力，响应 `roots\u002Flist` 请求，并在设置 `listChanged = true` 时发出 `notifications\u002Froots\u002Flist_changed` 通知。URI **必须** 是 `file:\u002F\u002F` 路径。\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.client.Client\nimport io.modelcontextprotocol.kotlin.sdk.client.ClientOptions\nimport io.modelcontextprotocol.kotlin.sdk.types.ClientCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\n\nsuspend fun main() {\n-->\n\n```kotlin\nval client = Client(\n    clientInfo = Implementation(\"demo-client\", \"1.0.0\"),\n    options = ClientOptions(\n        capabilities = ClientCapabilities(roots = ClientCapabilities.Roots(listChanged = true)),\n    ),\n)\n\nclient.addRoot(\n    uri = \"file:\u002F\u002F\u002FUsers\u002Fdemo\u002Fprojects\",\n    name = \"Projects\",\n)\nclient.sendRootsListChanged()\n```\n\n\u003C!--- SUFFIX \n}    \n-->\n\n\u003C!--- KNIT example-client-roots-01.kt -->\n\n每当文件系统视图发生变化时，调用 `addRoot`\u002F`removeRoot`，并使用 `sendRootsListChanged()` 通知服务器。确保根目录列表由用户控制，并撤销不再授权的条目。\n\n#### 择样\n\n择样功能使服务器能够请求客户端调用其首选的大型语言模型。声明 `sampling` 能力（如果支持工具启用的择样，则还需声明 `sampling.tools`），并处理 `sampling\u002FcreateMessage` 请求。审批流程中应始终有人工参与。\n\n\u003C!--- INCLUDE\nimport io.modelcontextprotocol.kotlin.sdk.client.Client\nimport io.modelcontextprotocol.kotlin.sdk.client.ClientOptions\nimport io.modelcontextprotocol.kotlin.sdk.types.ClientCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.CreateMessageRequest\nimport io.modelcontextprotocol.kotlin.sdk.types.CreateMessageResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.Method\nimport io.modelcontextprotocol.kotlin.sdk.types.Role\nimport io.modelcontextprotocol.kotlin.sdk.types.TextContent\nimport kotlinx.serialization.json.buildJsonObject\nimport kotlinx.serialization.json.putJsonObject\n\nfun main() {\n-->\n\n```kotlin\nval client = Client(\n    clientInfo = Implementation(\"demo-client\", \"1.0.0\"),\n    options = ClientOptions(\n        capabilities = ClientCapabilities(\n            sampling = buildJsonObject { putJsonObject(\"tools\") { } }, \u002F\u002F 如果不支持工具使用，则省略 tools\n        ),\n    ),\n)\n\nclient.setRequestHandler\u003CCreateMessageRequest>(Method.Defined.SamplingCreateMessage) { request, _ ->\n    val content = request.messages.lastOrNull()?.content\n    val prompt = if (content is TextContent) content.text else \"your topic\"\n    CreateMessageResult(\n        model = \"gpt-4o-mini\",\n        role = Role.Assistant,\n        content = TextContent(text = \"Here is a short note about $prompt\"),\n    )\n}\n```\n\n\u003C!--- SUFFIX\n}\n-->\n\n\u003C!--- KNIT example-client-sampling-01.kt -->\n\n在处理器中，您可以选择任何模型或提供商，要求审批，或拒绝请求。如果不支持工具使用，请在能力声明中省略 `sampling.tools`。\n\n[\u002F\u002F]: # (TODO: add elicitation section)\n\n[\u002F\u002F]: # (#### Elicitation)\n\n## 传输协议\n\n所有传输协议共享相同的 API 接口，因此您无需修改业务逻辑即可更改部署方式。请选择最适合服务器运行环境的传输协议。\n\n### STDIO 传输协议\n\n`StdioClientTransport` 和 `StdioServerTransport` 通过标准输入\u002F输出隧道传输 MCP 消息，非常适合需要启动辅助进程的编辑器插件或 CLI 工具。无需任何网络配置。\n\n### 可流式 HTTP 传输协议\n\n`StreamableHttpClientTransport` 以及 Ktor 的 `mcpStreamableHttp()` 和 `mcpStatelessStreamableHttp()` 辅助函数，可通过单个 HTTP 端点暴露 MCP，支持可选的仅 JSON 或 SSE 流式响应。这是远程部署的推荐选择，并能很好地与代理或服务网格集成。\n\n这些辅助函数会自动安装带有 `McpJson` 的 `ContentNegotiation` 插件——请勿自行安装，否则会记录警告信息。两者都接受 `path` 参数（默认为 `\"\u002Fmcp\"`），以便将端点挂载到任意 URL：\n\n\u003C!--- CLEAR -->\n\u003C!--- INCLUDE \nimport io.ktor.server.cio.CIO\nimport io.ktor.server.engine.embeddedServer\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.mcpStreamableHttp\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\n\nprivate class MyServer :\n    Server(\n        serverInfo = Implementation(name = \"ExampleServer\", version = \"1.0\"),\n        options = ServerOptions(capabilities = ServerCapabilities()),\n    )\n\nfun main() {\n-->\n\n```kotlin\nembeddedServer(CIO, port = 3000) {\n    mcpStreamableHttp(path = \"\u002Fapi\u002Fmcp\") {\n        MyServer()\n    }\n}.start(wait = true)\n```\n\n\u003C!--- SUFFIX \n}\n-->\n\u003C!--- KNIT example-server-routes-01.kt -->\n\n**针对基于浏览器的客户端（例如 MCP Inspector）的 CORS 设置：** 如果您从基于浏览器的客户端连接，需要安装 Ktor 的 CORS 插件，以允许并暴露 MCP 特定的头部信息：\n\n```kotlin\ninstall(CORS) {\n    anyHost() \u002F\u002F 在生产环境中限制为特定来源\n    allowMethod(HttpMethod.Options)\n    allowMethod(HttpMethod.Get)\n    allowMethod(HttpMethod.Post)\n    allowMethod(HttpMethod.Delete)\n    allowNonSimpleContentTypes = true\n    allowHeader(\"Mcp-Session-Id\")\n    allowHeader(\"Mcp-Protocol-Version\")\n    exposeHeader(\"Mcp-Session-Id\")\n    exposeHeader(\"Mcp-Protocol-Version\")\n}\n```\n\n### SSE 传输\n\n服务器发送事件仍可用于与旧版 MCP 客户端的向后兼容。提供了两个 Ktor 辅助函数：\n\n- **`Application.mcp { }`** — 自动安装 SSE 和带有 `McpJson` 的 `ContentNegotiation`，然后在 `\u002F` 路径下注册 MCP 端点。请勿自行安装 `ContentNegotiation`——SDK 已经处理好了。\n- **`Route.mcp { }`** — 在当前路由路径下注册 MCP 端点；需要先在应用中调用 `install(SSE)`。使用此方法可以在其他路由旁边或特定路径前缀下托管 MCP：\n\n\u003C!--- CLEAR -->\n\u003C!--- INCLUDE \nimport io.ktor.server.application.install\nimport io.ktor.server.cio.CIO\nimport io.ktor.server.engine.embeddedServer\nimport io.ktor.server.response.respondText\nimport io.ktor.server.routing.get\nimport io.ktor.server.routing.route\nimport io.ktor.server.routing.routing\nimport io.ktor.server.sse.SSE\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.mcp\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\n\nprivate class MyServer :\n    Server(\n        serverInfo = Implementation(name = \"ExampleServer\", version = \"1.0\"),\n        options = ServerOptions(capabilities = ServerCapabilities()),\n    )\n\nfun main() {\n-->\n\n```kotlin\nembeddedServer(CIO, port = 3000) {\n    install(SSE)\n    routing {\n        route(\"\u002Fapi\u002Fmcp\") {\n            mcp { MyServer() }\n        }\n    }\n}.start(wait = true)\n```\n\n\u003C!--- SUFFIX \n}\n-->\n\u003C!--- KNIT example-server-routes-02.kt -->\n\n对于新项目，建议使用可流式 HTTP。\n\n### WebSocket 传输\n\n`WebSocketClientTransport` 结合相应的服务器工具，可以提供全双工、低延迟的连接——这在您预计会有大量通知或长时间会话，并且反向代理已经终止 WebSocket 连接的情况下非常有用。\n\n### ChannelTransport（测试）\n`ChannelTransport` 提供了一种简单、无需网络的传输方式，适用于测试和本地开发。它使用 Kotlin 协程通道在客户端和服务器之间建立全双工连接，从而无需设置网络即可轻松测试 MCP 功能。\n\n## 连接您的服务器\n\n1. 在端口 3000 上启动一个示例 HTTP 服务器：\n\n    ```bash\n    .\u002Fgradlew :samples:kotlin-mcp-server:run\n    ```\n\n2. 使用 [MCP Inspector](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Finspector) 或 Claude Desktop\u002FCode 进行连接：\n\n   ```bash\n   npx -y @modelcontextprotocol\u002Finspector --connect http:\u002F\u002Flocalhost:3000\n   # 或\n   claude mcp add --transport http kotlin-mcp http:\u002F\u002Flocalhost:3000\n   ```\n\n3. 在 Inspector 中，确认提示、工具、资源、补全和日志是否正常显示。在本地反复迭代，直到您准备好将服务器部署到任何您希望的位置。\n\n## 示例\n`samples` 目录包含可运行的项目，展示了使用各种传输方式实现的 MCP 服务器和客户端。请参阅 [`samples` 概览](.\u002Fsamples\u002FREADME.md)，其中提供了对比表格和详细说明。\n\n## 文档\n[![Ask DeepWiki](https:\u002F\u002Fdeepwiki.com\u002Fbadge.svg)](https:\u002F\u002Fdeepwiki.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk)\n\n- [API 参考文档](https:\u002F\u002Fkotlin.sdk.modelcontextprotocol.io\u002F)\n- [模型上下文协议文档](https:\u002F\u002Fmodelcontextprotocol.io)\n- [MCP 规范](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002Flatest)\n\n## 贡献\n在贡献之前，请阅读 [贡献指南](CONTRIBUTING.md) 和 [行为准则](CODE_OF_CONDUCT.md)。\n\n## 许可证\n本项目对新贡献采用 Apache 2.0 许可证，现有代码则采用 MIT 许可证——详情请参阅 [LICENSE](LICENSE) 文件。","# Kotlin MCP SDK 快速上手指南\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **Kotlin**: 版本 2.2 或更高。\n*   **JDK**: 版本 11 或更高（针对 JVM 目标）。\n*   **构建工具**: Gradle (推荐) 或 Maven。\n*   **平台支持**: 支持 JVM, Native, JS (Wasm) 多平台开发。\n*   **依赖框架**: 本 SDK 基于 [Ktor](https:\u002F\u002Fktor.io\u002F) 构建，但**不会**传递性引入 Ktor 引擎依赖，您需要根据项目需求手动添加对应的 Ktor Client 或 Server 依赖。\n\n## 安装步骤\n\n### 1. 配置仓库\n在 `build.gradle.kts` (或 `build.gradle`) 中添加 Maven Central 仓库：\n\n```kotlin\nrepositories {\n    mavenCentral()\n}\n```\n\n> **提示**：国内开发者若访问 Maven Central 较慢，可在 `settings.gradle.kts` 中配置阿里云镜像：\n> ```kotlin\n> dependencyResolutionManagement {\n>     repositories {\n>         maven { url = uri(\"https:\u002F\u002Fmaven.aliyun.com\u002Frepository\u002Fpublic\") }\n>         mavenCentral()\n>     }\n> }\n> ```\n\n### 2. 添加依赖\n根据您的项目类型选择依赖方式。请将 `$mcpVersion` 替换为最新版本号（参考 README 顶部的徽章）。\n\n#### 方案 A：完整 SDK (客户端 + 服务端)\n```kotlin\ndependencies {\n    implementation(\"io.modelcontextprotocol:kotlin-sdk:$mcpVersion\")\n}\n```\n\n#### 方案 B：仅客户端 或 仅服务端\n```kotlin\ndependencies {\n    \u002F\u002F 仅客户端\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-client:$mcpVersion\")\n    \n    \u002F\u002F 仅服务端\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-server:$mcpVersion\")\n}\n```\n\n#### 方案 C：Kotlin Multiplatform (KMP)\n在 `commonMain` 源集中添加：\n```kotlin\ncommonMain {\n    dependencies {\n        implementation(\"io.modelcontextprotocol:kotlin-sdk:$mcpVersion\")\n    }\n}\n```\n\n### 3. 配置 Ktor 引擎 (必需)\nSDK 需要您显式声明 Ktor 引擎依赖。\n\n**对于 MCP 客户端:**\n```kotlin\ndependencies {\n    implementation(\"io.ktor:ktor-client-cio:$ktorVersion\") \u002F\u002F 或其他引擎\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-client:$mcpVersion\")\n}\n```\n\n**对于 MCP 服务端:**\n```kotlin\ndependencies {\n    implementation(\"io.ktor:ktor-server-netty:$ktorVersion\") \u002F\u002F 或其他引擎\n    implementation(\"io.modelcontextprotocol:kotlin-sdk-server:$mcpVersion\")\n}\n```\n\n## 基本使用\n\n以下示例展示如何快速创建一个 MCP 服务端和一个连接到该服务端的客户端。\n\n### 1. 创建 MCP 服务端\n创建一个暴露简单工具（Tool）的服务端，运行在嵌入式 Ktor 服务器上，使用 Streamable HTTP 传输协议。\n\n```kotlin\nimport io.ktor.server.cio.CIO\nimport io.ktor.server.engine.embeddedServer\nimport io.modelcontextprotocol.kotlin.sdk.server.Server\nimport io.modelcontextprotocol.kotlin.sdk.server.ServerOptions\nimport io.modelcontextprotocol.kotlin.sdk.server.mcpStreamableHttp\nimport io.modelcontextprotocol.kotlin.sdk.types.CallToolResult\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities\nimport io.modelcontextprotocol.kotlin.sdk.types.TextContent\nimport io.modelcontextprotocol.kotlin.sdk.types.ToolSchema\nimport kotlinx.serialization.json.buildJsonObject\nimport kotlinx.serialization.json.put\n\nfun main(args: Array\u003CString>) {\n    val port = args.firstOrNull()?.toIntOrNull() ?: 3000\n    \n    \u002F\u002F 初始化服务器\n    val mcpServer = Server(\n        serverInfo = Implementation(\n            name = \"example-server\",\n            version = \"1.0.0\"\n        ),\n        options = ServerOptions(\n            capabilities = ServerCapabilities(\n                tools = ServerCapabilities.Tools(listChanged = true),\n            ),\n        )\n    )\n\n    \u002F\u002F 注册一个工具\n    mcpServer.addTool(\n        name = \"example-tool\",\n        description = \"An example tool\",\n        inputSchema = ToolSchema(\n            properties = buildJsonObject {\n                put(\"input\", buildJsonObject { put(\"type\", \"string\") })\n            }\n        )\n    ) { request ->\n        \u002F\u002F 处理工具调用逻辑\n        CallToolResult(content = listOf(TextContent(\"Hello, world!\")))\n    }\n    \n    \u002F\u002F 启动嵌入式服务器\n    embeddedServer(CIO, host = \"127.0.0.1\", port = port) {\n        mcpStreamableHttp {\n            mcpServer\n        }\n    }.start(wait = true)\n}\n```\n\n### 2. 创建 MCP 客户端\n创建一个客户端，通过 Streamable HTTP 连接到上述服务器，并列出可用的工具。\n\n```kotlin\nimport io.ktor.client.HttpClient\nimport io.ktor.client.plugins.sse.SSE\nimport io.modelcontextprotocol.kotlin.sdk.client.Client\nimport io.modelcontextprotocol.kotlin.sdk.client.StreamableHttpClientTransport\nimport io.modelcontextprotocol.kotlin.sdk.types.Implementation\nimport kotlinx.coroutines.runBlocking\n\nfun main(args: Array\u003CString>) = runBlocking {\n    val url = args.firstOrNull() ?: \"http:\u002F\u002Flocalhost:3000\u002Fmcp\"\n\n    \u002F\u002F 配置 HttpClient 并安装 SSE 插件\n    val httpClient = HttpClient { install(SSE) }\n\n    \u002F\u002F 初始化客户端\n    val client = Client(\n        clientInfo = Implementation(\n            name = \"example-client\",\n            version = \"1.0.0\"\n        )\n    )\n\n    \u002F\u002F 配置传输层\n    val transport = StreamableHttpClientTransport(\n        client = httpClient,\n        url = url\n    )\n\n    \u002F\u002F 连接服务器\n    client.connect(transport)\n\n    \u002F\u002F 获取并打印可用工具列表\n    val tools = client.listTools().tools\n    println(tools)\n}\n```\n\n### 3. 运行与测试\n1.  先运行**服务端**代码（默认端口 3000）。\n2.  再运行**客户端**代码。\n3.  或者，您可以使用官方 MCP Inspector 进行可视化测试：\n    ```bash\n    npx -y @modelcontextprotocol\u002Finspector\n    ```\n    在 Inspector 界面中连接地址：`http:\u002F\u002Flocalhost:3000\u002Fmcp`。","某金融科技公司后端团队正致力于将现有的 Kotlin 微服务架构与大模型集成，希望让 AI 助手能直接查询内部合规文档并执行数据脱敏工具。\n\n### 没有 kotlin-sdk 时\n- **协议实现繁琐**：开发者需手动解析 MCP 标准的 JSON-RPC 消息格式，处理复杂的生命周期状态机，极易因字段遗漏导致连接中断。\n- **多端适配困难**：若需同时支持 JVM 服务端和 Wasm 前端插件，必须维护两套独立的通信逻辑代码，重复工作量大且难以同步更新。\n- **异步处理复杂**：原生协程与 HTTP\u002FSSE 传输层的对接需要大量样板代码来处理背压和流式响应，调试耗时且容易引发内存泄漏。\n- **功能扩展受限**：想要暴露新的“资源”或“工具”给大模型，往往需要重写底层传输逻辑，导致业务迭代周期从几天延长至数周。\n\n### 使用 kotlin-sdk 后\n- **开箱即用**：kotlin-sdk 封装了完整的 MCP 协议细节，只需定义简单的数据类即可自动处理消息序列化与状态管理，连接稳定性显著提升。\n- **一次编写多端运行**：依托 Kotlin Multiplatform 特性，同一套客户端或服务端代码可无缝编译运行在 JVM、Native 及 Wasm 环境，大幅降低维护成本。\n- **协程原生支持**：利用 kotlinx.coroutines 深度集成的 API，开发者可用自然的挂起函数处理流式数据传输，代码简洁且天然避免阻塞问题。\n- **快速能力暴露**：通过声明式接口即可快速注册 Prompts、Resources 和 Tools，业务团队能在几小时内完成新智能功能的上线与测试。\n\nkotlin-sdk 通过标准化的协议封装与跨平台能力，让 Kotlin 开发者能以最低成本将传统应用平滑升级为具备上下文感知能力的 AI 原生应用。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelcontextprotocol_kotlin-sdk_e8e8ca08.png","modelcontextprotocol","Model Context Protocol","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmodelcontextprotocol_c5bd76d0.png","An open protocol that enables seamless integration between LLM applications and external data sources and tools.",null,"https:\u002F\u002Fmodelcontextprotocol.io","https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol",[84,88,92],{"name":85,"color":86,"percentage":87},"Kotlin","#A97BFF",97.4,{"name":89,"color":90,"percentage":91},"TypeScript","#3178c6",2.2,{"name":93,"color":94,"percentage":95},"Shell","#89e051",0.4,1318,205,"2026-04-03T03:45:26","NOASSERTION","","未说明",{"notes":103,"python":104,"dependencies":105},"该工具是基于 Kotlin 的多平台 SDK（支持 JVM、Native、JS、Wasm），并非 Python 项目，因此无需 Python 环境。它依赖 Ktor 框架进行网络通信，但需要用户在项目中手动声明具体的 Ktor 引擎依赖（如 ktor-client-cio 或 ktor-server-netty）。运行环境需安装 JDK 11 及以上版本。","不适用",[106,107,108,109,110],"Kotlin 2.2+","JVM 11+","Ktor (Client\u002FServer)","kotlinx.coroutines","kotlinx.serialization",[26,13],[113,114],"kotlin-multiplatform","mcp","2026-03-27T02:49:30.150509","2026-04-06T06:44:35.971899",[118,123,128,133,138,142],{"id":119,"question_zh":120,"answer_zh":121,"source_url":122},14028,"使用 SSE 连接时遇到 'Error handling notification: notifications\u002Finitialized' 和 'NoSuchElementException' 错误怎么办？","这是一个已知的 Bug，已在版本 0.6.0 中修复。请确保将 `kotlin-sdk` 依赖升级到最新版本（0.6.0 或更高）。如果问题仍然存在，可能是由于发布验证问题导致的临时情况，建议检查 Maven Central 确认最新版本是否可用。","https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fissues\u002F56",{"id":124,"question_zh":125,"answer_zh":126,"source_url":127},14029,"如何在 MCP SSE 客户端传输中添加自定义请求头（如 Authorization Bearer Token）？","在构建 `http.mcpSseTransport` 时，可以通过 `headers` 块添加自定义头。例如：\n```kotlin\nval haTransport = http.mcpSseTransport(\"http:\u002F\u002Fhomeassistant.local:8123\u002Fmcp_server\") {\n    headers {\n        append(\"Authorization\", \"Bearer some_token_here\")\n    }\n}\n```\n注意：如果在某些版本中发现 POST 请求未携带该头，可能是 SDK 内部实现遗漏，需等待官方修复或检查是否有更新的补丁版本。","https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fissues\u002F63",{"id":129,"question_zh":130,"answer_zh":131,"source_url":132},14030,"当 StdioClientServer 连接过程中子进程报错时，为什么 connect 方法不返回且无错误日志？","当前 `StdioClientTransport` 仅读取进程的 stdout 和 stdin，忽略了 stderr。若子进程出错，错误信息写入 stderr 导致主程序无法感知。解决方案是扩展 `StdioClientTransport` 构造函数，增加对 error 流的处理。示例代码如下：\n```kotlin\nval process = ProcessBuilder(...).start()\nval transport = StdioClientTransport(\n    input = process.inputStream.asSource().buffered(),\n    output = process.outputStream.asSink().buffered(),\n    error = process.errorStream.asSource().buffered() \u002F\u002F 新增参数处理错误流\n)\n```\n此改动可让客户端捕获并记录子进程的错误输出。","https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fissues\u002F107",{"id":134,"question_zh":135,"answer_zh":136,"source_url":137},14031,"为什么在 Ktor 的自定义 Route 中部署 MCP SSE 服务器会返回 404 Not Found？","MCP Ktor 插件默认绑定到根路径 `\u002F`，若将其注册在自定义路由（如 `\u002FmyRoute`）下，可能导致路径匹配失败。解决方法是确保 MCP 插件安装在正确的路由作用域内，或者直接访问根路径测试。如果必须在子路由运行，请检查 Ktor 路由配置是否正确嵌套，并确保事件流端点路径与客户端请求一致。目前官方示例多基于根路径，自定义路径需额外调试路由匹配逻辑。","https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fissues\u002F94",{"id":139,"question_zh":140,"answer_zh":141,"source_url":122},14032,"如何确认当前使用的 kotlin-sdk 版本是否包含关键修复（如 #157）？","可以查看 Maven Central 上的发布记录：https:\u002F\u002Fcentral.sonatype.com\u002Fartifact\u002Fio.modelcontextprotocol\u002Fkotlin-sdk。版本 0.6.0 明确包含了 issue #157 的修复。在项目的 `build.gradle.kts` 或 `pom.xml` 中确认依赖版本不低于 0.6.0。若仍遇问题，可查阅对应版本的 changelog 或在 GitHub Issues 中搜索相关修复编号。",{"id":143,"question_zh":144,"answer_zh":145,"source_url":127},14033,"连接 Home Assistant MCP 服务器时出现 401 未授权错误，但 curl 命令却成功，原因是什么？","这通常是因为 Kotlin SDK 客户端在建立 SSE 连接时未正确传递 Authorization 头。虽然代码中使用了 `headers { append(...) }`，但在某些旧版本中，这些头可能未被应用到实际的 HTTP 请求中（尤其是后续的消息 POST 请求）。建议：1) 升级 SDK 至最新版；2) 使用网络抓包工具（如 Wireshark 或 Charles）验证请求头是否真正发送；3) 若问题依旧，可临时通过代理层（如 Nginx）注入认证头作为变通方案。",[147,152,157,162,167,172,177,182,187,192,197,202,207,212,217,221,225,229,234,239],{"id":148,"version":149,"summary_zh":150,"released_at":151},80785,"0.11.0","新增基于 URL 的 elicitation 模式，支持类型化的 schema 定义；可配置服务器有效载荷大小限制；并将核心依赖升级至 Kotlin 2.3。\n\n## 破坏性变更\n\n**`ElicitRequestParams` 现已成为密封接口**，由 @devcrocod 在 [#660](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F660) 中实现。\n\n根据 MCP 规范，重构以同时支持基于表单和基于 URL 的 elicitation 模式。`ElicitRequestParams` 由之前的 `data class` 改为包含两个变体的 `sealed interface`：`ElicitRequestFormParams` 和 `ElicitRequestUrlParams`。同时提供一个已弃用的工厂函数，以保持现有调用的源代码兼容性。\n\n```diff\n- val params = ElicitRequestParams(message = \"...\", requestedSchema = schema)\n+ val params = ElicitRequestFormParams(message = \"...\", requestedSchema = schema)\n```\n\n**`RequestedSchema.properties` 类型变更**，由 @devcrocod 在 [#660](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F660) 中完成。\n\n为提高类型安全性，该字段由 `JsonObject` 更改为 `Map\u003CString, PrimitiveSchemaDefinition>`。\n\n**移除 `macosX64` 目标**，由 @devcrocod 在 [#625](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F625) 中实施。\n\n在 Kotlin 2.2 中已废弃、并计划于 Kotlin 2.3 中正式移除的 `macosX64` 原生目标已被删除。请改用 `macosArm64`。\n\n## 新特性\n\n- 基于 URL 的 elicitation 模式及与 MCP 规范一致的类型化 `PrimitiveSchemaDefinition` 层次结构，由 @devcrocod 在 [#660](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F660) 中实现。\n- 通过 `Configuration.maxRequestBodySize` 可配置 `StreamableHttpServerTransport` 的最大请求有效载荷大小，由 @jskjw157 在 [#646](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F646) 中添加。\n- 在 `mcp()`、`mcpStreamableHttp()` 和 `mcpStatelessStreamableHttp()` 中自动安装带有 `McpJson` 的 `ContentNegotiation`——用户不再需要手动配置 JSON 序列化（#664），由 @kpavlov 在 [#665](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F665) 中完成。\n- 服务器向客户端发送 `notifications\u002Felicitation\u002Fcomplete` 通知，用于带外完成 elicitation，由 @devcrocod 在 [#667](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F667) 中实现。\n\n## 修复\n\n- 当客户端响应中缺少字段时，现会应用 elicitation schema 的默认值，由 @devcrocod 在 [#661](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F661) 中修复。\n- 现在会拒绝重复的 `initialize` 请求，并返回 `INVALID_REQUEST` 错误，由 @devcrocod 在 [#624](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F624) 中修复。\n\n## 维护\n\n- 将 Kotlin 升级至 2.3.10，Ktor 升级至 3.3.3，kotlinx-io 升级至 0.9.0，kotlinx-serialization 升级至 1.10.0，由 @devcrocod 在 [#611](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F611) 中完成。\n- 启用 Wasm 上的 SseTransportTest，并重构测试结构，由 @devcrocod 在 [#662](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F662) 中完成。\n- 改进 dependabot 配置，由 @devcrocod 在 [#619](https:\u002F\u002Fgithub.com\u002Fmodelcontextp","2026-04-02T13:08:19",{"id":153,"version":154,"summary_zh":155,"released_at":156},80786,"0.10.0","## 亮点\r\n\r\n  本次发布新增了 MCP 一致性测试基础设施、SSE 重连支持、Tasks 协议类型、资源模板匹配以及工具执行属性等功能。同时，也完成了弃用周期——从 `io.modelcontextprotocol.kotlin.sdk` 中移除了所有此前已废弃（ERROR 级别）的符号，转而使用 `io.modelcontextprotocol.kotlin.sdk.types` 中的替代实现。                          \r\n                            \r\n## 重大变更\r\n\r\n  - **弃用周期完成** —— 在 0.9.0 版本中以 `ERROR` 级别标记为已弃用的所有符号，现已由 @devcrocod (#615) 全部移除。这包括整个 `io.modelcontextprotocol.kotlin.sdk.types.kt` 兼容性文件（如 `CallToolResult`、`CancelledNotification`、`ClientCapabilities`、`CompleteRequest` 等类型别名）以及 `io.modelcontextprotocol.kotlin.sdk` 中的旧版 `McpJson`。请迁移到 `io.modelcontextprotocol.kotlin.sdk.types` 中对应的实现。\r\n  - **SSE\u002F可流式 HTTP 传输变更** —— `StreamableHttpClientTransport` 现在接受 `ReconnectionOptions`，以实现可配置的重试行为，由 @devcrocod (#585, #596) 完成。之前的构造函数签名仍然可用。                                                  \r\n   \r\n## 功能                                                                                                                                 \r\n                            \r\n  - **MCP 一致性测试基础设施** —— 提供全面的一致性测试套件，覆盖核心协议操作、工具调用、引导、资源、提示以及 20 种 OAuth\u002F认证场景。包含 CI 工作流、基线跟踪和 Shell 运行器，由 @devcrocod (#585) 实现。\r\n  - **支持重试的 SSE 重连功能** —— 客户端传输层现在通过 `ReconnectionOptions` 支持可配置的指数退避重连机制（初始延迟、最大延迟、倍数、最大重试次数），由 @devcrocod (#596) 实现。                                              \r\n  - **Tasks 协议类型** —— 根据 MCP Tasks 规范，新增了 `Task`、`TaskStatus` 及相关模型，由 @devcrocod (#566) 完成。\r\n  - **资源模板与基础模板匹配器** —— 服务器端支持基于 URI 模板的资源匹配功能，由 @kpavlov (#502, #606) 实现。\r\n  - **工具执行属性** —— `Tool` 现在公开执行属性，以提供更丰富的工具元数据，由 @devcrocod (#567) 完成。                                                                                                                                              \r\n  ## 错误修复              \r\n                                                                                                                                              \r\n  - **可流式 HTTP 下通知未送达问题** —— 修复了可流式 HTTP 传输会话中的服务器端通知发送问题，由 @kpavlov (#587, #599) 完成。\r\n  - **一致性测试：SEP-1330 枚举模式** —— 修正了一致性测试中引导枚举模式的相关问题，由 @kpavlov (#600) 完成。","2026-03-26T19:01:54",{"id":158,"version":159,"summary_zh":160,"released_at":161},80787,"0.9.0","## 变更内容\n\n### 破坏性变更\n\n  - **服务器调用处理器现在接收 `RequestContext`** — 工具、提示和资源的处理器 Lambda 函数新增了一个 `context` 参数，用于访问请求元数据（#515），由 @rnett 提供\n  - **Ktor 扩展函数已从 `Routing` 移至 `Route`** — 请更新调用位置：`routing { mcpSse() }` → `route(\"\u002Fmcp\") { mcpSse() }`，或直接在任何 `Route` 块中使用（#531），由 @kpavlov 提供\n  - **`StdioServerTransport` 会重新抛出 `CancellationException`** — 取消操作不再被静默吞下；同时修复了 `ReadBuffer` 的解析问题（#571），由 @kpavlov 提供\n\n  ### 新特性\n\n  - **`kotlin-sdk-testing` 模块** — 新增工件，提供基于通道的进程内 `TestClientTransport` \u002F `TestServerTransport`，用于在不涉及网络 I\u002FO 的情况下对 MCP 服务器和客户端进行单元测试（#505），由 @kpavlov 提供\n  - **`StreamableHttpServerTransport.Configuration`** — 可配置的构建器，用于设置可流式传输的 HTTP 服务器传输层（超时、会话处理等）（#560），由 @kpavlov 提供\n  - **Ktor 针对可流式传输 HTTP 的扩展** — Ktor 插件 `mcpStreamableHttp()` 和路由 DSL，用于部署可流式传输的 HTTP MCP 服务器（#504，由 @devcrocod 提供；#568，由 @kpavlov 提供）\n  - **`ToolSchema` 中的 `$defs` 支持** — 工具输入模式 now 可以表达 JSON Schema 的 `$defs` \u002F 定义（#526），由 @i1bro 提供\n\n  ### Bug 修复\n\n  - 修复了非根挂载路径下的 SSE 传输端点解析问题（#565），由 @Amaneusz 提供\n  - 通过添加适当的读取超时，修复了 `StdioClientTransport` 无限挂起的问题（#528），由 @kpavlov 提供\n\n  ### 改进\n\n  - 引入了 `AbstractClientTransport` 抽象基类，简化了客户端传输的生命周期管理（#516），由 @kpavlov 提供\n  - 开始了弃用周期 — 对计划在后续版本中移除的 API 进行标注（#498），由 @devcrocod 提供\n  - 将 Detekt 静态分析集成到 CI 流程中（#493、#507），由 @kpavlov 提供\n  - 通过 Codecov 添加了代码覆盖率报告（#579、#580），由 @kpavlov 提供\n  - 替换了易失败的 `StdioClientTransport` 测试，改用基于真实标准输入管道的测试（#508），由 @kpavlov 提供\n\n  ### 依赖项更新\n\n  - Kotest 6.1.2、MockK 1.14.9、AtomicFU 0.31.0、Gradle 9.3.1、Kover 0.9.7\n\n## 新贡献者\n\n* @jskjw157 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F486 中做出了首次贡献\n* @i1bro 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F526 中做出了首次贡献\n* @localden 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F536 中做出了首次贡献\n* @aozherelyeva 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F551 中做出了首次贡献\n* @rnett 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F515 中做出了首次贡献\n* @Amaneusz 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F565 中做出了首次贡献\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.8.4...0.9.0","2026-03-05T12:48:57",{"id":163,"version":164,"summary_zh":165,"released_at":166},80788,"0.8.4","## 变更\n\n- 功能：用于可流式传输 HTTP 的 Ktor 扩展 (#504)，由 @devcrocod 提供\n- 修复：向 ToolSchema 和测试中添加 $defs (#526)，由 @i1bro 提供\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.8.3...0.8.4","2026-02-17T06:31:28",{"id":168,"version":169,"summary_zh":170,"released_at":171},80789,"0.8.3","# 变更内容\n\n## Bug修复\n\n- **破坏性变更！**：`StdioClientTransport.send(...)` 和 `StreamableHttpClientTransport.send(...)` 现在会在未就绪时抛出 `McpException` (#487)，由 @kpavlov 提供\n- #450 正确检查内容类型 (#451)，由 @nerzhulart 提供\n- 修复不稳定的 StdioClientTransportErrorHandlingTest (#457)，由 @kpavlov 提供\n- 修复通知相关的测试 (#446)，由 @tiginamaria 提供\n- 修复 kotlin-mcp-server 示例 (#459)，由 @devcrocod 提供\n- 修复 GitHub Actions 构建工作流 (#474)，由 @kpavlov 提供\n- 修复确认测试 (#483)，由 @Fuud 和 @kpavlov 提供\n- 重构集成测试基础设施，修复并启用使用 ts-client 的测试 (#478)，由 @kpavlov 提供\n\n## 新特性\n\n- 将用于类型的 DSL 函数标记为 public (#472)，由 @kpavlov 提供\n\n## 杂项任务\n\n- 将新贡献的许可协议更新为 Apache 2.0 (#481)，由 @domdomegg 提供\n- 为集成测试添加集中式的 TypeScript 服务器工厂 (#477)，由 @kpavlov 提供\n- 将 actions\u002Fsetup-node 从 4 升级到 6 (#453)，由 @dependabot 提供\n- 更新 GitHub Actions 工作流 (#452)，由 @kpavlov 提供\n- 将 io.mockk:mockk 从 1.14.6 升级到 1.14.7 (#455)，由 @dependabot 提供\n- 将 io.github.oshai:kotlin-logging 从 7.0.13 升级到 7.0.14 (#471)，由 @dependabot 提供\n- 将 org.jetbrains.kotlinx.kover 从 0.9.3 升级到 0.9.4 (#466)，由 @dependabot 提供\n- 将 io.netty:netty-bom 从 4.2.7.Final 升级到 4.2.9.Final (#468)，由 @dependabot 提供\n- 将 actions\u002Fupload-artifact 从 5 升级到 6 (#465)，由 @dependabot 提供\n\n## 新贡献者\n* @nathaniellombardi-toast 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F472 中做出了首次贡献\n* @domdomegg 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F481 中做出了首次贡献\n* @Fuud 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F483 中做出了首次贡献\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.8.1...0.8.2","2026-01-21T10:21:50",{"id":173,"version":174,"summary_zh":175,"released_at":176},80790,"0.8.1","## 变更内容\n\n- 修复（stdio-client）：监控 STDERR 并重构 `StdioClientTransport` 以使用流式处理。修复 #107，由 @kpavlov 完成\n- 修复（sse-client）：在 `StreamableHttpClientTransport` 中，当数据为空时跳过 SSE (#433)，由 @kpavlov 完成\n- 服务器功能列表变更及资源更新通知 (#441)，由 @tiginamaria 完成\n- 增加 MCP 一致性测试覆盖率 (#435)，由 @skarpovdev 完成\n\n### 杂项\n- 更新示例以使用新 Schema (#443)，由 @kpavlov 完成\n- 将 org.jetbrains.kotlinx:kotlinx-io-core 版本从 0.8.1 升级至 0.8.2 (#440)\n- 将 dev.mokksy:mokksy 版本从 0.6.1 升级至 0.6.2 (#431)\n- 将 kotest 版本从 6.0.4 升级至 6.0.7 (#439）\n- 将 actions\u002Fcheckout 版本从 5 升级至 6 (#429）\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.8.0...0.8.1","2025-12-04T15:38:30",{"id":178,"version":179,"summary_zh":180,"released_at":181},80791,"0.8.0","## 🚨 重大变更\n\n#### MCP 模式类型重构 (#386)\n\nMCP 模式的实现已更新至最新的 MCP 规范，并重新组织为专用包：\n- 所有 MCP 类型已移至 `io.modelcontextprotocol.kotlin.sdk.types` 包\n- 许多模式类型新增了字段，并更新了构造函数签名\n- 请求\u002F响应类型现在使用嵌套的 `params` 对象\n\n**迁移：**\n\n```kotlin\n\u002F\u002F 之前：\nimport io.modelcontextprotocol.kotlin.sdk.InitializeRequest\nimport io.modelcontextprotocol.kotlin.sdk.Resource\n\n\u002F\u002F 之后：\nimport io.modelcontextprotocol.kotlin.sdk.types.InitializeRequest\nimport io.modelcontextprotocol.kotlin.sdk.types.Resource\n```\n\n---\n#### 最低 JVM 版本提升至 11 (#394)\n\n目前支持的最低 JVM 版本已提升至 11。运行在 Java 8 上的项目必须升级其运行时和构建工具链。\n\n---\n\n#### Transport.send 签名变更 (#408)\n\n`Transport.send` 方法现在接受 `TransportSendOptions?` 参数，以支持恢复令牌、进度回调以及请求与响应的关联。\n\n> [!NOTE]\n> 哪些人会受到影响？\n> 仅自定义的 Transport 实现。内置传输无需任何更改。\n\n**迁移：**\n请将所有 `Transport.send` 实现更新为包含新的 `TransportSendOptions?` 参数。\n\n---\n\n## 功能特性\n- 新的 MCP 模式类型 (#386) @devcrocod\n- 添加服务器会话 ID (#381) @tiginamaria\n- 为请求和通知类型添加新的辅助属性 (#388) @devcrocod \n- 添加实验性 mcpClient(...) 工厂方法 (#396) @kpavlov\n- 提案：为请求类型提供 DSL 构建器 (#399) @devcrocod \n- 在 Transport.send 方法中添加选项 (#408) @devcrocod \n- 为 JSONRPCRequest 添加便捷构造函数 (#336) @kpavlov\n\n## 改进\n- 提升支持的规范版本 (#391) @devcrocod \n- 提高弃用级别 (#393) @devcrocod \n- 更新 ServerPromptsTest，并将 AbstractTransport 移至独立文件 (#376) @kpavlov \n- 添加向后兼容的构造函数和测试 (#395) @kpavlov \n- 在 ExperimentalMcpApi 注解中添加警告信息并调整级别 (#398) @devcrocod \n- 在客户端初始化处理中增加对额外错误类型的处理 (#404) @devcrocod \n- 添加使用新模式类型的测试 (#389) @devcrocod\n\n## 错误修复\n- 从 0.7.5 版本开始，Kotlin-MCP 无法在不使用 ktor-bom 的情况下使用 (#392) @IRus \n- 修复在请求中提供 progressToken 的问题 (#405) @devcrocod\n\n## 文档与示例\n- 添加演示 MCP 客户端的 Kotlin Notebook 示例 (#397) @kpavlov\n\n构建与依赖\n- 将版本号提升至 0.8.0-SNAPSHOT，并更新示例中的 mcp-kotlin 依赖 (#385) @kpavlov\n- 在 Gradle 构建配置中将 JVM 目标版本更新为 11 (#394) @kpavlov\n- 将 org.jlleitschuh.gradle.ktlint 从 13.1.0 升级至 14.0.1 (#402) @dependabot[bot]\n- 将 com.vanniktech:gradle-maven-publish-plugin 从 0.34.0 升级至 0.35.0 (#403) @dependabot[bot]\n\n## 新贡献者\n* @IRus 在 https:\u002F\u002Fgithub.com\u002Fmodel 中做出了首次贡献","2025-11-20T22:49:19",{"id":183,"version":184,"summary_zh":185,"released_at":186},80792,"0.7.7","## 变更内容\n*  **💥 重大变更:**  由 @kpavlov 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F383 中将 `Annotations` 中的 `lastModified` 从 `Instant` 替换为 `String`\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.7.6...0.7.7","2025-11-10T16:43:33",{"id":188,"version":189,"summary_zh":190,"released_at":191},80793,"0.7.6","## 变更内容\n\n## Bug修复\n* #355 在服务器传输中处理协程取消，由 kpavlov 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F375 中完成\n\n## 依赖更新\n* 将版本号升级至 0.7.6-SNAPSHOT，并在示例中将版本号更新为 0.7.5，由 kpavlov 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F374 中完成\n* 在所有项目中将 Gradle 版本更新至 9.2.0，由 kpavlov 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F377 中完成\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.7.5...0.7.6","2025-11-07T15:26:02",{"id":193,"version":194,"summary_zh":195,"released_at":196},80794,"0.7.5","## 变更内容\n\n* 由 @devcrocod 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F350 中重构 WebSocket 依赖。\n* 修复：为符合 MCP 规范，对于工具错误返回带有 isError 标志的 CallToolResult，由 @devcrocod 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F354 中完成。\n* 将 `WebSocketIntegrationTest` 从 `commonTest` 移至 `jvmTest`，由 @devcrocod 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F352 中完成。\n* 修复 kotlin-mcp-server 示例并更新示例代码，由 @devcrocod 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F345 中完成。\n* 修复服务器端登录的安全性问题，由 @devcrocod 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F360 中完成。\n* 重构 mcp 服务器，将 connect 方法重命名为 ，由 @tiginamaria 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F364 中完成。\n* 修复：解决服务器中未关闭会话导致的内存泄漏问题，由 @devcrocod 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F359 中完成。\n* 将功能（工具、提示、资源）管理移至 FeatureRegistry，由 @tiginamaria 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F365 中完成。\n* 重构 ServerTest 测试结构，由 @tiginamaria 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F366 中完成。\n* 修复：处理服务器端的日志记录\u002FsetLevel 请求，由 @devcrocod 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F358 中完成。\n* 添加 Ktor BOM 以实现跨所有模块的依赖管理，并运行 Kotlin-MCP-Server 示例，由 @kpavlov 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F367 中完成。\n* 为服务器示例添加测试用例，由 @tiginamaria 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F369 中完成。\n* 为 Tool 添加可选的 _meta 字段，由 @jclyne 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F339 中完成。\n* 更新 Kotlin-MCP-Server，增加 STDIO 支持、日志记录和 CORS 功能，由 @kpavlov 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F371 中完成。\n* 更新 .gitignore 文件，排除 kotlin-js-store 目录，由 @devcrocod 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F343 中完成。\n* 添加 AGENTS.md 文件，由 @devcrocod 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F349 中完成。\n\n## 依赖项更新\n\n* 将 org.openapi.generator 从 7.16.0 升级至 7.17.0，由 @dependabot[bot] 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F362 中完成。\n* 将 mikepenz\u002Faction-junit-report 从 5 升级至 6，由 @dependabot[bot] 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F363 中完成。\n* 将 actions\u002Fupload-artifact 从 4 升级至 5，由 @dependabot[bot] 在 https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F348 中完成。\n\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.7.4...0.7.5","2025-11-06T17:30:24",{"id":198,"version":199,"summary_zh":200,"released_at":201},80795,"0.7.4","# What's Changed\r\n\r\n## Features\r\n* Add metadata support to callTool method by @maeryo in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F289\r\n\r\n## Improvements \r\n* Fix decimal separator format in calculator tool tests by @maeryo in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F315\r\n* Refactor testClientConnectWithInvalidJson by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F338\r\n\r\n## Build & CI\r\n* #302 [part 1] Add GitHub workflow to validate samples by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F327\r\n* #302 Update samples build workflow by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F330\r\n\r\n## Dependencies\r\n* Bump kotest from 6.0.3 to 6.0.4 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F324\r\n* Bump com.anthropic:anthropic-java from 2.7.0 to 2.9.0 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F323\r\n* Bump org.jetbrains.kotlinx.kover from 0.9.2 to 0.9.3 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F322\r\n* Update kotlin, ktor, dokka by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F334\r\n* downgrade Ktor to 3.2.3 by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F342\r\n* Exclude samples from composite gradle build by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F337\r\n\r\n## Docs\r\n* Update badges in README and set version to 0.7.4-SNAPSHOT by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F326\r\n* Prepare release 0.7.4 by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F341\r\n\r\n## New Contributors\r\n* @maeryo made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F289\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.7.3...0.7.4","2025-10-24T13:06:02",{"id":203,"version":204,"summary_zh":205,"released_at":206},80796,"0.7.3","## What's Changed\r\n\r\n* Introduce server sessions by @tiginamaria in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F198\r\n* Capture version at configuration time to avoid configuration cache issue by @jclyne in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F291\r\n* Add `instructions` string to the Server and propagate to the `InitializeResult` by @jclyne in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F290\r\n* Change sample server host from `0.0.0.0` to `127.0.0.1` by @JLLeitschuh in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F307\r\n\r\n* Add `StreamableHttpClientTest` with test infrastructure setup and dependencies by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F316\r\n* Refactor streaming http tests by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F320\r\n* Fix Streamable handling to support JSON-only responses by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F309\r\n\r\n### Chores\r\n\r\n* Bump org.jetbrains.kotlinx.kover from 0.9.1 to 0.9.2 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F286\r\n* Conditionally imports the samples only if it's the root project by @jclyne in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F292\r\n* Generate MCP classes with OpenAPI Generator by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F294\r\n* Disable OpenAPI Generator by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F301\r\n* Bump gradle\u002Factions from 4 to 5 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F306\r\n* Compatibility updates for gradle 9.x.x by @jclyne in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F313\r\n* Bump github\u002Fcodeql-action from 3 to 4 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F317\r\n* Bump org.openapi.generator from 7.15.0 to 7.16.0 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F305\r\n\r\n## New Contributors\r\n* @jclyne made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F292\r\n* @JLLeitschuh made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F307\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.7.2...0.7.3","2025-10-21T15:58:06",{"id":208,"version":209,"summary_zh":210,"released_at":211},80797,"0.6.1","## What's Changed\r\n* Fix incorrect deserializer mapping for tool and prompt list notifications (https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F195)\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.6.0...0.6.1","2025-10-06T11:48:15",{"id":213,"version":214,"summary_zh":215,"released_at":216},80798,"0.7.2","## What's Changed\r\n* migration from `jreleaser` to `mavenPublish` plugin by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F277\r\n* Generate test report by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F271\r\n* Move `generateLibVersion` task to `kotlin-sdk-core`  by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F274\r\n* #196 Update build configuration and workflows for enhanced local publ… by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F275\r\n* Add Stdio coverage for integration tests by @skarpovdev in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F276\r\n* Bump io.kotest:kotest-assertions-json from 5.9.1 to 6.0.3 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F247\r\n* migration from `jreleaser` to `mavenPublish` plugin by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F277\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.7.1...0.7.2","2025-09-19T15:11:34",{"id":218,"version":219,"summary_zh":80,"released_at":220},80799,"0.7.2-alpha3","2025-09-19T13:59:37",{"id":222,"version":223,"summary_zh":80,"released_at":224},80800,"0.7.2-alpha2","2025-09-19T11:14:00",{"id":226,"version":227,"summary_zh":80,"released_at":228},80801,"0.7.2-alpha1","2025-09-18T13:20:40",{"id":230,"version":231,"summary_zh":232,"released_at":233},80802,"0.7.1","## What's Changed\r\n\r\n* Bump io.github.oshai:kotlin-logging from 7.0.7 to 7.0.11 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F211\r\n* Bump org.jlleitschuh.gradle.ktlint from 13.0.0 to 13.1.0 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F241\r\n* Bump com.anthropic:anthropic-java from 0.8.0 to 2.6.0 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F246\r\n* Fix upload reports in GitHub actions by @skarpovdev in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F264\r\n* Bump ktor from 3.2.3 to 3.3.0 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F265\r\n* fix hang caused by StreamableHttpClientTransport (#226) by @AdrianMiska in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F227\r\n* Bump kotlin from 2.2.0 to 2.2.10 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F230\r\n* Add module documentation and enhance Dokka configuration by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F261\r\n* Mark `testMultipleClientParallel` as ignored due to flakiness by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F267\r\n\r\n## New Contributors\r\n* @AdrianMiska made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F227\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fcompare\u002F0.7.0...0.7.1","2025-09-15T18:52:32",{"id":235,"version":236,"summary_zh":237,"released_at":238},80803,"0.7.0","## What's Changed\r\n* revert jreleaser to 1.17.0 and skip checksums by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F150\r\n* fix deploy for klibs by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F153\r\n* FEAT: Support almost all Tier 1, 2 and 3 Kotlin targets by @nomisRev in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F151\r\n* Revert \"FEAT: Support all Tier 1, 2 and 3 targets by Kotlin & remove … by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F154\r\n* Fix release by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F155\r\n* Refactor JSON processing to exclude \"method\" in serialization by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F157\r\n* Update CI workflows configuration for debugging by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F172\r\n* fix signing by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F179\r\n* fix key name by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F181\r\n* Bump org.jetbrains.kotlinx.binary-compatibility-validator from 0.18.0 to 0.18.1 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F148\r\n* Add optional title property for tool object (#191) by @sdubov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F192\r\n* Update PR validation workflow by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F177\r\n* Update notification schema by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F199\r\n* Bump io.mockk:mockk from 1.14.4 to 1.14.5 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F204\r\n* Bump protocol version to `2025-03-26` by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F202\r\n* Bump ktor from 3.2.1 to 3.2.2 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F205\r\n* Add CodeQL workflow for Kotlin analysis by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F200\r\n* modularize sdk by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F208\r\n* Fix SseIntegratioTest by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F212\r\n* Add ServerSSESession as a receiver for mcp {} dsl by @nerzhulart in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F190\r\n* Update MavenCentral configuration and developer metadata by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F201\r\n* Fix incorrect deserializer mapping notifications by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F195\r\n* Add ktlint by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F213\r\n* rename ResourceReference to ResourceTemplateReference by @zyfy29 in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F193\r\n* Bump ktor from 3.2.2 to 3.2.3 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F217\r\n* use SSEClientExcpetion instead of ClientRequestException by @shiqicao in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F207\r\n* Add missing title, size and annotation attributes on Resource\u002FResourceTemplate and other types by @ptitjes in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F219\r\n* Fix deserialization in read buffer by @tiginamaria in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F225\r\n* Fix serializer for CreateElicitationResult by @tiginamaria in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F240\r\n* Add recovery during deserialization and upload test artifacts by @skarpovdev in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F243\r\n* Bump actions\u002Fsetup-java from 4 to 5 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F238\r\n* Introduce Kotlin client\u002Fserver \u003C--> TypeScript client\u002Fserver integration tests by @skarpovdev in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F216\r\n* Refactor workflow, run on main by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F251\r\n* Add Kover check by @kpavlov in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F250\r\n* Remove dependency on CIO engine by @MukjepScarlet in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F223\r\n\r\n## New Contributors\r\n* @nomisRev made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F151\r\n* @sdubov made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F192\r\n* @nerzhulart made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F190\r\n* @zyfy29 made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F193\r\n* @tiginamaria made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F225\r\n* @skarpovdev made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F243\r\n* @kpavlov made their first contributio","2025-09-11T17:09:19",{"id":240,"version":241,"summary_zh":242,"released_at":243},80804,"0.6.0","## What's Changed\r\n* Update jreleaser to fix publication issue by @e5l in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F91\r\n* Disable configuration cache to fix jreleaser issue by @e5l in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F92\r\n* feat: Add audio type according to 2025-03-26 spec by @SeanChinJunKai in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F68\r\n* fix(client): serialize inputSchema as input_schema by @shiqicao in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F97\r\n* fix(client) add encodeDefault for field with non spec default value by @shiqicao in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F99\r\n* Make McpJson public to allow flexible protocol development by @parnurzeal in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F103\r\n* fix: apply `requestBuilder` headers when sending rpc messages by @dead8309 in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F96\r\n* fix: Remove @SerialName annotation for inputSchema by @adamglin0 in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F105\r\n* add ios and wasm targets by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F81\r\n* Add dependabot by @StefMa in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F121\r\n* Bump org.jetbrains.kotlinx:kotlinx-serialization-json from 1.7.3 to 1.8.1 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F127\r\n* Bump io.github.oshai:kotlin-logging from 7.0.0 to 7.0.7 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F126\r\n* Bump org.jetbrains.kotlinx.binary-compatibility-validator from 0.17.0 to 0.18.0 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F125\r\n* update kotlin to 2.2.0 and ktor to 3.1.3 by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F120\r\n* Add client roots addition\u002Fremoval API and listRoots handler by @ptitjes in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F118\r\n* Bump org.slf4j:slf4j-simple from 2.0.16 to 2.0.17 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F131\r\n* Bump org.jetbrains.kotlinx:kotlinx-serialization-json from 1.8.1 to 1.9.0 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F132\r\n* Bump io.mockk:mockk from 1.13.13 to 1.14.4 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F133\r\n* Remove fixed suffix \u002Fsse by @adamglin0 in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F108\r\n* sse server does not process endpoint correctly when sse path is not a directory by @shendaxia-sm in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F43\r\n* Add labels to dependabot configuration for Kotlin and GitHub Actions by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F135\r\n* feat: add tool annotations according to 2025-03-26 spec by @SeanChinJunKai in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F71\r\n* Bump ktor from 3.1.3 to 3.2.1 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F140\r\n* Bump gradle\u002Factions from 4.0.0 to 4.4.1 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F122\r\n* Bump org.jreleaser from 1.17.0 to 1.19.0 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F141\r\n* refactor `SseClientTransport` by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F142\r\n* atomic and persistent collections for thread safety by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F143\r\n* Bump org.gradle.toolchains.foojay-resolver-convention from 0.8.0 to 1.0.0 by @dependabot[bot] in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F130\r\n* Add support for elicitation by @ptitjes in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F138\r\n* Add support for tool structured content and output schema by @ptitjes in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F146\r\n* Add streamable http client transport by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F147\r\n* Refactor JSON processing to exclude \"method\" in serialization by @devcrocod in #157 \r\n* Release 0.6.0 by @devcrocod in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F149\r\n\r\n## New Contributors\r\n* @shiqicao made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F97\r\n* @parnurzeal made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F103\r\n* @dead8309 made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F96\r\n* @adamglin0 made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F105\r\n* @StefMa made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F121\r\n* @dependabot[bot] made their first contribution in https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fkotlin-sdk\u002Fpull\u002F127\r\n* @ptitjes made their first contribution ","2025-07-16T11:01:12"]