返回 DeepSeek-Reasonix
mcp_list.go
根目录 / internal / cli / mcp_list.go
1 package cli
2
3 import (
4 "fmt"
5 "os"
6 "strings"
7
8 "reasonix/internal/boot"
9 "reasonix/internal/config"
10 )
11
12 func mcpList() int {
13 workspace := mcpCLIWorkspaceRoot()
14 cfg, err := config.LoadForRoot(workspace)
15 if err != nil {
16 fmt.Fprintln(os.Stderr, err)
17 return 1
18 }
19 listed, pending := 0, false
20 for _, p := range cfg.Plugins {
21 typ := p.Type
22 if typ == "" {
23 typ = "stdio"
24 }
25 decision := config.MCPServerDecision(p, workspace)
26 pending = pending || decision.AwaitsUser()
27 auto := " [" + decision.Code() + "]"
28 fmt.Printf("%-16s (%s)%s %s\n", p.Name, typ, auto, config.MCPLaunchLine(p))
29 listed++
30 }
31 if listed == 0 {
32 fmt.Println("no MCP servers configured")
33 }
34 if pending {
35 fmt.Println("project-declared servers stay off until you review them (`reasonix mcp get <name>`) and run `reasonix mcp enable <name>`")
36 }
37 return 0
38 }
39
40 // mcpCLIWorkspaceRoot is the workspace a session started here would use, so a
41 // decision recorded from the command line reaches that session.
42 func mcpCLIWorkspaceRoot() string {
43 if root := boot.ResolveWorkspaceRoot(""); strings.TrimSpace(root) != "" {
44 return root
45 }
46 return "."
47 }
48
48 lines GO