forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp-add.test.ts
More file actions
74 lines (70 loc) · 1.99 KB
/
Copy pathmcp-add.test.ts
File metadata and controls
74 lines (70 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { describe, expect } from "bun:test"
import { Effect } from "effect"
import path from "path"
import { cliIt } from "../lib/cli-process"
describe("opencode mcp add (non-interactive subprocess)", () => {
cliIt.concurrent(
"adds a remote server with HTTP headers",
({ home, opencode }) =>
Effect.gen(function* () {
const result = yield* opencode.spawn([
"mcp",
"add",
"github",
"--url",
"https://example.com/mcp",
"--header",
"Authorization=Bearer {env:GITHUB_TOKEN}",
"--header",
"X-Option=one=two",
])
opencode.expectExit(result, 0)
const config = yield* Effect.promise(() =>
Bun.file(path.join(home, ".config", "opencode", "opencode.json")).json(),
)
expect(config.mcp.github).toEqual({
type: "remote",
url: "https://example.com/mcp",
headers: {
Authorization: "Bearer {env:GITHUB_TOKEN}",
"X-Option": "one=two",
},
})
}),
60_000,
)
cliIt.concurrent(
"adds a local server while preserving argv and environment values",
({ home, opencode }) =>
Effect.gen(function* () {
const result = yield* opencode.spawn([
"mcp",
"add",
"local",
"--env",
"API_KEY=secret",
"--env",
"VALUE=one=two",
"--",
"npx",
"-y",
"@example/server",
"--label",
"two words",
])
opencode.expectExit(result, 0)
const config = yield* Effect.promise(() =>
Bun.file(path.join(home, ".config", "opencode", "opencode.json")).json(),
)
expect(config.mcp.local).toEqual({
type: "local",
command: ["npx", "-y", "@example/server", "--label", "two words"],
environment: {
API_KEY: "secret",
VALUE: "one=two",
},
})
}),
60_000,
)
})