on main help sign in
Merge pull request #109 from charmbracelet/stable-sorting
7226a61Kujtim Hoxha
internal/config/config.go+6−5
@@ -86,11 +86,12 @@ const (
86)
86)
87
87
88type MCPConfig struct {
88type MCPConfig struct {
89− Command string `json:"command,omitempty" `
89+ Command string `json:"command,omitempty" `
90− Env []string `json:"env,omitempty"`
90+ Env []string `json:"env,omitempty"`
91− Args []string `json:"args,omitempty"`
91+ Args []string `json:"args,omitempty"`
92− Type MCPType `json:"type"`
92+ Type MCPType `json:"type"`
93− URL string `json:"url,omitempty"`
93+ URL string `json:"url,omitempty"`
94+ Disabled bool `json:"disabled,omitempty"`
94
95
95 // TODO: maybe make it possible to get the value from the env
96 // TODO: maybe make it possible to get the value from the env
96 Headers map[string]string `json:"headers,omitempty"`
97 Headers map[string]string `json:"headers,omitempty"`
internal/llm/agent/mcp-tools.go+4
@@ -188,6 +188,10 @@ func GetMcpTools(ctx context.Context, permissions permission.Service, cfg *confi
188 return mcpTools
188 return mcpTools
189 }
189 }
190 for name, m := range cfg.MCP {
190 for name, m := range cfg.MCP {
191+ if m.Disabled {
192+ slog.Debug("skipping disabled mcp", "name", name)
193+ continue
194+ }
191 switch m.Type {
195 switch m.Type {
192 case config.MCPStdio:
196 case config.MCPStdio:
193 c, err := client.NewStdioMCPClient(
197 c, err := client.NewStdioMCPClient(
internal/tui/components/chat/sidebar/sidebar.go+14−11
@@ -332,7 +332,7 @@ func (m *sidebarCmp) lspBlock() string {
332
332
333 lspList := []string{section, ""}
333 lspList := []string{section, ""}
334
334
335− lsp := config.Get().LSP
335+ lsp := config.Get().LSP.Sorted()
336 if len(lsp) == 0 {
336 if len(lsp) == 0 {
337 return lipgloss.JoinVertical(
337 return lipgloss.JoinVertical(
338 lipgloss.Left,
338 lipgloss.Left,
@@ -342,9 +342,9 @@ func (m *sidebarCmp) lspBlock() string {
342 )
342 )
343 }
343 }
344
344
345− for n, l := range lsp {
345+ for _, l := range lsp {
346 iconColor := t.Success
346 iconColor := t.Success
347− if l.Disabled {
347+ if l.LSP.Disabled {
348 iconColor = t.FgMuted
348 iconColor = t.FgMuted
349 }
349 }
350 lspErrs := map[protocol.DiagnosticSeverity]int{
350 lspErrs := map[protocol.DiagnosticSeverity]int{
@@ -353,7 +353,7 @@ func (m *sidebarCmp) lspBlock() string {
353 protocol.SeverityHint: 0,
353 protocol.SeverityHint: 0,
354 protocol.SeverityInformation: 0,
354 protocol.SeverityInformation: 0,
355 }
355 }
356− if client, ok := m.lspClients[n]; ok {
356+ if client, ok := m.lspClients[l.Name]; ok {
357 for _, diagnostics := range client.GetDiagnostics() {
357 for _, diagnostics := range client.GetDiagnostics() {
358 for _, diagnostic := range diagnostics {
358 for _, diagnostic := range diagnostics {
359 if severity, ok := lspErrs[diagnostic.Severity]; ok {
359 if severity, ok := lspErrs[diagnostic.Severity]; ok {
@@ -381,8 +381,8 @@ func (m *sidebarCmp) lspBlock() string {
381 core.Status(
381 core.Status(
382 core.StatusOpts{
382 core.StatusOpts{
383 IconColor: iconColor,
383 IconColor: iconColor,
384− Title: n,
384+ Title: l.Name,
385− Description: l.Command,
385+ Description: l.LSP.Command,
386 ExtraContent: strings.Join(errs, " "),
386 ExtraContent: strings.Join(errs, " "),
387 },
387 },
388 m.width,
388 m.width,
@@ -406,8 +406,8 @@ func (m *sidebarCmp) mcpBlock() string {
406
406
407 mcpList := []string{section, ""}
407 mcpList := []string{section, ""}
408
408
409− mcp := config.Get().MCP
409+ mcps := config.Get().MCP.Sorted()
410− if len(mcp) == 0 {
410+ if len(mcps) == 0 {
411 return lipgloss.JoinVertical(
411 return lipgloss.JoinVertical(
412 lipgloss.Left,
412 lipgloss.Left,
413 section,
413 section,
@@ -416,14 +416,17 @@ func (m *sidebarCmp) mcpBlock() string {
416 )
416 )
417 }
417 }
418
418
419− for n, l := range mcp {
419+ for _, l := range mcps {
420 iconColor := t.Success
420 iconColor := t.Success
421+ if l.MCP.Disabled {
422+ iconColor = t.FgMuted
423+ }
421 mcpList = append(mcpList,
424 mcpList = append(mcpList,
422 core.Status(
425 core.Status(
423 core.StatusOpts{
426 core.StatusOpts{
424 IconColor: iconColor,
427 IconColor: iconColor,
425− Title: n,
428+ Title: l.Name,
426− Description: l.Command,
429+ Description: l.MCP.Command,
427 },
430 },
428 m.width,
431 m.width,
429 ),
432 ),