* 加载服务器工具
(sessionId: string)
| 214 | * 加载服务器工具 |
| 215 | */ |
| 216 | async loadServerTools(sessionId: string): Promise<void> { |
| 217 | if (!this.client) return; |
| 218 | |
| 219 | try { |
| 220 | const tools = await this.client.listTools(sessionId); |
| 221 | const session = this.getSessionById(sessionId); |
| 222 | |
| 223 | if (session) { |
| 224 | const toolsWithServer = tools.map(tool => ({ |
| 225 | ...tool, |
| 226 | serverId: sessionId, |
| 227 | serverName: session.config.name, |
| 228 | })); |
| 229 | |
| 230 | this.tools.set(sessionId, toolsWithServer); |
| 231 | this.log(`加载了 ${tools.length} 个工具从 ${session.config.name}`); |
| 232 | } |
| 233 | } catch (error) { |
| 234 | this.log(`加载服务器工具失败: ${error}`); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * 获取所有可用资源 |
no test coverage detected