Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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")
Expand Down
33 changes: 18 additions & 15 deletions src/main/kotlin/org/jetbrains/mcpextensiondemo/MyCustomTool.kt
Original file line number Diff line number Diff line change
@@ -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>(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
)
data class MyCustomResult(
val message: String,
val error: String? = null
)