[scan] omit UNSIGNED agent token from MCP server headers (H1)

This commit is contained in:
Renn F
2026-07-06 09:38:09 +02:00
parent dd381a6739
commit 1a16a633f4
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ def _get_agent_headers(agent_id: str) -> dict[str, str]:
if team:
headers["X-Agent-Team"] = team
token = os.environ.get("ROBOCO_AGENT_TOKEN")
if token:
if token and token != "UNSIGNED":
headers["X-Agent-Token"] = token
return headers
@@ -0,0 +1,20 @@
"""Tests for roboco.mcp.utils._get_agent_headers UNSIGNED-token guard."""
from __future__ import annotations
def test_get_agent_headers_omits_unsigned_token(monkeypatch):
from roboco.mcp import utils as mcp_utils
monkeypatch.setenv("ROBOCO_AGENT_TOKEN", "UNSIGNED")
h = mcp_utils._get_agent_headers("be-dev-1")
assert "X-Agent-Token" not in h
assert h["X-Agent-ID"] == "be-dev-1"
def test_get_agent_headers_sends_real_token(monkeypatch):
from roboco.mcp import utils as mcp_utils
monkeypatch.setenv("ROBOCO_AGENT_TOKEN", "signed-token-abc")
h = mcp_utils._get_agent_headers("be-dev-1")
assert h["X-Agent-Token"] == "signed-token-abc"