What's Fixed
Critical regression from v10.36.3: Get-McpApiKey in scripts/service/windows/lib/server-config.ps1 returned the first character of the API key ('b') instead of the full key (bxvWZwrI...), breaking manage_service.ps1 status Version and Backend display for all Windows users.
Root Cause
The v10.36.3 refactor (Gemini review suggestion, PR #685) replaced a working implementation with:
$apiKey = ($matches[1], $matches[2], $matches[3] | Where-Object { $_ -ne $null })[0]PowerShell's $matches hashtable omits unmatched capture groups (they are absent, not $null). When only capture group 3 matched (the common unquoted MCP_API_KEY=value case), the comma expression produced a single-element string in the pipeline. Where-Object passed it through unchanged, but PowerShell's array-enumeration behavior then caused [0] to index the string's Char array — returning 'b' instead of the full key.
The Fix
if ($matches.ContainsKey(1) -and -not [string]::IsNullOrEmpty($matches[1])) {
$apiKey = [string]$matches[1]
} elseif ($matches.ContainsKey(2) -and -not [string]::IsNullOrEmpty($matches[2])) {
$apiKey = [string]$matches[2]
} elseif ($matches.ContainsKey(3) -and -not [string]::IsNullOrEmpty($matches[3])) {
$apiKey = [string]$matches[3]
}Explicit $matches.ContainsKey(N) checks with [string] casts eliminate both the null-check trap and the enumeration issue.
Verification
Tested live on a real .env file:
- Before:
Get-McpApiKeyreturnsChar, value: 'b' - After:
Get-McpApiKeyreturnsString, length: 43, preview: bxvWZwrI... manage_service.ps1 statuscorrectly displaysVersion: 10.36.4, Backend: sqlite-vec
Impact
All Windows users running v10.36.3 will have seen (unavailable - set MCP_API_KEY in .env for details) in manage_service.ps1 status even with a correctly configured .env. This is purely a display regression — the API key itself was stored and used correctly by the server.
Lesson Learned
Gemini-suggested refactors that touch PowerShell regex/$matches logic must be live-tested against a real .env file before accepting. The v10.36.3 refactor looked idiomatic but was not verified against actual PowerShell behavior.
Changes
scripts/service/windows/lib/server-config.ps1- FixGet-McpApiKeywith explicitif/elseifchain- Version bump: 10.36.3 -> 10.36.4
Full changelog: https://github.com/doobidoo/mcp-memory-service/blob/main/CHANGELOG.md#10364---2026-04-10