fix(catalog): wire api_key auth headers for http MCP servers
When an optional-mcps manifest declares transport.type=http with
auth.type=api_key, install_entry() prompts for the key and saves it to
.env, but _build_server_config() only handled the oauth case — the
api_key case produced a bare url entry with no headers, so every
request to the server was unauthenticated (-> 401).
Reuse _bearer_auth_headers(entry.name) from mcp_config.py so the
catalog path emits the same 'Authorization: Bearer ${MCP_..._API_KEY}'
template as the manual 'hermes mcp add --url' path.
Salvaged from #70782 (production hunk applied clean; tests re-anchored
onto current main). Credit: JonthanaHanh.
This commit is contained in:
@@ -506,6 +506,10 @@ def _build_server_config(
|
||||
cfg["url"] = t.url
|
||||
if entry.auth.type == "oauth":
|
||||
cfg["auth"] = "oauth"
|
||||
elif entry.auth.type == "api_key":
|
||||
from hermes_cli.mcp_config import _bearer_auth_headers
|
||||
|
||||
cfg["headers"] = _bearer_auth_headers(entry.name)
|
||||
return cfg
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user