Skip to content

Commit 99f8a5b

Browse files
committed
format and simplify auth type
Signed-off-by: Anxhela Coba <acoba@redhat.com>
1 parent f9ba4f2 commit 99f8a5b

3 files changed

Lines changed: 9 additions & 40 deletions

File tree

config/system.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ api:
4141
# API input configuration
4242
provider: "openai" # LLM provider for queries
4343
model: "gpt-4o-mini" # Model to use for queries
44-
no_tools: null # Whether to bypass tools and MCP servers (optional)
44+
no_tools: false # Whether to bypass tools and MCP servers (optional)
4545
system_prompt: null # System prompt (default None)
4646

4747
cache_dir: ".caches/api_cache" # Directory with lightspeed-stack cache
@@ -52,7 +52,7 @@ api:
5252
enabled: true # Enable MCP headers functionality
5353
servers: # MCP server configurations
5454
filesystem-tools:
55-
auth_type: bearer # Authentication type: bearer, api_key, custom
55+
auth_type: bearer # Authentication type: only bearer is supported
5656
env_var: API_KEY # Environment variable containing the token/key
5757

5858
# Legacy authentication (fallback when mcp_headers.enabled is false)

src/lightspeed_evaluation/core/api/client.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -127,30 +127,9 @@ def _build_mcp_headers(self) -> dict[str, dict[str, str]]:
127127
)
128128
continue
129129

130-
# Determine header name and value based on auth_type
131-
if server_config.auth_type == "bearer":
132-
header_name = server_config.header_name or "Authorization"
133-
header_value = f"Bearer {token}"
134-
elif server_config.auth_type == "api_key":
135-
header_name = server_config.header_name or "X-API-Key"
136-
header_value = token
137-
elif server_config.auth_type == "custom":
138-
if not server_config.header_name:
139-
logger.warning(
140-
"Custom auth_type for server '%s' requires "
141-
"header_name to be specified. Skipping.",
142-
server_name,
143-
)
144-
continue
145-
header_name = server_config.header_name
146-
header_value = token
147-
else:
148-
logger.warning(
149-
"Unknown auth_type '%s' for server '%s'. Skipping.",
150-
server_config.auth_type,
151-
server_name,
152-
)
153-
continue
130+
# Set up bearer auth headers
131+
header_name = server_config.header_name or "Authorization"
132+
header_value = f"Bearer {token}"
154133

155134
mcp_headers[server_name] = {header_name: header_value}
156135

src/lightspeed_evaluation/core/models/system.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ class MCPServerConfig(BaseModel):
166166
model_config = ConfigDict(extra="forbid")
167167

168168
auth_type: str = Field(
169-
...,
170-
description="Authentication type: bearer, api_key",
169+
default="bearer",
170+
description="Authentication type: only bearer is supported",
171171
)
172172
env_var: str = Field(
173173
...,
@@ -183,20 +183,10 @@ class MCPServerConfig(BaseModel):
183183
@classmethod
184184
def validate_auth_type(cls, v: str) -> str:
185185
"""Validate auth_type is supported."""
186-
allowed = {"bearer", "api_key", "custom"}
187-
if v not in allowed:
188-
raise ValueError(f"auth_type must be one of {allowed}")
186+
if v != "bearer":
187+
raise ValueError("auth_type must be 'bearer'")
189188
return v
190189

191-
@model_validator(mode="after")
192-
def validate_custom_header_name(self) -> "MCPServerConfig":
193-
"""Validate custom auth has an explicit header name."""
194-
if self.auth_type == "custom" and not self.header_name:
195-
raise ConfigurationError(
196-
"For auth_type='custom', 'header_name' must be provided."
197-
)
198-
return self
199-
200190

201191
class MCPHeadersConfig(BaseModel):
202192
"""Configuration for MCP headers functionality."""

0 commit comments

Comments
 (0)