-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_installation.py
More file actions
106 lines (94 loc) · 3.09 KB
/
test_installation.py
File metadata and controls
106 lines (94 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python3
"""
Yahoo Finance MCP Server - Installation Test Script
This script verifies that all required packages are installed correctly
and that the server can connect to Yahoo Finance.
"""
import sys
print("=" * 60)
print("Yahoo Finance MCP Server - Installation Test")
print("=" * 60)
print()
# Test 1: Python Version
print("Test 1: Checking Python version...")
version = sys.version_info
if version.major >= 3 and version.minor >= 8:
print(f"✅ Python {version.major}.{version.minor}.{version.micro} - OK")
else:
print(f"❌ Python {version.major}.{version.minor}.{version.micro} - Need Python 3.8+")
sys.exit(1)
print()
# Test 2: Required Packages
print("Test 2: Checking required packages...")
required_packages = {
'yfinance': 'yfinance',
'pandas': 'pandas',
'pydantic': 'pydantic',
'httpx': 'httpx',
'mcp': 'mcp'
}
all_packages_ok = True
for package_name, import_name in required_packages.items():
try:
__import__(import_name)
print(f"✅ {package_name} - Installed")
except ImportError:
print(f"❌ {package_name} - NOT installed")
all_packages_ok = False
if not all_packages_ok:
print()
print("⚠️ Some packages are missing!")
print("Run: pip install -r requirements.txt")
sys.exit(1)
print()
# Test 3: Yahoo Finance Connection
print("Test 3: Testing Yahoo Finance connection...")
try:
import yfinance as yf
ticker = yf.Ticker("AAPL")
info = ticker.info
price = info.get('currentPrice', info.get('regularMarketPrice', 'N/A'))
if price != 'N/A':
print(f"✅ Successfully fetched Apple stock price: ${price}")
else:
print("⚠️ Connected but couldn't get price (this is OK)")
except Exception as e:
print(f"❌ Error connecting to Yahoo Finance: {str(e)}")
print("Check your internet connection")
all_packages_ok = False
print()
# Test 4: MCP Server File
print("Test 4: Checking MCP server file...")
import os
server_file = "yahoo_finance_mcp.py"
if os.path.exists(server_file):
print(f"✅ {server_file} - Found")
# Check if it's valid Python
try:
with open(server_file, 'r') as f:
compile(f.read(), server_file, 'exec')
print(f"✅ {server_file} - Valid Python syntax")
except SyntaxError as e:
print(f"❌ {server_file} - Syntax error: {e}")
all_packages_ok = False
else:
print(f"❌ {server_file} - Not found in current directory")
all_packages_ok = False
print()
# Final Result
print("=" * 60)
if all_packages_ok:
print("🎉 All tests passed! Your installation looks good!")
print()
print("Next steps:")
print("1. Configure Claude Desktop (see SETUP_GUIDE.md)")
print("2. Restart Claude Desktop")
print("3. Try asking: 'What's the price of Apple stock?'")
else:
print("⚠️ Some tests failed. Please fix the issues above.")
print()
print("Common solutions:")
print("- Install missing packages: pip install -r requirements.txt")
print("- Check your internet connection")
print("- Make sure yahoo_finance_mcp.py is in this directory")
print("=" * 60)