generated from coulomb/repo-seed
Rename MCP server identifier from state-hub to dev-hub
Introduce canonical MCP_SERVER_NAME constants, shared registration helpers, and a migrate_mcp_config.py script for ~/.claude.json upgrades. Registration, patch, and custodian CLI checks accept both dev-hub and legacy state-hub during transition. API root metadata and session-protocol template reflect the new name.
This commit is contained in:
30
scripts/mcp_registration.py
Normal file
30
scripts/mcp_registration.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""Helpers for ~/.claude.json MCP server registration checks."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from mcp_server.constants import LEGACY_MCP_SERVER_NAME, MCP_SERVER_NAME
|
||||
|
||||
|
||||
def load_claude_json(path: Path | None = None) -> dict | None:
|
||||
claude_json = path or Path.home() / ".claude.json"
|
||||
if not claude_json.exists():
|
||||
return None
|
||||
return json.loads(claude_json.read_text())
|
||||
|
||||
|
||||
def mcp_server_registered(config: dict | None) -> bool:
|
||||
if not config:
|
||||
return False
|
||||
servers = config.get("mcpServers", {})
|
||||
return MCP_SERVER_NAME in servers or LEGACY_MCP_SERVER_NAME in servers
|
||||
|
||||
|
||||
def resolve_mcp_server_name(config: dict) -> str | None:
|
||||
servers = config.get("mcpServers", {})
|
||||
if MCP_SERVER_NAME in servers:
|
||||
return MCP_SERVER_NAME
|
||||
if LEGACY_MCP_SERVER_NAME in servers:
|
||||
return LEGACY_MCP_SERVER_NAME
|
||||
return None
|
||||
Reference in New Issue
Block a user