37 lines
863 B
Go
37 lines
863 B
Go
package mcpc
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"nub/internal/config"
|
|
)
|
|
|
|
// SelectServers filtert die konfigurierten MCP-Server nach einem Profil
|
|
// (4.7: `[profiles] review = ["github"]`). Ohne konfigurierte Profile
|
|
// werden alle Server verbunden. Ist profileName leer, wird "default"
|
|
// verwendet, falls definiert.
|
|
func SelectServers(servers []config.MCPServer, profiles map[string][]string, profileName string) ([]config.MCPServer, error) {
|
|
if len(profiles) == 0 {
|
|
return servers, nil
|
|
}
|
|
if profileName == "" {
|
|
profileName = "default"
|
|
}
|
|
names, ok := profiles[profileName]
|
|
if !ok {
|
|
return nil, fmt.Errorf("unknown profile %q", profileName)
|
|
}
|
|
|
|
allow := make(map[string]bool, len(names))
|
|
for _, n := range names {
|
|
allow[n] = true
|
|
}
|
|
|
|
var out []config.MCPServer
|
|
for _, s := range servers {
|
|
if allow[s.Name] {
|
|
out = append(out, s)
|
|
}
|
|
}
|
|
return out, nil
|
|
}
|