File tree Expand file tree Collapse file tree
daiv/automation/tools/mcp
tests/automation/tools/mcp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,9 +32,13 @@ def get_connection(self) -> SSEConnection:
3232 Returns:
3333 SSEConnection: The SSE connection to the MCP proxy.
3434 """
35- return SSEConnection (
36- transport = "sse" , url = build_uri (settings .MCP_PROXY_HOST .encoded_string (), f"{ self .name } /sse" )
37- )
35+ url = build_uri (settings .MCP_PROXY_HOST .encoded_string (), f"{ self .name } /sse" )
36+ headers = None
37+ if settings .MCP_PROXY_AUTH_TOKEN :
38+ token = settings .MCP_PROXY_AUTH_TOKEN .get_secret_value ()
39+ headers = {"Authorization" : f"Bearer { token } " }
40+
41+ return SSEConnection (transport = "sse" , url = url , headers = headers )
3842
3943 def get_proxy_config (self ) -> StdioMcpServer | SseMcpServer | StreamableHttpMcpServer :
4044 """
Original file line number Diff line number Diff line change @@ -58,13 +58,27 @@ def test_is_enabled_can_be_overridden(self):
5858 def test_get_connection_returns_sse_connection (self , mock_settings ):
5959 """Test that get_connection returns a properly configured SSEConnection."""
6060 mock_settings .MCP_PROXY_HOST .encoded_string .return_value = "http://test-host:9090"
61+ mock_settings .MCP_PROXY_AUTH_TOKEN = None
6162
6263 server = ConcreteMCPServer ()
6364 connection = server .get_connection ()
6465
6566 assert connection ["transport" ] == "sse"
6667 assert "concrete_server/sse" in connection ["url" ]
6768
69+ @patch ("automation.tools.mcp.base.settings" )
70+ def test_get_connection_includes_auth_header_when_token_set (self , mock_settings ):
71+ """Test that get_connection includes Authorization header when MCP_PROXY_AUTH_TOKEN is set."""
72+ mock_settings .MCP_PROXY_HOST .encoded_string .return_value = "http://test-host:9090"
73+ mock_settings .MCP_PROXY_AUTH_TOKEN .get_secret_value .return_value = "secret-token"
74+
75+ server = ConcreteMCPServer ()
76+ connection = server .get_connection ()
77+
78+ assert connection ["transport" ] == "sse"
79+ assert "concrete_server/sse" in connection ["url" ]
80+ assert connection ["headers" ] == {"Authorization" : "Bearer secret-token" }
81+
6882 def test_get_proxy_config_returns_configured_proxy (self ):
6983 """Test that get_proxy_config returns the configured proxy configuration."""
7084 server = ConcreteMCPServer ()
You can’t perform that action at this time.
0 commit comments