diff --git a/internal/config/config.go b/internal/config/config.go index 2b81094ed394e669b4d293200f911a875c2deacb..a32d04f9b62cf6e734f98e35df01c6148e06573a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -86,11 +86,12 @@ const ( ) type MCPConfig struct { - Command string `json:"command,omitempty" ` - Env []string `json:"env,omitempty"` - Args []string `json:"args,omitempty"` - Type MCPType `json:"type"` - URL string `json:"url,omitempty"` + Command string `json:"command,omitempty" ` + Env []string `json:"env,omitempty"` + Args []string `json:"args,omitempty"` + Type MCPType `json:"type"` + URL string `json:"url,omitempty"` + Disabled bool `json:"disabled,omitempty"` // TODO: maybe make it possible to get the value from the env Headers map[string]string `json:"headers,omitempty"` diff --git a/internal/llm/agent/mcp-tools.go b/internal/llm/agent/mcp-tools.go index bb9b497722151c137dba1575390744230a3d6e99..d8610b557896272d94c76c608b9bc00347655be4 100644 --- a/internal/llm/agent/mcp-tools.go +++ b/internal/llm/agent/mcp-tools.go @@ -188,6 +188,10 @@ func GetMcpTools(ctx context.Context, permissions permission.Service, cfg *confi return mcpTools } for name, m := range cfg.MCP { + if m.Disabled { + slog.Debug("skipping disabled mcp", "name", name) + continue + } switch m.Type { case config.MCPStdio: c, err := client.NewStdioMCPClient( diff --git a/internal/tui/components/chat/sidebar/sidebar.go b/internal/tui/components/chat/sidebar/sidebar.go index 14c9468a401956adce14c3a2b08f0166c096dd6b..3d8338c2b40b33febd9d78f2649cc3aa06337db6 100644 --- a/internal/tui/components/chat/sidebar/sidebar.go +++ b/internal/tui/components/chat/sidebar/sidebar.go @@ -332,7 +332,7 @@ func (m *sidebarCmp) lspBlock() string { lspList := []string{section, ""} - lsp := config.Get().LSP + lsp := config.Get().LSP.Sorted() if len(lsp) == 0 { return lipgloss.JoinVertical( lipgloss.Left, @@ -342,9 +342,9 @@ func (m *sidebarCmp) lspBlock() string { ) } - for n, l := range lsp { + for _, l := range lsp { iconColor := t.Success - if l.Disabled { + if l.LSP.Disabled { iconColor = t.FgMuted } lspErrs := map[protocol.DiagnosticSeverity]int{ @@ -353,7 +353,7 @@ func (m *sidebarCmp) lspBlock() string { protocol.SeverityHint: 0, protocol.SeverityInformation: 0, } - if client, ok := m.lspClients[n]; ok { + if client, ok := m.lspClients[l.Name]; ok { for _, diagnostics := range client.GetDiagnostics() { for _, diagnostic := range diagnostics { if severity, ok := lspErrs[diagnostic.Severity]; ok { @@ -381,8 +381,8 @@ func (m *sidebarCmp) lspBlock() string { core.Status( core.StatusOpts{ IconColor: iconColor, - Title: n, - Description: l.Command, + Title: l.Name, + Description: l.LSP.Command, ExtraContent: strings.Join(errs, " "), }, m.width, @@ -406,8 +406,8 @@ func (m *sidebarCmp) mcpBlock() string { mcpList := []string{section, ""} - mcp := config.Get().MCP - if len(mcp) == 0 { + mcps := config.Get().MCP.Sorted() + if len(mcps) == 0 { return lipgloss.JoinVertical( lipgloss.Left, section, @@ -416,14 +416,17 @@ func (m *sidebarCmp) mcpBlock() string { ) } - for n, l := range mcp { + for _, l := range mcps { iconColor := t.Success + if l.MCP.Disabled { + iconColor = t.FgMuted + } mcpList = append(mcpList, core.Status( core.StatusOpts{ IconColor: iconColor, - Title: n, - Description: l.Command, + Title: l.Name, + Description: l.MCP.Command, }, m.width, ),