Enables automated workflow creation for stock analysis, including daily portfolio reports, price alerts, and batch valuation through HTTP request nodes
📊 Stock Valuation MCP Server
📖 Table of Contents
📝 About
The Stock Valuation MCP Server provides professional-grade financial analysis tools for stock valuation and investment decision-making. It integrates seamlessly with Claude Desktop and provides real-time data from Thai stock markets through the SET Watch API.
Key Capabilities
Valuation Models: PE Band Analysis, Dividend Discount Model (DDM), Discounted Cash Flow (DCF)
Real-time Data: Live stock data from SET Watch API
Financial Statements: Complete income statement, balance sheet, and cash flow analysis
Historical Analysis: Track and analyze financial ratios over time
Investment Recommendations: Data-driven buy/sell/hold suggestions
Secure Configuration: Environment-based configuration for API keys and secrets
✨ Features
📈 Valuation Tools
PE Band Analysis - Historical PE ratio analysis with fair value ranges
Dividend Discount Model (DDM) - Gordon Growth Model for dividend-paying stocks
Discounted Cash Flow (DCF) - Intrinsic value calculation using free cash flow projections
🔍 Real-Time Data Integration
SET Watch API Integration - Fetch real-time Thai stock data
Financial Statements - Complete financial statement analysis
Historical Ratios - Track PE, PBV, ROE, ROA, ROIC trends over time
Automatic Calculations - Compute key financial ratios automatically
📊 Analysis Features
Trend Analysis - Identify valuation and profitability trends
Comparative Analysis - Compare against historical averages
Investment Scoring - Generate buy/sell/hold recommendations
Risk Metrics - Altman Z-Score, Piotroski F-Score calculations
🛡️ Security & Configuration
Environment Variables - Secure API key and configuration management
Oracle Cloud Ready - Optimized for Oracle Cloud Free Tier deployment
Docker Support - Containerized deployment with environment injection
Type Safety - Full TypeScript implementation with comprehensive type definitions
🛠️ Supported Tools
Tool Category | Tool Name | Description |
Valuation |
| Calculate PE band valuation with historical data |
Valuation |
| Dividend Discount Model analysis |
Valuation |
| Discounted Cash Flow valuation |
Data Fetching |
| Fetch real-time stock data from SET Watch |
Data Fetching |
| Run all valuation models with fetched data |
Financial Statements |
| Fetch income statement data |
Financial Statements |
| Fetch balance sheet data |
Financial Statements |
| Fetch cash flow statement data |
Financial Statements |
| Fetch all statements with ratio analysis |
Historical Analysis |
| Fetch historical PE, PBV, ROE, ROA, ROIC data |
Historical Analysis |
| Analyze trends with investment recommendations |
🚀 Quick Start
Prerequisites
Node.js 18+ installed
Claude Desktop (for MCP integration)
Docker (optional, for containerized deployment)
Installation
Claude Desktop Integration
Add to your claude_desktop_config.json:
Restart Claude Desktop to start using the tools!
Quick Test with MCP Inspector
☁️ Oracle Cloud Deployment
One-Click Deployment
Manual Deployment Steps
Setup Oracle Cloud Account
Create free tier account
Setup compartment and VCN
Generate SSH keys
Deploy Instance
# Using OCI CLI oci compute instance launch \ --availability-domain <your-AD> \ --compartment-id <compartment-id> \ --shape VM.Standard.A1.Flex \ --shape-config '{"memoryInGBs": "6", "ocpus": "2"}' \ --display-name stock-valuation-mcp \ --assign-public-ip trueConfigure Environment
# SSH into instance ssh -i ~/.ssh/oracle_key opc@<instance-ip> # Setup Docker sudo yum install -y docker sudo systemctl start docker sudo usermod -aG docker opc # Deploy MCP Server docker run -d \ --name stock-valuation-mcp \ --restart unless-stopped \ -p 2901:2901 \ -e NODE_ENV=production \ -e SET_WATCH_API_HOST=https://your-api.com \ stock-valuation-mcp:latest
For detailed deployment instructions, see Oracle Cloud Deployment Guide.
🔗 n8n Integration
Setting up n8n
Deploy n8n
docker-compose up -dCreate HTTP Request Node
{ "method": "POST", "url": "http://YOUR-MCP-SERVER:2901/mcp", "body": { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "fetch_stock_data", "arguments": { "symbol": "ADVANC" } } } }
Example Workflows
Daily Analysis Report: Automatically analyze portfolio stocks every morning
Price Alerts: Get notified when stocks hit target prices
Batch Valuation: Value multiple stocks in parallel
For complete n8n integration guide, see n8n Integration Documentation.
📚 Documentation
Document | Description |
Complete guide for deploying to Oracle Cloud Free Tier | |
Integrate with n8n for automated workflows | |
Ready-to-use n8n workflow examples | |
Common issues and solutions |
⚙️ Installation
Development Mode
Production Mode
Docker Deployment
🔧 Configuration
Environment Variables
Create a .env file based on .env.example:
Available Variables
Variable | Description | Default |
| SET Watch API base URL |
|
| API request timeout (ms) |
|
| Environment mode |
|
| Logging level |
|
| Custom auth header | (none) |
| Auth header value | (none) |
📚 API Documentation
Tool Examples
1. Complete Stock Analysis
2. Financial Statement Analysis
3. Historical Trend Analysis
Response Format
All tools return structured JSON responses including:
💡 Usage Examples
Example 1: Thai Stock Valuation
Response: Current stock data with PE, PBV, EPS, dividend yield, ROE, etc.
Example 2: PE Band Analysis with Custom Data
Response: PE band analysis with fair value range and recommendation.
Example 3: DCF Valuation
Response: DCF analysis with 5-year projections and intrinsic value calculation.
Example 4: Historical Ratio Analysis
Response: Complete historical analysis with trends and investment recommendation.
🚀 Deployment
Oracle Cloud Free Tier
Update Deployment Script:
# Edit scripts/deploy-oracle.sh # Update your Oracle Cloud credentialsDeploy:
chmod +x scripts/deploy-oracle.sh ./scripts/deploy-oracle.shConfigure Environment:
# On the instance docker pull <your-image> docker run -d \ -p 2901:2901 \ -e NODE_ENV=production \ -e SET_WATCH_API_HOST=https://your-api.com \ <your-image>
Docker Compose
Environment-Specific Configuration
Development (.env.development):
Production (.env.production):
🏗️ Architecture
Project Structure
MCP Server Architecture
🤝 Contributing
We welcome contributions! Please follow these steps:
Development Workflow
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Make your changes
Add tests if applicable
Ensure all tests pass (
npm test)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Create a Pull Request
Code Standards
Use TypeScript for all new code
Follow ESLint rules (
npm run lint)Add JSDoc comments for functions
Write tests for new features
Update documentation
Testing
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏♂️ Acknowledgments
Model Context Protocol - For the MCP SDK
SET Watch - For providing the Thai stock market data API
Oracle Cloud - For the generous free tier hosting option
n8n - For workflow automation capabilities
📞 Support
📧 Create an issue for bug reports or feature requests
📖 Check Issues for known problems
📚 See Documentation for detailed guides