MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / ListServers

Function ListServers

internal/mcp/client.go:162–189  ·  view source on GitHub ↗

ListServers returns all servers installed for the client at scope.

(client ClientSpec, scope Scope)

Source from the content-addressed store, hash-verified

160
161// ListServers returns all servers installed for the client at scope.
162func ListServers(client ClientSpec, scope Scope) ([]Server, string, error) {
163 path := client.ResolvePath(scope)
164 if path == "" {
165 return nil, "", fmt.Errorf("mcp: client %s does not support scope %s", client.Name, scope)
166 }
167 data, err := readJSON(path)
168 if err != nil {
169 return nil, path, err
170 }
171 container, _ := data[client.Container].(map[string]any)
172 if container == nil {
173 return nil, path, nil
174 }
175 out := []Server{}
176 keys := make([]string, 0, len(container))
177 for k := range container {
178 keys = append(keys, k)
179 }
180 sort.Strings(keys)
181 for _, k := range keys {
182 entry, ok := container[k].(map[string]any)
183 if !ok {
184 continue
185 }
186 out = append(out, mapToServer(k, entry))
187 }
188 return out, path, nil
189}
190
191func serverToMap(server Server) map[string]any {
192 out := map[string]any{}

Callers 4

ListInstalledMethod · 0.92
installedServerNamesFunction · 0.92
mcpListCommandMethod · 0.92

Calls 3

readJSONFunction · 0.85
mapToServerFunction · 0.85
ResolvePathMethod · 0.80

Tested by 1