mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-14 00:57:49 +00:00
fixup! fix(apply): propagate read errors, auto-open repo, dedupe adapter base (#6)
This commit is contained in:
@@ -168,6 +168,7 @@ func parseMCPEntry(name string, raw json.RawMessage) (canonical.MCPServer, bool)
|
|||||||
Cmd json.RawMessage `json:"cmd"`
|
Cmd json.RawMessage `json:"cmd"`
|
||||||
Args []string `json:"args"`
|
Args []string `json:"args"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
|
Headers map[string]string `json:"headers"`
|
||||||
Env map[string]string `json:"env"`
|
Env map[string]string `json:"env"`
|
||||||
Environment map[string]string `json:"environment"`
|
Environment map[string]string `json:"environment"`
|
||||||
}
|
}
|
||||||
@@ -198,6 +199,7 @@ func parseMCPEntry(name string, raw json.RawMessage) (canonical.MCPServer, bool)
|
|||||||
Args: args,
|
Args: args,
|
||||||
URL: e.URL,
|
URL: e.URL,
|
||||||
Transport: transport,
|
Transport: transport,
|
||||||
|
Headers: e.Headers,
|
||||||
Env: env,
|
Env: env,
|
||||||
}, true
|
}, true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ func TestImportMCPFromJSONFileFSExtractsServers(t *testing.T) {
|
|||||||
"myserver": {
|
"myserver": {
|
||||||
"command": "/usr/bin/mytool",
|
"command": "/usr/bin/mytool",
|
||||||
"args": ["--flag"],
|
"args": ["--flag"],
|
||||||
|
"headers": {"Authorization": "Bearer ${MCP_TOKEN}"},
|
||||||
"type": "stdio"
|
"type": "stdio"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,6 +56,7 @@ func TestImportMCPFromJSONFileFSExtractsServers(t *testing.T) {
|
|||||||
assert.Equal(t, "/usr/bin/mytool", servers[0].Command)
|
assert.Equal(t, "/usr/bin/mytool", servers[0].Command)
|
||||||
assert.Equal(t, []string{"--flag"}, servers[0].Args)
|
assert.Equal(t, []string{"--flag"}, servers[0].Args)
|
||||||
assert.Equal(t, "stdio", servers[0].Transport)
|
assert.Equal(t, "stdio", servers[0].Transport)
|
||||||
|
assert.Equal(t, map[string]string{"Authorization": "Bearer ${MCP_TOKEN}"}, servers[0].Headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestImportMCPFromJSONFileFSReadOnlyFS(t *testing.T) {
|
func TestImportMCPFromJSONFileFSReadOnlyFS(t *testing.T) {
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ func mcpEntry(s canonical.MCPServer, style MCPStyle) map[string]any {
|
|||||||
}
|
}
|
||||||
e["type"] = t
|
e["type"] = t
|
||||||
e["url"] = s.URL
|
e["url"] = s.URL
|
||||||
|
if len(s.Headers) > 0 {
|
||||||
|
e["headers"] = s.Headers
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Claude honours Transport field; Crush always uses "stdio".
|
// Claude honours Transport field; Crush always uses "stdio".
|
||||||
t := "stdio"
|
t := "stdio"
|
||||||
@@ -60,6 +63,9 @@ func mcpEntry(s canonical.MCPServer, style MCPStyle) map[string]any {
|
|||||||
if s.URL != "" {
|
if s.URL != "" {
|
||||||
e["type"] = "remote"
|
e["type"] = "remote"
|
||||||
e["url"] = s.URL
|
e["url"] = s.URL
|
||||||
|
if len(s.Headers) > 0 {
|
||||||
|
e["headers"] = s.Headers
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
e["type"] = "local"
|
e["type"] = "local"
|
||||||
cmd := []string{}
|
cmd := []string{}
|
||||||
@@ -79,6 +85,9 @@ func mcpEntry(s canonical.MCPServer, style MCPStyle) map[string]any {
|
|||||||
// fail all of them. Omitting "enabled" defaults to true.
|
// fail all of them. Omitting "enabled" defaults to true.
|
||||||
if s.URL != "" {
|
if s.URL != "" {
|
||||||
e["url"] = s.URL
|
e["url"] = s.URL
|
||||||
|
if len(s.Headers) > 0 {
|
||||||
|
e["headers"] = s.Headers
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if s.Command != "" {
|
if s.Command != "" {
|
||||||
e["command"] = s.Command
|
e["command"] = s.Command
|
||||||
|
|||||||
@@ -26,11 +26,16 @@ func TestBuildMCPMapStyledClaudeStyle(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildMCPMapStyledClaudeStyleURL(t *testing.T) {
|
func TestBuildMCPMapStyledClaudeStyleURL(t *testing.T) {
|
||||||
r := reg(canonical.MCPServer{Name: "remote", URL: "https://example.com"})
|
r := reg(canonical.MCPServer{
|
||||||
|
Name: "remote",
|
||||||
|
URL: "https://example.com",
|
||||||
|
Headers: map[string]string{"Authorization": "Bearer ${MCP_TOKEN}"},
|
||||||
|
})
|
||||||
out := BuildMCPMapStyled(r, MCPClaudeStyle)
|
out := BuildMCPMapStyled(r, MCPClaudeStyle)
|
||||||
e := out["remote"].(map[string]any)
|
e := out["remote"].(map[string]any)
|
||||||
assert.Equal(t, "https://example.com", e["url"])
|
assert.Equal(t, "https://example.com", e["url"])
|
||||||
assert.Equal(t, "http", e["type"])
|
assert.Equal(t, "http", e["type"])
|
||||||
|
assert.Equal(t, map[string]string{"Authorization": "Bearer ${MCP_TOKEN}"}, e["headers"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildMCPMapStyledCrushStdio(t *testing.T) {
|
func TestBuildMCPMapStyledCrushStdio(t *testing.T) {
|
||||||
@@ -70,12 +75,17 @@ func TestBuildMCPMapStyledOpencodeLocal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildMCPMapStyledOpencodeRemote(t *testing.T) {
|
func TestBuildMCPMapStyledOpencodeRemote(t *testing.T) {
|
||||||
r := reg(canonical.MCPServer{Name: "r", URL: "https://example.com"})
|
r := reg(canonical.MCPServer{
|
||||||
|
Name: "r",
|
||||||
|
URL: "https://example.com",
|
||||||
|
Headers: map[string]string{"X-Tenant": "tenant-a"},
|
||||||
|
})
|
||||||
out := BuildMCPMapStyled(r, MCPOpencodeStyle)
|
out := BuildMCPMapStyled(r, MCPOpencodeStyle)
|
||||||
e := out["r"].(map[string]any)
|
e := out["r"].(map[string]any)
|
||||||
assert.Equal(t, "remote", e["type"])
|
assert.Equal(t, "remote", e["type"])
|
||||||
assert.Equal(t, true, e["enabled"])
|
assert.Equal(t, true, e["enabled"])
|
||||||
assert.Equal(t, "https://example.com", e["url"])
|
assert.Equal(t, "https://example.com", e["url"])
|
||||||
|
assert.Equal(t, map[string]string{"X-Tenant": "tenant-a"}, e["headers"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildMCPMapStyledOpencodeEnv(t *testing.T) {
|
func TestBuildMCPMapStyledOpencodeEnv(t *testing.T) {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ type MCPRegistry struct {
|
|||||||
|
|
||||||
type MCPServer struct {
|
type MCPServer struct {
|
||||||
Env map[string]string `yaml:"env,omitempty"`
|
Env map[string]string `yaml:"env,omitempty"`
|
||||||
|
Headers map[string]string `yaml:"headers,omitempty"`
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Command string `yaml:"command,omitempty"`
|
Command string `yaml:"command,omitempty"`
|
||||||
URL string `yaml:"url,omitempty"`
|
URL string `yaml:"url,omitempty"`
|
||||||
|
|||||||
Reference in New Issue
Block a user