{"record":{"id":"0101505b108fd64c","repo":"ruvnet/ruflo","slug":"iot-cognitum-not-initialized","errorCode":null,"errorMessage":"IoT Cognitum not initialized","messagePattern":"IoT Cognitum not initialized","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugin-iot-cognitum/src/mcp-tools.ts","lineNumber":18,"sourceCode":"import type { MCPToolDefinition } from '@claude-flow/shared/src/plugin-interface.js';\nimport type { PluginContext } from '@claude-flow/shared/src/plugin-interface.js';\nimport type { IoTCoordinator } from './application/iot-coordinator.js';\n\ntype CoordinatorGetter = () => IoTCoordinator | null;\ntype ContextGetter = () => PluginContext | null;\n\nfunction textResult(text: string, isError = false) {\n  return { content: [{ type: 'text' as const, text }], isError };\n}\n\nexport function createMcpTools(\n  getCoordinator: CoordinatorGetter,\n  _getContext: ContextGetter,\n): MCPToolDefinition[] {\n  function requireCoordinator(): IoTCoordinator {\n    const c = getCoordinator();\n    if (!c) throw new Error('IoT Cognitum not initialized');\n    return c;\n  }\n\n  return [\n    // -- Device lifecycle ----------------------------------------------------\n    {\n      name: 'iot_device_register',\n      description: 'Register a Cognitum Seed device by endpoint',\n      pluginName: '@claude-flow/plugin-iot-cognitum',\n      version: '1.0.0-alpha.1',\n      inputSchema: {\n        type: 'object',\n        properties: {\n          endpoint: { type: 'string', description: 'Device HTTP endpoint (e.g. http://169.254.42.1)' },\n          pairingToken: { type: 'string', description: 'Optional pairing token for mutual auth' },\n        },\n        required: ['endpoint'],\n      },","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugin-iot-cognitum/src/mcp-tools.ts#L1-L36","documentation":"MCP twin of the CLI guard: every iot_* MCP tool obtains its IoTCoordinator via requireCoordinator(), which throws when the plugin's coordinator is null — the IoT Cognitum plugin has not completed initialization/registration in this host. It fires before any tool logic runs.","triggerScenarios":"An MCP client (agent or test harness) invoking iot_device_register or any other iot_* tool before the plugin's init/registration flow ran, or after it failed, leaving getCoordinator() null.","commonSituations":"LLM agents discovering the tools and calling them out of order; plugin init failed at host startup (bad config, unreachable endpoint) so the coordinator was never set; tools invoked while async initialization is still in flight.","solutions":["Complete the plugin's initialization/registration flow (the iot register path) before invoking iot_* tools","Inspect host and plugin startup logs for a failed IoTCoordinator construction and fix it","Retry the tool call after initialization succeeds"],"exampleFix":"// before\nawait client.callTool('iot_device_register', { endpoint }); // throws 'IoT Cognitum not initialized'\n\n// after\nawait client.callTool('iot_init', {}); // plugin bootstrap\nawait runIotRegister(); // registration flow completes coordinator setup\nawait client.callTool('iot_device_register', { endpoint });","handlingStrategy":"validation","validationCode":"const ready = await pluginHost.waitForReady('@claude-flow/plugin-iot-cognitum');\nif (!ready) {\n  throw new Error('IoT plugin not ready; blocking iot_* tool calls');\n}\nawait client.callTool('iot_device_register', { endpoint });","typeGuard":null,"tryCatchPattern":"try {\n  await client.callTool('iot_device_register', { endpoint });\n} catch (e) {\n  if (e instanceof Error && e.message === 'IoT Cognitum not initialized') {\n    await bootstrapIotPlugin(); // init + register, then retry once\n    await client.callTool('iot_device_register', { endpoint });\n  } else throw e;\n}","preventionTips":["Expose iot_* tools to agents only after the plugin reports readiness","In agent workflows, run setup/init tools before operational tools","Health-check the plugin before serving its tools"],"tags":["iot","mcp","initialization","claude-flow"],"backgroundTag":"service-not-initialized","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}