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

Method ConnectServerDeferred

pkg/tools/mcp/manager.go:144–164  ·  view source on GitHub ↗

ConnectServerDeferred 连接 MCP Server 但使用延迟加载模式 只发现工具并添加到索引,不立即注册到 Registry

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

Source from the content-addressed store, hash-verified

142// ConnectServerDeferred 连接 MCP Server 但使用延迟加载模式
143// 只发现工具并添加到索引,不立即注册到 Registry
144func (m *MCPManager) ConnectServerDeferred(ctx context.Context, serverID string, index *search.ToolIndex) error {
145 m.mu.RLock()
146 server, exists := m.servers[serverID]
147 m.mu.RUnlock()
148
149 if !exists {
150 return fmt.Errorf("server not found: %s", serverID)
151 }
152
153 // 连接并发现工具
154 if err := server.Connect(ctx); err != nil {
155 return fmt.Errorf("connect to server: %w", err)
156 }
157
158 // 将工具添加到索引(延迟加载模式)
159 if err := server.IndexToolsToIndex(index); err != nil {
160 return fmt.Errorf("index tools: %w", err)
161 }
162
163 return nil
164}
165
166// ConnectAllDeferred 连接所有 MCP Server 使用延迟加载模式
167func (m *MCPManager) ConnectAllDeferred(ctx context.Context, index *search.ToolIndex) error {

Callers 1

ConnectAllDeferredMethod · 0.95

Calls 2

IndexToolsToIndexMethod · 0.80
ConnectMethod · 0.45

Tested by

no test coverage detected