MCPcopy Create free account
hub / github.com/diillson/chatcli / LoadConfig

Method LoadConfig

cli/mcp/manager.go:148–178  ·  view source on GitHub ↗

LoadConfig loads MCP server configurations from a JSON file.

(configPath string)

Source from the content-addressed store, hash-verified

146
147// LoadConfig loads MCP server configurations from a JSON file.
148func (m *Manager) LoadConfig(configPath string) error {
149 data, err := os.ReadFile(configPath) //#nosec G304 -- path supplied by user/agent through validated tool surface (boundary check upstream)
150 if err != nil {
151 if os.IsNotExist(err) {
152 return nil // No config is fine
153 }
154 return fmt.Errorf("reading MCP config: %w", err)
155 }
156
157 var configs struct {
158 Servers []ServerConfig `json:"mcpServers"`
159 }
160 if err := json.Unmarshal(data, &configs); err != nil {
161 return fmt.Errorf("parsing MCP config: %w", err)
162 }
163
164 for _, cfg := range configs.Servers {
165 if cfg.Enabled {
166 m.mu.Lock()
167 m.servers[cfg.Name] = &ServerConnection{
168 Config: cfg,
169 Status: ServerStatus{Name: cfg.Name, Starting: true},
170 logs: newLogRing(mcpLogRingCapacity),
171 }
172 m.mu.Unlock()
173 }
174 }
175
176 m.logger.Info("MCP servers loaded", zap.Int("count", len(m.servers)))
177 return nil
178}
179
180// DefaultConfigPath returns the default MCP config file path.
181func DefaultConfigPath() string {

Implementers 2

MockTokenManagerllm/token/mock_token_manager.go
TokenManagerllm/token/token_manager.go

Calls 5

newLogRingFunction · 0.85
ErrorfMethod · 0.80
LockMethod · 0.80
UnlockMethod · 0.80
InfoMethod · 0.65