返回 DeepSeek-Reasonix
mcp_remove_helpers.go
根目录 / desktop / mcp_remove_helpers.go
1 package main
2
3 import (
4 "errors"
5 "fmt"
6
7 "reasonix/internal/config"
8 "reasonix/internal/mcpdiag"
9 "reasonix/internal/plugin"
10 )
11
12 func reconcileRemovedMCPAuthentication(name string, roots []string) error {
13 seenRoots := map[string]bool{}
14 var cleanupErrors []error
15 for _, root := range roots {
16 if seenRoots[root] {
17 continue
18 }
19 seenRoots[root] = true
20 remainingResource := ""
21 entry, found, err := desktopEffectiveMCPServer(root, name)
22 if err != nil {
23 cleanupErrors = append(cleanupErrors, fmt.Errorf("reload MCP configuration for %q: %w", name, err))
24 continue
25 }
26 if found {
27 remainingResource = mcpdiag.HTTPMCPOAuthResource(entry.Type, entry.URL, mcpdiag.HasAuthConfig(entry.Headers, entry.Env, entry.URL))
28 }
29 if _, err := plugin.ReconcileHTTPMCPOAuthAfterRemoval(plugin.Spec{
30 Name: name, StateDir: plugin.MCPStateDir(config.ReasonixHomeDir(), root, name),
31 }, remainingResource); err != nil {
32 cleanupErrors = append(cleanupErrors, fmt.Errorf("reconcile OAuth state for %q: %w", name, err))
33 }
34 }
35 return errors.Join(cleanupErrors...)
36 }
37
38 func (a *App) mcpWorkspaceRoots(activeRoot string) []string {
39 roots := []string{activeRoot}
40 a.mu.RLock()
41 for _, tab := range a.runtimeTabsLocked() {
42 if tab != nil && tab.WorkspaceRoot != "" {
43 roots = append(roots, tab.WorkspaceRoot)
44 }
45 }
46 a.mu.RUnlock()
47 return roots
48 }
49
49 lines GO