File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
core/src/main/kotlin/cc/unitmesh/devti/mcp Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,22 @@ class CustomMcpServerManager(val project: Project) {
111
111
return " No such tool: ${tool.name} or failed to execute"
112
112
}
113
113
114
+ suspend fun collectServerInfos (config : String ): Map <String , List <Tool >> {
115
+ if (cached.containsKey(config)) return cached[config]!!
116
+ val mcpConfig = McpServer .load(config)
117
+ if (mcpConfig == null ) return emptyMap()
118
+
119
+ val toolsMap = mutableMapOf<String , List <Tool >>()
120
+ mcpConfig.mcpServers.forEach { entry ->
121
+ if (entry.value.disabled == true ) return @forEach
122
+ val tools = collectServerInfo(entry.key, entry.value)
123
+ toolsMap[entry.key] = tools
124
+ }
125
+
126
+ cached[config] = toolsMap
127
+ return toolsMap
128
+ }
129
+
114
130
companion object {
115
131
fun instance (project : Project ): CustomMcpServerManager {
116
132
return project.getService(CustomMcpServerManager ::class .java)
Original file line number Diff line number Diff line change 1
1
package cc.unitmesh.devti.mcp.editor
2
2
3
3
import cc.unitmesh.devti.mcp.client.CustomMcpServerManager
4
+ import com.intellij.openapi.application.runReadAction
4
5
import com.intellij.openapi.editor.Editor
5
6
import com.intellij.openapi.fileEditor.FileEditor
6
7
import com.intellij.openapi.fileEditor.FileEditorState
@@ -33,6 +34,7 @@ import java.awt.GridLayout
33
34
import java.beans.PropertyChangeListener
34
35
import javax.swing.*
35
36
import javax.swing.border.CompoundBorder
37
+ import cc.unitmesh.devti.sketch.ui.patch.readText
36
38
37
39
/* *
38
40
* Display shire file render prompt and have a sample file as view
@@ -75,8 +77,9 @@ open class McpPreviewEditor(
75
77
}
76
78
77
79
private fun loadTools () {
80
+ val content = runReadAction { virtualFile.readText() }
78
81
CoroutineScope (Dispatchers .IO ).launch {
79
- allTools.putAll(mcpServerManager.collectServerInfos())
82
+ allTools.putAll(mcpServerManager.collectServerInfos(content ))
80
83
SwingUtilities .invokeLater {
81
84
addTools()
82
85
}
You can’t perform that action at this time.
0 commit comments