Skip to content

Commit 53dca04

Browse files
committed
feat(mcp): add IssueEvaluateTool for issue analysis
Introduce a new tool `IssueEvaluateTool` to evaluate issues or stories within the project context. The tool sends the issue description to the sketch tool window for analysis and returns a response indicating the start of the analysis process. The tool is registered in `HostMcpToolManager`.
1 parent b95f815 commit 53dca04

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

core/src/main/kotlin/cc/unitmesh/devti/mcp/host/AutoDevMcpTools.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cc.unitmesh.devti.gui.AutoDevToolWindowFactory
44
import cc.unitmesh.devti.gui.chat.message.ChatActionType
55
import com.intellij.openapi.project.Project
66
import kotlinx.serialization.Serializable
7+
import com.intellij.openapi.application.runInEdt
78

89
@Serializable
910
data class IssueArgs(val issue: String)
@@ -22,8 +23,10 @@ class IssueEvaluateTool : AbstractMcpTool<IssueArgs>() {
2223
): Response {
2324
val issue = args.issue
2425

25-
AutoDevToolWindowFactory.Companion.sendToSketchToolWindow(project, ChatActionType.SKETCH) { ui, _ ->
26-
ui.sendInput(issue)
26+
runInEdt {
27+
AutoDevToolWindowFactory.Companion.sendToSketchToolWindow(project, ChatActionType.SKETCH) { ui, _ ->
28+
ui.sendInput(issue)
29+
}
2730
}
2831

2932
return Response("Start analysis in IDEA")

core/src/main/kotlin/cc/unitmesh/devti/sketch/SketchToolWindow.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,14 @@ open class SketchToolWindow(
351351

352352
fun sendInput(text: String) {
353353
inputSection.text += "\n" + text
354-
inputSection.send()
354+
ApplicationManager.getApplication().invokeLater {
355+
inputSection.send()
356+
}
355357
}
356358

357359
fun scrollToBottom() {
358360
if (!isUserScrolling) {
359-
SwingUtilities.invokeLater {
361+
ApplicationManager.getApplication().invokeLater {
360362
val verticalScrollBar = scrollPanel.verticalScrollBar
361363
verticalScrollBar.value = verticalScrollBar.maximum
362364
}

docs/mcp/mcp-client.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,18 @@ Execute list_directory tool's result
6666
"text": "[FILE] mcp-client.md\n[FILE] mcp-server.md\n[FILE] mcp.md"
6767
}
6868
]
69-
```
69+
```
70+
71+
### Test for Sketch call
72+
73+
- http://127.0.0.1:63342/api/mcp/list_tools
74+
75+
76+
```bash
77+
➜ ~ curl -X POST "http://127.0.0.1:63343/api/mcp/issue_or_story_evaluate" \
78+
> -H "Content-Type: application/json" \
79+
> -d '{"issue": "重构 blog 为 DDD 服务"}'
80+
{
81+
"error": "Failed to execute tool issue_or_story_evaluate, message Access is allowed from Event Dispatch Thread (EDT) only; see https://jb.gg/ij-platform-threading for details\nCurrent thread: Thread[Netty Builtin Server 3,5,main] 496134154 (EventQueue.isDispatchThread()=false)\nSystemEventQueueThread: Thread[AWT-EventQueue-0,6,main] 321680684"
82+
}
83+
```

0 commit comments

Comments
 (0)