From 4f0abaebce0c3ad9f45da2b5967c8e47dc23e9b3 Mon Sep 17 00:00:00 2001 From: hepiao3 Date: Mon, 11 May 2026 15:47:10 +0800 Subject: [PATCH 1/2] fix(core): migrate MyCustomTool to McpToolset API --- build.gradle.kts | 6 ++-- .../mcpextensiondemo/MyCustomTool.kt | 33 ++++++++++--------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a98bcb7..d641e70 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,8 @@ plugins { id("java") - kotlin("jvm") version "1.9.24" + kotlin("jvm") version "2.3.0" id("org.jetbrains.intellij.platform") version "2.5.0" - kotlin("plugin.serialization") version "1.9.24" + kotlin("plugin.serialization") version "2.3.0" } group = "org.jetbrains" @@ -21,7 +21,7 @@ dependencies { intellijPlatform { create("IC", "2024.3") testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Platform) - plugin("com.intellij.mcpServer", "1.0.30") + plugin("com.intellij.mcpServer", "261.24374.39") // Add necessary plugin dependencies for compilation here, example: // bundledPlugin("com.intellij.java") diff --git a/src/main/kotlin/org/jetbrains/mcpextensiondemo/MyCustomTool.kt b/src/main/kotlin/org/jetbrains/mcpextensiondemo/MyCustomTool.kt index 8540b6c..7c9192e 100644 --- a/src/main/kotlin/org/jetbrains/mcpextensiondemo/MyCustomTool.kt +++ b/src/main/kotlin/org/jetbrains/mcpextensiondemo/MyCustomTool.kt @@ -1,24 +1,27 @@ package org.jetbrains.mcpextensiondemo -import com.intellij.openapi.project.Project +import com.intellij.mcpserver.McpToolset +import com.intellij.mcpserver.annotations.McpDescription +import com.intellij.mcpserver.annotations.McpTool +import com.intellij.openapi.project.ProjectManager import kotlinx.serialization.Serializable -import kotlinx.serialization.encodeToString -import kotlinx.serialization.json.Json -import org.jetbrains.ide.mcp.Response -import org.jetbrains.mcpserverplugin.AbstractMcpTool -class MyCustomTool : AbstractMcpTool(MyArgs.serializer()) { - override val name: String = "my_custom_tool" - override val description: String = "Custom tool for the demonstration" +class MyCustomTool : McpToolset { - override fun handle(project: Project, args: MyArgs): Response { - return Response("Everything is fine, passed args: ${args.param1}, args: ${args.param2}") + @McpTool + @McpDescription(description = "Custom tool for the demonstration that echoes back passed arguments.") + suspend fun my_custom_tool( + param1: String, + param2: Int + ): MyCustomResult { + return MyCustomResult( + message = "Everything is fine, passed args: $param1, args: $param2" + ) } } -// Define your arguments data class @Serializable -data class MyArgs( - val param1: String, - val param2: Int -) \ No newline at end of file +data class MyCustomResult( + val message: String, + val error: String? = null +) From 7e074730ac63d133fcea552b35d578662a97b0a3 Mon Sep 17 00:00:00 2001 From: hepiao3 Date: Mon, 11 May 2026 16:02:27 +0800 Subject: [PATCH 2/2] docs(core): update README with latest version placeholder --- README.MD | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.MD b/README.MD index 5a42d4e..92801c3 100644 --- a/README.MD +++ b/README.MD @@ -17,10 +17,12 @@ This is needed to use the same version of serialization as in the main plugin. ``` dependencies { intellijPlatform { - plugin("com.intellij.mcpServer", "1.0.30") + plugin("com.intellij.mcpServer", "[latest version]") } } ``` + +> Replace `[latest version]` with the latest version from [JetBrains MCP Server Plugin](https://plugins.jetbrains.com/plugin/26071-mcp-server). * Make kotlinx.serialization compileOnly dependendency to avoid runtime errors due to different class loaders of the library ```kotlin dependencies {