registerDependencies method
Registers this plugin's dependencies into the shared di
container.
Called during the engine's bootstrap phase, before any onInit calls. Only registration methods should be invoked here; do not call ZuraffaDIContainer.get because other plugins' dependencies may not yet be registered.
Implementation
@override
void registerDependencies(ZuraffaDIContainer di) {
final registry = McpToolRegistry();
for (final tool in tools) {
registry.register(tool);
}
// The runtime ZuraffaPlugin contract is sync (void), so we
// bypass the async override path in ZuraffaDIContainer.registerSingleton
// and manipulate GetIt directly. In production the type is never
// registered yet; in tests with a shared GetIt.instance the prior
// registration is removed synchronously before re-registering.
final getIt = di.getIt;
if (getIt.isRegistered<McpToolRegistry>()) {
// unregister's side effect is synchronous; the returned Future
// is for onDispose callbacks we don't use.
getIt.unregister<McpToolRegistry>();
}
getIt.registerSingleton<McpToolRegistry>(registry);
}