1package soy.iko.opencode.ui.mcp
3import kotlinx.serialization.json.add
4import kotlinx.serialization.json.buildJsonObject
5import kotlinx.serialization.json.put
6import kotlinx.serialization.json.putJsonArray
7import kotlinx.serialization.json.putJsonObject
8import org.junit.Assert.assertEquals
9import org.junit.Assert.assertFalse
10import org.junit.Assert.assertTrue
16 fun parsesLocalAndRemoteServers() {
17 val config = buildJsonObject {
18 putJsonObject("mcp") {
19 putJsonObject("local-one") {
22 putJsonArray("command") { add("node"); add("server.js") }
24 putJsonObject("remote-one") {
26 put("url", "https://example.com/mcp")
31 val servers = parseMcpServers(config)
32 assertEquals(2, servers.size)
33 val local = servers.first { it.name == "local-one" }
34 assertEquals("local", local.type)
35 assertTrue(local.enabled)
36 assertEquals("node server.js", local.target)
37 val remote = servers.first { it.name == "remote-one" }
38 assertFalse(remote.enabled)
39 assertEquals("https://example.com/mcp", remote.target)
43 fun defaultsEnabledWhenOmitted() {
44 val config = buildJsonObject { putJsonObject("mcp") { putJsonObject("x") { put("type", "local") } } }
45 assertTrue(parseMcpServers(config).single().enabled)
49 fun emptyWhenNoMcpKey() {
50 assertTrue(parseMcpServers(buildJsonObject { }).isEmpty())
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list