[MCP Server] Migrate to MCP SDK 0.6

(cherry picked from commit f7382b7ce1b5d6a10a21fd953283f5b8de746fca)

IJ-MR-170096

GitOrigin-RevId: b6ac94e0b96f671cf0799f97524c78bc17e08f20
This commit is contained in:
Artem.Bukhonov
2025-07-22 16:14:00 +02:00
committed by intellij-monorepo-bot
parent b9eecc4e08
commit 587300dc5d
6 changed files with 21 additions and 19 deletions

View File

@@ -1,18 +1,18 @@
<component name="libraryTable">
<library name="io.modelcontextprotocol.kotlin.sdk" type="repository">
<properties include-transitive-deps="false" maven-id="io.modelcontextprotocol:kotlin-sdk-jvm:0.5.0">
<properties include-transitive-deps="false" maven-id="io.modelcontextprotocol:kotlin-sdk-jvm:0.6.0">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/io/modelcontextprotocol/kotlin-sdk-jvm/0.5.0/kotlin-sdk-jvm-0.5.0.jar">
<sha256sum>d3f56ac2562dc7883043fcbf6b7624196952cf17d41f864db5197d8e9f8b183c</sha256sum>
<artifact url="file://$MAVEN_REPOSITORY$/io/modelcontextprotocol/kotlin-sdk-jvm/0.6.0/kotlin-sdk-jvm-0.6.0.jar">
<sha256sum>10b00c7af47c7a0fb510fb9d7519a9d2476f8e815a5005282734821082f9dc21</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/io/modelcontextprotocol/kotlin-sdk-jvm/0.5.0/kotlin-sdk-jvm-0.5.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/modelcontextprotocol/kotlin-sdk-jvm/0.6.0/kotlin-sdk-jvm-0.6.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/io/modelcontextprotocol/kotlin-sdk-jvm/0.5.0/kotlin-sdk-jvm-0.5.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/modelcontextprotocol/kotlin-sdk-jvm/0.6.0/kotlin-sdk-jvm-0.6.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -2282,8 +2282,8 @@ jvm_import(
jvm_import(
name = "io-modelcontextprotocol-kotlin-sdk",
jar = "@kotlin-sdk-jvm-0_5_0_http//file",
source_jar = "@kotlin-sdk-jvm-0_5_0-sources_http//file",
jar = "@kotlin-sdk-jvm-0_6_0_http//file",
source_jar = "@kotlin-sdk-jvm-0_6_0-sources_http//file",
visibility = ["//visibility:public"]
)

View File

@@ -3023,17 +3023,17 @@ http_file(
)
http_file(
name = "kotlin-sdk-jvm-0_5_0_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/modelcontextprotocol/kotlin-sdk-jvm/0.5.0/kotlin-sdk-jvm-0.5.0.jar",
sha256 = "d3f56ac2562dc7883043fcbf6b7624196952cf17d41f864db5197d8e9f8b183c",
downloaded_file_path = "kotlin-sdk-jvm-0.5.0.jar"
name = "kotlin-sdk-jvm-0_6_0_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/modelcontextprotocol/kotlin-sdk-jvm/0.6.0/kotlin-sdk-jvm-0.6.0.jar",
sha256 = "10b00c7af47c7a0fb510fb9d7519a9d2476f8e815a5005282734821082f9dc21",
downloaded_file_path = "kotlin-sdk-jvm-0.6.0.jar"
)
http_file(
name = "kotlin-sdk-jvm-0_5_0-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/modelcontextprotocol/kotlin-sdk-jvm/0.5.0/kotlin-sdk-jvm-0.5.0-sources.jar",
sha256 = "cd753e33d2aa5308eefa4ee2542f829d4be85805c9d0a8fbaf504a66492d5f1e",
downloaded_file_path = "kotlin-sdk-jvm-0.5.0-sources.jar"
name = "kotlin-sdk-jvm-0_6_0-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/modelcontextprotocol/kotlin-sdk-jvm/0.6.0/kotlin-sdk-jvm-0.6.0-sources.jar",
sha256 = "a7dec8c0b7df080e7e234f5ca683b28a6e6a4b7bfcdafa75a8aeca20b753ea81",
downloaded_file_path = "kotlin-sdk-jvm-0.6.0-sources.jar"
)
http_file(

View File

@@ -30,7 +30,7 @@ suspend fun main() {
install(SSE)
}
val sseClientTransport = SseClientTransport(httpClient, "http://localhost:$port/")
val sseClientTransport = SseClientTransport(httpClient, "http://localhost:$port/sse")
val projectPath = System.getenv(IJ_MCP_SERVER_PROJECT_PATH)

View File

@@ -184,7 +184,9 @@ private fun McpTool.mcpToolToRegisteredTool(): RegisteredTool {
description = descriptor.description,
inputSchema = Tool.Input(
properties = descriptor.inputSchema.properties,
required = descriptor.inputSchema.requiredParameters.toList()))
required = descriptor.inputSchema.requiredParameters.toList()),
outputSchema = null,
annotations = null)
return RegisteredTool(tool) { request ->
val projectPath = (request._meta[IJ_MCP_SERVER_PROJECT_PATH] as? JsonPrimitive)?.content
val project = if (!projectPath.isNullOrBlank()) {
@@ -304,7 +306,7 @@ private fun McpTool.mcpToolToRegisteredTool(): RegisteredTool {
is McpToolCallResultContent.Text -> TextContent(content.text)
}
}
return@RegisteredTool CallToolResult(content = contents, callResult.isError)}
return@RegisteredTool CallToolResult(content = contents, structuredContent = null, isError = callResult.isError)}
}
}

View File

@@ -132,7 +132,7 @@ class SseTransportHolder(project: Project) : TransportHolder() {
override val transport: AbstractTransport by lazy {
SseClientTransport(HttpClient {
install(SSE)
}, "http://localhost:${McpServerService.getInstance().port}/")
}, "http://localhost:${McpServerService.getInstance().port}/sse")
}
override fun toString(): String {