Skip to content

Commit 3ff2569

Browse files
authored
Merge pull request #19 from redhat-ai-tools/remote-token-logs
Add remote token logs
2 parents 633a820 + 76b0d19 commit 3ff2569

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/tools.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ def get_snowflake_token(mcp: FastMCP) -> Optional[str]:
2323
# Get token from request headers for non-stdio transports
2424
context = mcp.get_context()
2525
if context and hasattr(context, 'request_context') and context.request_context:
26-
headers = context.request_context.request.headers
27-
return headers.get("X-Snowflake-Token")
26+
token = context.request_context.request.headers["X-Snowflake-Token"]
27+
if token:
28+
logger.info("Successfully retrieved Snowflake token from X-Snowflake-Token header")
29+
return token
30+
else:
31+
logger.warning("X-Snowflake-Token header is present but empty")
32+
else:
33+
logger.error("Request context not available for non-stdio transport")
34+
except KeyError:
35+
logger.error("X-Snowflake-Token header not found in request headers")
2836
except Exception as e:
2937
logger.error(f"Error getting token from request context: {e}")
3038
return None

0 commit comments

Comments
 (0)