Skip to content

Fix duplicate server entries from hyphenated serverName in mcp-config.json#67

Draft
aditya-scio wants to merge 1 commit into
mainfrom
fix/normalize-server-name-hyphens
Draft

Fix duplicate server entries from hyphenated serverName in mcp-config.json#67
aditya-scio wants to merge 1 commit into
mainfrom
fix/normalize-server-name-hyphens

Conversation

@aditya-scio
Copy link
Copy Markdown

Description

Fixes the issue reported by Neil Dhruva in #discuss-ai-code where glean_default and glean_glean-default both appear in claude_desktop_config.json and fail to auth.

Root cause: A bad merge introduced entries with serverName: "glean-default" (hyphen) into mcp-config.json. The buildGleanServerName function in @gleanwork/mcp-config-glean only recognizes the "glean_" (underscore) prefix, so "glean-default" was transformed into "glean_glean-default" in host configs. The dedup logic also failed to match the two variants since it used exact string comparison.

Fix: Normalize hyphens to underscores in serverName at two levels:

  • Added a Zod .transform() on McpServerEntrySchema so all parsed entries from mcp-config.json are normalized automatically — this fixes both the host config naming and dedup comparisons
  • Normalize incoming serverName in writeConfig before writing to mcp-config.json

Testing

  • Added test: hyphens in serverName are normalized to underscores when writing
  • Added test: hyphenated serverName is deduplicated against existing underscored entry
  • Added test: existing hyphenated entry in mcp-config.json is recognized as duplicate
  • All 150 existing tests pass

🤖 Generated by Glean Code Writer
📝 Chat link - https://app.glean.com/chat/be05961f64114be29dd0c0fe59218745

…onfig.json

A bad merge introduced entries with "glean-default" (hyphen) into
mcp-config.json. The buildGleanServerName function only recognizes the
"glean_" (underscore) prefix, so "glean-default" was transformed into
"glean_glean-default" in host configs like claude_desktop_config.json.
The dedup logic also failed to match "glean-default" against "glean_default"
since it used exact string comparison.

Fix by normalizing hyphens to underscores in serverName:
- Add a Zod transform on McpServerEntrySchema so all parsed entries are
  normalized automatically (affects both readMcpConfig and writeConfig)
- Normalize incoming serverName in writeConfig before writing

Generated by Glean Code Writer
@aditya-scio aditya-scio added the glean-code-writer Modified by Glean Code Writer label Apr 11, 2026 — with glean-github-app-oauth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

glean-code-writer Modified by Glean Code Writer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants