Skip to content

Commit b8c03e1

Browse files
prestistclaude
andcommitted
Add OpenCode client support
Co-Authored-By: Claude <[email protected]>
1 parent e667810 commit b8c03e1

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

cmd/thv/app/client.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Valid clients:
5757
- cursor: Cursor editor
5858
- goose: Goose AI agent
5959
- lm-studio: LM Studio application
60+
- opencode: OpenCode editor
6061
- roo-code: Roo Code extension for VS Code
6162
- trae: Trae IDE
6263
- vscode: Visual Studio Code
@@ -84,6 +85,7 @@ Valid clients:
8485
- cursor: Cursor editor
8586
- goose: Goose AI agent
8687
- lm-studio: LM Studio application
88+
- opencode: OpenCode editor
8789
- roo-code: Roo Code extension for VS Code
8890
- trae: Trae IDE
8991
- vscode: Visual Studio Code
@@ -191,13 +193,14 @@ func clientRegisterCmdFunc(cmd *cobra.Command, args []string) error {
191193
// Validate the client type
192194
switch clientType {
193195
case "roo-code", "cline", "cursor", "claude-code", "vscode-insider", "vscode", "windsurf", "windsurf-jetbrains",
194-
"amp-cli", "amp-vscode", "amp-vscode-insider", "amp-cursor", "amp-windsurf", "lm-studio", "goose", "trae", "continue":
196+
"amp-cli", "amp-vscode", "amp-vscode-insider", "amp-cursor", "amp-windsurf", "lm-studio", "goose", "trae",
197+
"continue", "opencode":
195198
// Valid client type
196199
default:
197200
return fmt.Errorf(
198201
"invalid client type: %s (valid types: roo-code, cline, cursor, claude-code, vscode, vscode-insider, "+
199202
"windsurf, windsurf-jetbrains, amp-cli, amp-vscode, amp-vscode-insider, amp-cursor, amp-windsurf, lm-studio, "+
200-
"goose, trae, continue)",
203+
"goose, trae, continue, opencode)",
201204
clientType)
202205
}
203206

@@ -210,13 +213,14 @@ func clientRemoveCmdFunc(cmd *cobra.Command, args []string) error {
210213
// Validate the client type
211214
switch clientType {
212215
case "roo-code", "cline", "cursor", "claude-code", "vscode-insider", "vscode", "windsurf", "windsurf-jetbrains",
213-
"amp-cli", "amp-vscode", "amp-vscode-insider", "amp-cursor", "amp-windsurf", "lm-studio", "goose", "trae", "continue":
216+
"amp-cli", "amp-vscode", "amp-vscode-insider", "amp-cursor", "amp-windsurf", "lm-studio", "goose", "trae",
217+
"continue", "opencode":
214218
// Valid client type
215219
default:
216220
return fmt.Errorf(
217221
"invalid client type: %s (valid types: roo-code, cline, cursor, claude-code, vscode, vscode-insider, "+
218222
"windsurf, windsurf-jetbrains, amp-cli, amp-vscode, amp-vscode-insider, amp-cursor, amp-windsurf, lm-studio, "+
219-
"goose, trae, continue)",
223+
"goose, trae, continue, opencode)",
220224
clientType)
221225
}
222226

docs/cli/thv_client_register.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/cli/thv_client_remove.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/config.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ const (
5959
Trae MCPClient = "trae"
6060
// Continue represents the Continue.dev IDE plugins.
6161
Continue MCPClient = "continue"
62+
// OpenCode represents the OpenCode editor.
63+
OpenCode MCPClient = "opencode"
6264
)
6365

6466
// Extension is extension of the client config file.
@@ -429,6 +431,21 @@ var supportedClientIntegrations = []mcpClientConfig{
429431
YAMLStorageType: YAMLStorageTypeArray,
430432
YAMLIdentifierField: "name",
431433
},
434+
{
435+
ClientType: OpenCode,
436+
Description: "OpenCode editor",
437+
SettingsFile: "opencode.json",
438+
MCPServersPathPrefix: "/mcp",
439+
RelPath: []string{".config", "opencode"},
440+
Extension: JSON,
441+
SupportedTransportTypesMap: map[types.TransportType]string{
442+
types.TransportTypeStdio: "remote", // OpenCode requires "type": "remote" for URL-based servers
443+
types.TransportTypeSSE: "remote",
444+
types.TransportTypeStreamableHTTP: "remote",
445+
},
446+
IsTransportTypeFieldSupported: true, // OpenCode requires "type": "remote" for URL-based servers
447+
MCPServersUrlLabel: "url",
448+
},
432449
}
433450

434451
// ConfigFile represents a client configuration file

pkg/client/config_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ func TestSuccessfulClientConfigOperations(t *testing.T) {
423423
case LMStudio, Trae:
424424
assert.Contains(t, string(content), `"mcpServers":`,
425425
"LMStudio config should contain mcpServers key")
426+
case OpenCode:
427+
assert.Contains(t, string(content), `"mcpServers":`,
428+
"OpenCode config should contain mcpServers key")
426429
case Goose:
427430
// YAML files are created empty and initialized on first use
428431
// Just verify the file exists and is readable
@@ -464,7 +467,7 @@ func TestSuccessfulClientConfigOperations(t *testing.T) {
464467
assert.Contains(t, string(content), testURL,
465468
"VSCode config should contain the server URL")
466469
case Cursor, RooCode, ClaudeCode, Cline, Windsurf, WindsurfJetBrains, AmpCli,
467-
AmpVSCode, AmpCursor, AmpVSCodeInsider, AmpWindsurf, LMStudio, Goose, Trae, Continue:
470+
AmpVSCode, AmpCursor, AmpVSCodeInsider, AmpWindsurf, LMStudio, Goose, Trae, Continue, OpenCode:
468471
assert.Contains(t, string(content), testURL,
469472
"Config should contain the server URL")
470473
}

0 commit comments

Comments
 (0)