MCPcopy Create free account
hub / github.com/astercloud/aster / ConnectAllDeferred

Method ConnectAllDeferred

pkg/tools/mcp/manager.go:167–183  ·  view source on GitHub ↗

ConnectAllDeferred 连接所有 MCP Server 使用延迟加载模式

(ctx context.Context, index *search.ToolIndex)

Source from the content-addressed store, hash-verified

165
166// ConnectAllDeferred 连接所有 MCP Server 使用延迟加载模式
167func (m *MCPManager) ConnectAllDeferred(ctx context.Context, index *search.ToolIndex) error {
168 m.mu.RLock()
169 serverIDs := make([]string, 0, len(m.servers))
170 for id := range m.servers {
171 serverIDs = append(serverIDs, id)
172 }
173 m.mu.RUnlock()
174
175 // 连接所有 Server(延迟模式)
176 for _, serverID := range serverIDs {
177 if err := m.ConnectServerDeferred(ctx, serverID, index); err != nil {
178 return fmt.Errorf("connect server %s: %w", serverID, err)
179 }
180 }
181
182 return nil
183}
184
185// ActivateTool 激活延迟加载的 MCP 工具
186func (m *MCPManager) ActivateTool(toolName string) error {

Callers

nothing calls this directly

Calls 1

ConnectServerDeferredMethod · 0.95

Tested by

no test coverage detected