Skip to content

Commit dad6906

Browse files
committed
feat(mcp): set work directory for MCP server command #371
Add project directory as work directory for MCP server command execution to ensure proper file resolution
1 parent 57b59ab commit dad6906

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

core/src/main/kotlin/cc/unitmesh/devti/mcp/client/CustomMcpServerManager.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import java.io.File
2323
import java.io.BufferedReader
2424
import java.io.InputStreamReader
2525
import com.intellij.execution.configurations.GeneralCommandLine
26+
import com.intellij.openapi.project.guessProjectDir
2627

2728
@Service(Service.Level.PROJECT)
2829
class CustomMcpServerManager(val project: Project) {
@@ -60,6 +61,8 @@ class CustomMcpServerManager(val project: Project) {
6061
val cmd = GeneralCommandLine(resolvedCommand)
6162
cmd.addParameters(*serverConfig.args.toTypedArray())
6263

64+
cmd.workDirectory = File(project.guessProjectDir()!!.path)
65+
6366
serverConfig.env?.forEach { (key, value) ->
6467
cmd.environment[key] = value
6568
}

0 commit comments

Comments
 (0)