{"record":{"id":"ad68ec4dfafe8708","repo":"ruvnet/ruflo","slug":"wg-mesh-layer-not-initialized-set-config-wgmesh","errorCode":null,"errorMessage":"WG mesh layer not initialized (set config.wgMesh = true and inject WgMeshService)","messagePattern":"WG mesh layer not initialized \\(set config\\.wgMesh = true and inject WgMeshService\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugin-agent-federation/src/mcp-tools.ts","lineNumber":31,"sourceCode":"type WgMeshGetter = () => WgMeshService | 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  getWgMesh: WgMeshGetter = () => null,\n): MCPToolDefinition[] {\n  function requireCoordinator(): FederationCoordinator {\n    const c = getCoordinator();\n    if (!c) throw new Error('Federation not initialized');\n    return c;\n  }\n  function requireWgMesh(): WgMeshService {\n    const w = getWgMesh();\n    if (!w) throw new Error('WG mesh layer not initialized (set config.wgMesh = true and inject WgMeshService)');\n    return w;\n  }\n\n  return [\n    {\n      name: 'federation_init',\n      description: 'Initialize federation on this node with a manifest and begin discovery',\n      pluginName: '@claude-flow/plugin-agent-federation',\n      version: FEDERATION_PLUGIN_VERSION,\n      inputSchema: {\n        type: 'object',\n        properties: {\n          nodeId: { type: 'string', description: 'Unique node identifier' },\n          endpoint: { type: 'string', description: 'WebSocket or HTTP endpoint for this node' },\n          agentTypes: { type: 'array', description: 'Supported agent types', items: { type: 'string' } },\n        },\n        required: ['endpoint'],\n      },","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugin-agent-federation/src/mcp-tools.ts#L13-L49","documentation":"The WireGuard-mesh guard in the federation MCP tools: requireWgMesh() throws when the WgMeshService getter returns null, meaning the host neither enabled config.wgMesh nor injected a WgMeshService. The message embeds the exact remedy; it fires only for WG-mesh-specific tools while the base federation layer works without it.","triggerScenarios":"Calling WG-mesh federation MCP tools when the plugin config lacks wgMesh: true, or when the host wiring never passed a WgMeshService into createMcpTools (the getWgMesh parameter defaults to () => null).","commonSituations":"Running with default config (WG mesh is opt-in); upgrading to a version where the WG mesh became a separately injected service; custom plugin hosts that only wire the base coordinator.","solutions":["Set config.wgMesh = true in the agent-federation plugin config","Inject a real WgMeshService instance so the mesh getter resolves it instead of the default null getter","Restart or reload the plugin so the MCP tools are created with the wired getter"],"exampleFix":"// before\nconst config = { nodeId: 'node-a' }; // wgMesh not set -> requireWgMesh() throws\n\n// after\nconst config = { nodeId: 'node-a', wgMesh: true };\n// and inject the WgMeshService when wiring the plugin host","handlingStrategy":"validation","validationCode":"const wgReady = pluginConfig['wgMesh'] === true && !!wgMeshService;\nif (!wgReady) {\n  throw new Error('WG mesh not configured: set config.wgMesh = true and inject WgMeshService before calling WG mesh tools');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await client.callTool('federation_wg_status', {});\n} catch (e) {\n  if (e instanceof Error && e.message.includes('WG mesh layer not initialized')) {\n    // fix config + DI, reload the plugin, then retry; do not loop\n  } else throw e;\n}","preventionTips":["Declare wgMesh: true in config for every node using WG topology","Keep the wgMesh flag and the WgMeshService injection in the same wiring commit so they never diverge","Smoke-test one WG mesh tool immediately after startup"],"tags":["wireguard","mesh-network","configuration","mcp","federation"],"backgroundTag":"missing-configuration","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}