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

Method RegisterToolDeferred

pkg/tools/mcp/server.go:157–173  ·  view source on GitHub ↗

RegisterToolDeferred 延迟注册单个工具(按需激活时调用)

(toolName string)

Source from the content-addressed store, hash-verified

155
156// RegisterToolDeferred 延迟注册单个工具(按需激活时调用)
157func (s *MCPServer) RegisterToolDeferred(toolName string) error {
158 s.mu.RLock()
159 defer s.mu.RUnlock()
160
161 // 查找对应的 MCP 工具
162 for _, mcpTool := range s.tools {
163 fullName := fmt.Sprintf("%s:%s", s.serverID, mcpTool.Name)
164 if fullName == toolName {
165 // 创建工具工厂并注册
166 factory := ToolFactory(s.client, mcpTool)
167 s.registry.Register(toolName, factory)
168 return nil
169 }
170 }
171
172 return fmt.Errorf("tool not found: %s", toolName)
173}
174
175// IndexToolsToIndex 将工具添加到工具索引(延迟加载模式)
176func (s *MCPServer) IndexToolsToIndex(index *search.ToolIndex) error {

Callers 1

ActivateToolMethod · 0.80

Calls 2

ToolFactoryFunction · 0.70
RegisterMethod · 0.65

Tested by

no test coverage detected