|
1 | 1 | { |
2 | 2 | "mcpServers": { |
3 | 3 | {{- $servers := index . "mcpServers" -}} |
4 | | -{{- $isPrivate := and (hasKey . "private") .private -}} |
5 | 4 | {{- $first := true -}} |
6 | 5 | {{- range $server := $servers -}} |
7 | | -{{- $isPrivateBlocked := and (hasKey $server "conditions") (index $server.conditions "requirePrivateFalse") $isPrivate -}} |
8 | | -{{- if and $server.targets.cursor.enabled (not $isPrivateBlocked) -}} |
9 | | -{{- if hasKey $server.targets.cursor "local" -}} |
10 | | -{{- $cursorCommand := $server.local.command -}} |
11 | | -{{- if hasKey $server.targets.cursor.local "command" -}} |
12 | | -{{- $cursorCommand = $server.targets.cursor.local.command -}} |
| 6 | +{{- $conditionsMatch := true -}} |
| 7 | +{{- if hasKey $server "conditions" -}} |
| 8 | +{{- range $conditionKey, $expected := $server.conditions -}} |
| 9 | +{{- if and (hasKey $ $conditionKey) (eq (index $ $conditionKey) $expected) -}} |
| 10 | +{{- else -}} |
| 11 | +{{- $conditionsMatch = false -}} |
| 12 | +{{- end -}} |
13 | 13 | {{- end -}} |
14 | | -{{- $cursorArgs := $server.local.args -}} |
15 | | -{{- if hasKey $server.targets.cursor.local "args" -}} |
16 | | -{{- $cursorArgs = $server.targets.cursor.local.args -}} |
17 | 14 | {{- end -}} |
| 15 | +{{- if and $server.targets.cursor.enabled $conditionsMatch -}} |
| 16 | +{{- if hasKey $server "local" -}} |
| 17 | +{{- $cursorCommand := $server.local.command -}} |
| 18 | +{{- $cursorArgs := $server.local.args -}} |
18 | 19 | {{- $cursorEnv := (default (dict) $server.local.env) -}} |
19 | | -{{- if hasKey $server.targets.cursor.local "env" -}} |
20 | | -{{- $cursorEnv = $server.targets.cursor.local.env -}} |
| 20 | +{{- if hasKey $server.local "appendDataArgs" -}} |
| 21 | +{{- range $dataKey := $server.local.appendDataArgs -}} |
| 22 | +{{- if hasKey $ $dataKey -}} |
| 23 | +{{- $cursorArgs = append $cursorArgs (index $ $dataKey) -}} |
21 | 24 | {{- end -}} |
22 | | -{{- if hasKey $server.targets.cursor.local "appendVaultPath" -}} |
23 | | -{{- if $server.targets.cursor.local.appendVaultPath -}} |
24 | | -{{- $cursorArgs = append $cursorArgs (printf "%s/Documents/Obsidian/Vault" $.chezmoi.homeDir) -}} |
25 | 25 | {{- end -}} |
26 | | -{{- else if and (hasKey $server.local "appendVaultPath") $server.local.appendVaultPath -}} |
27 | | -{{- $cursorArgs = append $cursorArgs (printf "%s/Documents/Obsidian/Vault" $.chezmoi.homeDir) -}} |
28 | 26 | {{- end -}} |
29 | 27 | {{- if $first }}{{- $first = false }}{{ else }},{{ end }} |
30 | 28 | "{{ $server.id }}": { |
31 | 29 | "command": "{{ $cursorCommand }}", |
32 | 30 | "env": {{ $cursorEnv | toPrettyJson " " }}, |
33 | 31 | "args": {{ $cursorArgs | toPrettyJson " " }} |
34 | 32 | } |
35 | | -{{- else if hasKey $server "local" -}} |
36 | | -{{- $cursorCommand := $server.local.command -}} |
37 | | -{{- $cursorArgs := $server.local.args -}} |
38 | | -{{- if and (hasKey $server.local "appendVaultPath") $server.local.appendVaultPath -}} |
39 | | -{{- $cursorArgs = append $cursorArgs (printf "%s/Documents/Obsidian/Vault" $.chezmoi.homeDir) -}} |
40 | | -{{- end -}} |
41 | | -{{- if $first }}{{- $first = false }}{{ else }},{{ end }} |
42 | | - "{{ $server.id }}": { |
43 | | - "command": "{{ $cursorCommand }}", |
44 | | - "env": {{ (default (dict) $server.local.env) | toPrettyJson " " }}, |
45 | | - "args": {{ $cursorArgs | toPrettyJson " " }} |
46 | | - } |
47 | | -{{- else if hasKey $server.targets.cursor "remote" -}} |
48 | | -{{- $cursorTransport := "streamableHttp" -}} |
49 | | -{{- if hasKey $server.targets.cursor.remote "transport" -}} |
50 | | -{{- $cursorTransport = $server.targets.cursor.remote.transport -}} |
51 | | -{{- end -}} |
52 | | -{{- $cursorUrl := $server.remote.url -}} |
53 | | -{{- if hasKey $server.targets.cursor.remote "url" -}} |
54 | | -{{- $cursorUrl = $server.targets.cursor.remote.url -}} |
55 | | -{{- end -}} |
56 | | -{{- $cursorHeaders := dict -}} |
57 | | -{{- if hasKey $server.targets.cursor.remote "headers" -}} |
58 | | -{{- $cursorHeaders = $server.targets.cursor.remote.headers -}} |
59 | | -{{- end -}} |
60 | | -{{- if $first }}{{- $first = false }}{{ else }},{{ end }} |
61 | | - "{{ $server.id }}": { |
62 | | - "transport": "{{ $cursorTransport }}", |
63 | | - "url": "{{ $cursorUrl }}", |
64 | | - "headers": {{ $cursorHeaders | toPrettyJson " " }} |
65 | | - } |
66 | 33 | {{- else if hasKey $server "remote" -}} |
67 | 34 | {{- $cursorTransport := "streamableHttp" -}} |
68 | 35 | {{- if hasKey $server.remote "transport" -}} |
|
0 commit comments