BrianIsaac commited on
Commit
61b860f
·
1 Parent(s): 62c549e

fix: use centralized settings instead of direct os.getenv for FINNHUB_API_KEY

Browse files

- Remove direct os.getenv() call from news_sentiment_mcp.py
- Use backend.config.settings.finnhub_api_key for consistency
- Ensures API key is properly loaded from environment in both local and container environments

backend/mcp_servers/news_sentiment_mcp.py CHANGED
@@ -17,6 +17,8 @@ from datetime import datetime, timedelta
17
  import httpx
18
  import logging
19
 
 
 
20
  logger = logging.getLogger(__name__)
21
 
22
  mcp = FastMCP("news-sentiment")
@@ -98,9 +100,8 @@ async def get_news_with_sentiment(
98
  )
99
 
100
  try:
101
- # Get Finnhub API key from environment
102
- import os
103
- finnhub_api_key = os.getenv("FINNHUB_API_KEY")
104
 
105
  if not finnhub_api_key:
106
  logger.warning("FINNHUB_API_KEY not set, returning empty sentiment")
 
17
  import httpx
18
  import logging
19
 
20
+ from backend.config import settings
21
+
22
  logger = logging.getLogger(__name__)
23
 
24
  mcp = FastMCP("news-sentiment")
 
100
  )
101
 
102
  try:
103
+ # Get Finnhub API key from centralized settings
104
+ finnhub_api_key = settings.finnhub_api_key
 
105
 
106
  if not finnhub_api_key:
107
  logger.warning("FINNHUB_API_KEY not set, returning empty sentiment")