Skip to content

Commit 8d53a2e

Browse files
committed
fix: Disable magic MCP server for Gemini CLI compatibility
The @21st-dev/magic package exports tool names starting with '21st_' (e.g., 21st_magic_component_builder) which violates Gemini's function naming rules that require names to start with a letter or underscore. Changes: - Add gemini_compatible flag to MCP server definitions - Install incompatible servers to _disabledMcpServers with warning - Add compatibility warning to MCP_Magic.md documentation - Add _geminiCompatibility note to magic.json config The magic server will be automatically installed as DISABLED until the upstream package is updated with compliant tool names.
1 parent d194233 commit 8d53a2e

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-13
lines changed

SuperGemini/MCP/MCP_Magic.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
**Purpose**: Modern UI component generation from 21st.dev patterns with design system integration
44

5+
## Gemini CLI Compatibility Warning
6+
7+
**Status**: NOT COMPATIBLE with Gemini CLI (as of December 2025)
8+
9+
**Issue**: The `@21st-dev/magic` package exports tool names that start with `21st_` (e.g., `21st_magic_component_builder`). Gemini's API requires function names to start with a letter or underscore, not a number.
10+
11+
**Error**: `[FIELD_INVALID] Invalid function name. Must start with a letter or an underscore.`
12+
13+
**Workaround**: SuperGemini automatically installs this server as DISABLED. You can enable it once the `@21st-dev/magic` package is updated to use compliant tool names.
14+
15+
**Tracking**: This issue affects Gemini CLI only. The magic server works fine with Claude Code and other MCP clients.
16+
517
## Triggers
618
- UI component requests: button, form, modal, card, table, nav
719
- Design system implementation needs

SuperGemini/MCP/configs/magic.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
],
88
"env": {
99
"TWENTYFIRST_API_KEY": ""
10-
}
10+
},
11+
"_geminiCompatibility": "NOT_COMPATIBLE - Tool names start with '21st_' which violates Gemini function naming rules"
1112
}
1213
}

setup/components/mcp.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def __init__(self, install_dir: Optional[Path] = None):
5555
"config_file": "magic.json",
5656
"npm_package": "@21st-dev/magic",
5757
"requires_api_key": True,
58-
"api_key_env": "TWENTYFIRST_API_KEY"
58+
"api_key_env": "TWENTYFIRST_API_KEY",
59+
"gemini_compatible": False,
60+
"incompatibility_reason": "Tool names start with '21st_' which violates Gemini's function naming rules (must start with letter/underscore, not number)"
5961
},
6062
"playwright": {
6163
"name": "playwright",
@@ -727,21 +729,40 @@ def _install(self, config: Dict[str, Any]) -> bool:
727729
display_info(f"Server '{server_key}' requires API key: {api_key_env}")
728730
display_info("You can set this environment variable later")
729731

730-
# Always enable newly managed servers by default
731-
target_section = "mcpServers"
732+
# Check Gemini compatibility - install incompatible servers as disabled
733+
is_gemini_compatible = server_info.get("gemini_compatible", True)
732734

733-
# If the server was previously disabled, remove the stale entry
734-
if server_key in gemini_config.get("_disabledMcpServers", {}):
735-
try:
736-
del gemini_config["_disabledMcpServers"][server_key]
737-
except KeyError:
738-
pass
735+
if is_gemini_compatible:
736+
# Enable compatible servers by default
737+
target_section = "mcpServers"
738+
739+
# If the server was previously disabled, remove the stale entry
740+
if server_key in gemini_config.get("_disabledMcpServers", {}):
741+
try:
742+
del gemini_config["_disabledMcpServers"][server_key]
743+
except KeyError:
744+
pass
745+
746+
self.logger.debug(f"Server '{server_key}' installed as enabled")
747+
else:
748+
# Install incompatible servers as disabled with explanation
749+
target_section = "_disabledMcpServers"
750+
incompatibility_reason = server_info.get("incompatibility_reason", "Not compatible with Gemini CLI")
739751

740-
# Merge server config into active section
752+
# Add disabled reason to the config
753+
for server_name in server_config:
754+
server_config[server_name]["_disabledReason"] = incompatibility_reason
755+
756+
# Warn user about incompatibility
757+
display_warning(f"Server '{server_key}' is NOT compatible with Gemini CLI!")
758+
display_warning(f"Reason: {incompatibility_reason}")
759+
display_info(f"Installing '{server_key}' as DISABLED. You can enable it when the package is updated.")
760+
761+
self.logger.warning(f"Server '{server_key}' installed as DISABLED due to Gemini incompatibility")
762+
763+
# Merge server config into appropriate section
741764
self._merge_mcp_server_config(gemini_config[target_section], server_config, server_key)
742765
configured_count += 1
743-
744-
self.logger.debug(f"Server '{server_key}' installed as enabled")
745766

746767
# Save updated configuration
747768
if configured_count > 0:

0 commit comments

Comments
 (0)