{"record":{"id":"aacc7f63fa4ecee5","repo":"affaan-m/ECC","slug":"ecc-memory-harness-must-identify-this-mcp-server-w","errorCode":null,"errorMessage":"ECC_MEMORY_HARNESS must identify this MCP server with a lowercase harness slug.","messagePattern":"ECC_MEMORY_HARNESS must identify this MCP server with a lowercase harness slug\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/memory-mcp.mjs","lineNumber":178,"sourceCode":"  }\n}\n\nfunction isRecord(value) {\n  return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction isValidRequestId(value) {\n  return (\n    (typeof value === 'string' && value.length > 0 && value.length <= 128)\n    || (typeof value === 'number' && Number.isSafeInteger(value))\n  );\n}\n\nfunction resolveServiceSecurity(options = {}) {\n  const env = isRecord(options.env) ? options.env : process.env;\n  const harness = options.harness ?? env.ECC_MEMORY_HARNESS;\n  if (typeof harness !== 'string' || !SLUG_REGEXP.test(harness)) {\n    throw new Error(\n      'ECC_MEMORY_HARNESS must identify this MCP server with a lowercase harness slug.'\n    );\n  }\n  return Object.freeze({\n    harness,\n    allowUserScope: options.allowUserScope ?? env.ECC_MEMORY_ALLOW_USER_SCOPE === '1',\n  });\n}\n\nfunction assertScopesAuthorized(scopes, security) {\n  const requestedScopes = scopes || DEFAULT_RECALL_SCOPES;\n  if (!security.allowUserScope && requestedScopes.includes('user')) {\n    throw new JsonRpcError(\n      -32602,\n      'The user memory scope is disabled for this MCP server.'\n    );\n  }\n  return requestedScopes;","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/memory-mcp.mjs#L160-L196","documentation":"The memory MCP server must know which harness (Claude Code, Codex, Cursor, etc.) is connecting, both for scoping and diagnostics. resolveServiceSecurity reads ECC_MEMORY_HARNESS and requires it to be a string matching SLUG_REGEXP (lowercase slug). Otherwise it throws at startup/tool resolution time.","triggerScenarios":"resolveServiceSecurity() is called with neither options.harness nor a valid env.ECC_MEMORY_HARNESS — the variable is unset, empty, contains uppercase/invalid characters, or fails the slug regex.","commonSituations":"Running the MCP server directly without the harness wrapper that sets ECC_MEMORY_HARNESS; value set as 'Claude-Code' (uppercase) instead of 'claude-code'; mcp config missing the env block.","solutions":["Set ECC_MEMORY_HARNESS to a lowercase slug like 'claude-code' in the MCP server env config","If launching programmatically, pass { harness: 'claude-code' } in options instead","Check for typos/whitespace/uppercase in the configured value"],"exampleFix":"// before\n\"env\": {}\n// after\n\"env\": { \"ECC_MEMORY_HARNESS\": \"claude-code\" }","handlingStrategy":"validation","validationCode":"const v = process.env.ECC_MEMORY_HARNESS; if (typeof v !== 'string' || !/^[a-z0-9-]+$/.test(v)) throw new Error('ECC_MEMORY_HARNESS must be a lowercase slug like claude-code');","typeGuard":"const isValidHarnessSlug = (v) => typeof v === 'string' && /^[a-z][a-z0-9-]*$/.test(v);","tryCatchPattern":"try { const security = resolveServiceSecurity(); /* ... */ } catch (e) { if (/ECC_MEMORY_HARNESS/.test(e.message)) { console.error('Set ECC_MEMORY_HARNESS (e.g. claude-code) in the MCP server env'); process.exit(1); } throw e; }","preventionTips":["Set ECC_MEMORY_HARNESS in the mcpServers env block for every harness install","Keep the value lowercase-hyphenated; avoid spaces and uppercase","When launching programmatically, pass options.harness explicitly instead of relying on env"],"tags":["mcp","configuration","env"],"backgroundTag":"invalid-env-var-value","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}