in src/main/kotlin/org/jetbrains/mcpserverplugin/notification/ClaudeConfigManager.kt [24:53]
fun modifyClaudeSettings() {
val configFile = configPath.toFile()
if (!configFile.exists()) {
configFile.parentFile.mkdirs()
configFile.createNewFile()
}
val jsonObject = getExistingJsonObject() ?: JsonObject()
if (!jsonObject.has("mcpServers")) {
jsonObject.add("mcpServers", JsonObject())
}
val mcpServers = jsonObject.getAsJsonObject("mcpServers")
if (!isProxyInServers(mcpServers)) {
val jetbrainsConfig = JsonObject().apply {
addProperty("command", "npx")
add("args", gson.toJsonTree(arrayOf("-y", "@jetbrains/mcp-proxy")))
}
mcpServers.add("jetbrains", jetbrainsConfig)
try {
val prettyGson = GsonBuilder().setPrettyPrinting().create()
configFile.writeText(prettyGson.toJson(jsonObject))
} catch (e: Exception) {
throw RuntimeException("Failed to write configuration file", e)
}
}
}