Files

50 lines
1.7 KiB
Go

package chattools
import (
"encoding/json"
"strings"
)
// ClaudeMCPConfig is the inline JSON Claude Code takes as --mcp-config.
func ClaudeMCPConfig(url string) string {
data, _ := json.Marshal(map[string]any{"mcpServers": map[string]any{
ServerName: map[string]any{"type": "http", "url": url},
}})
return string(data)
}
// ClaudeAllowedTools pre-approves every Pipelines tool, so a call never waits
// on a permission card: the tools only present content to the operator.
func ClaudeAllowedTools() string { return "mcp__" + ServerName }
// CodexConfig is the thread/start (and thread/resume) config override that
// registers the endpoint as a streamable HTTP MCP server for one thread.
func CodexConfig(url string) map[string]any {
return map[string]any{"mcp_servers": map[string]any{
ServerName: map[string]any{"url": url},
}}
}
// OpenCodeConfig is the OpenCode config fragment registering the endpoint as a
// remote MCP server.
func OpenCodeConfig(url string) map[string]any {
return map[string]any{"mcp": map[string]any{
ServerName: map[string]any{"type": "remote", "url": url, "enabled": true},
}}
}
// HarnessToolNames are the names one tool has in each harness's transcript.
func HarnessToolNames(tool string) []string {
return []string{"mcp__" + ServerName + "__" + tool, ServerName + "_" + tool, ServerName + "/" + tool}
}
// ToolFromHarnessName returns the Pipelines tool a harness tool name denotes.
func ToolFromHarnessName(name string) (string, bool) {
for _, prefix := range []string{"mcp__" + ServerName + "__", ServerName + "_", ServerName + "/"} {
if tool, ok := strings.CutPrefix(name, prefix); ok && IsTool(tool) {
return tool, true
}
}
return "", false
}