Skip to main content
Glama

Agentic AI System with MCP Integration

news_sentiment.py1.19 kB
import os import requests ALPHA_VANTAGE_KEY = os.environ.get("ALPHA_VANTAGE_KEY") BASE_URL = "https://www.alphavantage.co/query?" if not ALPHA_VANTAGE_KEY: raise EnvironmentError( "Please set the ALPHA_VANTAGE_KEY environment variable." ) def get_news_sentiment(tickers=None, topics=None, time_from=None, time_to=None, sort='latest'): """Fetches news sentiment data.""" params = { 'function': 'NEWS_SENTIMENT', 'sort': sort, 'apikey': ALPHA_VANTAGE_KEY } if tickers: params['tickers'] = tickers if topics: params['topics'] = topics if time_from: params['time_from'] = time_from if time_to: params['time_to'] = time_to try: response = requests.get(BASE_URL, params=params) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: print(f"Error fetching news sentiment: {e}") return None if __name__ == '__main__': print("Example: Fetching news sentiment for Apple") aapl_news = get_news_sentiment(tickers='AAPL') if aapl_news and 'feed' in aapl_news: print(aapl_news['feed'][:1])

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pratyush-usc-mba/Designing-an-Agentic-AI-System-with-MCP-Integration'

If you have feedback or need assistance with the MCP directory API, please join our Discord server