Skip to content

Commit a798c18

Browse files
committed
fix: load MCP config from settings.json and support mcpServers key
- Read mcp.config_path from settings.json when --mcp-config not given - Also check global_settings in server lifespan as fallback - Support Claude Desktop format "mcpServers" key in addition to "servers"
1 parent 0c2587b commit a798c18

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

omlx/cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ def serve_command(args):
114114
print(f"Max process memory: {settings.memory.max_process_memory}")
115115

116116
# Store MCP config path for FastAPI startup
117-
if args.mcp_config:
118-
print(f"MCP config: {args.mcp_config}")
119-
os.environ["OMLX_MCP_CONFIG"] = args.mcp_config
117+
# Priority: CLI arg > settings.json
118+
mcp_config = args.mcp_config or settings.mcp.config_path
119+
if mcp_config:
120+
print(f"MCP config: {mcp_config}")
121+
os.environ["OMLX_MCP_CONFIG"] = mcp_config
120122

121123
# Determine paged SSD cache directory
122124
# Priority: --no-cache > CLI arg > settings file

omlx/mcp/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ def validate_config(data: Dict[str, Any]) -> MCPConfig:
114114
raise ValueError("MCP config must be a dictionary")
115115

116116
# Validate servers section
117-
servers_data = data.get("servers", {})
117+
# Support both oMLX ("servers") and Claude Desktop ("mcpServers") format
118+
servers_data = data.get("servers") or data.get("mcpServers", {})
118119
if not isinstance(servers_data, dict):
119120
raise ValueError("'servers' must be a dictionary")
120121

omlx/server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ async def _ttl_check_loop():
323323
ttl_task = asyncio.create_task(_ttl_check_loop())
324324

325325
# Initialize MCP if config provided
326+
# Priority: env var > settings.json
326327
mcp_config = os.environ.get("OMLX_MCP_CONFIG")
328+
if not mcp_config and _server_state.global_settings:
329+
mcp_config = _server_state.global_settings.mcp.config_path
327330
if mcp_config:
328331
await init_mcp(mcp_config)
329332

0 commit comments

Comments
 (0)