Tools returns the current MCP tool cache after startup-safe config synchronization. Before startup has settled via MarkStartupSettled, Tools blocks until settlement or ctx cancels. After settlement, it drives a config reload bounded by toolsReloadTimeout. On error before the first sync settles, To
(ctx context.Context, paths []string)
| 200 | // the error. On error after a prior sync, it returns cached tools and |
| 201 | // the error so callers can degrade gracefully. |
| 202 | func (m *Manager) Tools(ctx context.Context, paths []string) ([]workspacesdk.MCPToolInfo, error) { |
| 203 | if err := m.waitForStartupSettled(ctx); err != nil { |
| 204 | return nil, err |
| 205 | } |
| 206 | |
| 207 | ch, started, err := m.startReloadIfNeeded(paths) |
| 208 | if err != nil { |
| 209 | return m.toolsAfterReloadError(err) |
| 210 | } |
| 211 | if !started { |
| 212 | return normalizeTools(m.cachedTools()), nil |
| 213 | } |
| 214 | |
| 215 | if err := m.waitReload(ctx, ch, toolsReloadTimeout); err != nil { |
| 216 | return m.toolsAfterReloadError(err) |
| 217 | } |
| 218 | return normalizeTools(m.cachedTools()), nil |
| 219 | } |
| 220 | |
| 221 | func (m *Manager) waitForStartupSettled(ctx context.Context) error { |
| 222 | select { |