getToolContext 获取工具上下文
()
| 214 | |
| 215 | // getToolContext 获取工具上下文 |
| 216 | func (s *HTTPBridgeServer) getToolContext() *tools.ToolContext { |
| 217 | s.mu.RLock() |
| 218 | factory := s.contextFactory |
| 219 | s.mu.RUnlock() |
| 220 | |
| 221 | if factory != nil { |
| 222 | return factory() |
| 223 | } |
| 224 | |
| 225 | // 默认返回空上下文 |
| 226 | return &tools.ToolContext{ |
| 227 | Services: make(map[string]any), |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | // sendJSON 发送 JSON 响应 |
| 232 | func (s *HTTPBridgeServer) sendJSON(w http.ResponseWriter, data any) { |