Entz commited on
Commit
20e1ee3
Β·
verified Β·
1 Parent(s): e18685a

Delete stock_server.py

Browse files
Files changed (1) hide show
  1. stock_server.py +0 -63
stock_server.py DELETED
@@ -1,63 +0,0 @@
1
- from mcp.server.fastmcp import FastMCP
2
- import aiohttp
3
- import json
4
- from typing import Optional
5
-
6
- mcp = FastMCP("StockMarket")
7
-
8
- @mcp.tool()
9
- async def get_stock_price(symbol: str) -> str:
10
- """
11
- Get current stock price and info for a given ticker symbol.
12
- Uses Alpha Vantage free API (or Yahoo Finance fallback).
13
- """
14
- # Using a mock response for demo - replace with actual API call
15
- # For real implementation, use yfinance or Alpha Vantage API
16
- mock_prices = {
17
- "AAPL": {"price": 195.89, "change": "+2.34", "percent": "+1.21%"},
18
- "GOOGL": {"price": 142.57, "change": "-0.89", "percent": "-0.62%"},
19
- "MSFT": {"price": 378.91, "change": "+5.12", "percent": "+1.37%"},
20
- "TSLA": {"price": 238.45, "change": "-3.21", "percent": "-1.33%"},
21
- }
22
-
23
- symbol = symbol.upper()
24
- if symbol in mock_prices:
25
- data = mock_prices[symbol]
26
- return f"{symbol}: ${data['price']} ({data['change']}, {data['percent']})"
27
-
28
- # For production, uncomment and use real API:
29
- # try:
30
- # import yfinance as yf
31
- # ticker = yf.Ticker(symbol)
32
- # info = ticker.info
33
- # price = info.get('currentPrice', info.get('regularMarketPrice', 'N/A'))
34
- # return f"{symbol}: ${price}"
35
- # except:
36
- # return f"Could not fetch data for {symbol}"
37
-
38
- return f"Unknown symbol: {symbol}"
39
-
40
- @mcp.tool()
41
- async def get_market_summary() -> str:
42
- """Get a summary of major market indices."""
43
- # Mock data - replace with real API calls
44
- return """Market Summary:
45
- πŸ“Š S&P 500: 4,783.45 (+0.73%)
46
- πŸ“ˆ NASDAQ: 15,123.68 (+1.18%)
47
- πŸ“‰ DOW: 37,863.80 (-0.31%)
48
- πŸ’± USD/EUR: 0.9234
49
- πŸͺ™ Bitcoin: $43,521.00 (+2.4%)
50
- πŸ›’οΈ Oil (WTI): $73.41/barrel"""
51
-
52
- @mcp.tool()
53
- async def get_company_news(symbol: str, limit: int = 3) -> str:
54
- """Get latest news headlines for a company."""
55
- # Mock news - in production, use NewsAPI or similar
56
- symbol = symbol.upper()
57
- return f"""Latest news for {symbol}:
58
- 1. {symbol} announces Q4 earnings beat expectations
59
- 2. Analysts upgrade {symbol} to 'Buy' rating
60
- 3. {symbol} unveils new product line for 2025"""
61
-
62
- if __name__ == "__main__":
63
- mcp.run(transport="stdio")