Enables automated workflow creation for stock analysis, including daily portfolio reports, price alerts, and batch valuation through HTTP request nodes
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Stock Valuation MCP Servercalculate PE band for CPALL with 5-year historical data"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π 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
# Clone the repository
git clone <repository-url>
cd myMCPserver
# Install dependencies
npm install
# Copy environment configuration
cp .env.example .env
# Build the project
npm run buildClaude Desktop Integration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"stock-valuation": {
"command": "node",
"args": ["C:/Programing/ByAI/myMCPserver/dist/index.js"]
}
}
}Restart Claude Desktop to start using the tools!
Quick Test with MCP Inspector
npm install -g @modelcontextprotocol/inspector
npx @modelcontextprotocol/inspector node dist/index.jsβοΈ Oracle Cloud Deployment
One-Click Deployment
# Deploy to Oracle Cloud Free Tier
chmod +x scripts/deploy-oracle.sh
./scripts/deploy-oracle.shManual 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
# Install dependencies
npm install
# Set up environment
cp .env.example .env
# Build TypeScript
npm run build
# Run in development
npm run devProduction Mode
# Build for production
npm run clean
npm run build
# Run production server
npm startDocker Deployment
# Build image
docker build -t stock-valuation-mcp .
# Run with Docker
docker run -d \
-p 2901:2901 \
-e NODE_ENV=production \
stock-valuation-mcp
# Or use Docker Compose
docker-compose up -dπ§ Configuration
Environment Variables
Create a .env file based on .env.example:
# API Configuration
SET_WATCH_API_HOST=https://xxxxxxxxxxxx.app # Your API host
SET_WATCH_API_TIMEOUT=30000
# Server Configuration
NODE_ENV=production
LOG_LEVEL=info
# Optional: Custom API Authentication
# API_AUTH_HEADER=X-API-Key
# API_AUTH_VALUE=your-api-keyAvailable 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
{
"tool": "complete_valuation",
"arguments": {
"symbol": "ADVANC",
"requiredReturn": 0.10,
"growthRate": 0.05,
"discountRate": 0.10
}
}2. Financial Statement Analysis
{
"tool": "fetch_all_financial_statements",
"arguments": {
"symbol": "SCB",
"period": "Quarterly"
}
}3. Historical Trend Analysis
{
"tool": "analyze_historical_ratios",
"arguments": {
"symbol": "PTT",
"period": "Quarterly"
}
}Response Format
All tools return structured JSON responses including:
{
"symbol": "ADVANC.BK",
"timestamp": "2024-01-20T10:30:00Z",
"data": { ... },
"analysis": { ... },
"recommendation": "Buy"
}π‘ Usage Examples
Example 1: Thai Stock Valuation
{
"tool": "fetch_stock_data",
"arguments": {
"symbol": "AOT"
}
}Response: Current stock data with PE, PBV, EPS, dividend yield, ROE, etc.
Example 2: PE Band Analysis with Custom Data
{
"tool": "calculate_pe_band",
"arguments": {
"symbol": "AAPL",
"currentPrice": 150.00,
"eps": 5.00,
"historicalPEs": [15, 18, 20, 22, 25, 23]
}
}Response: PE band analysis with fair value range and recommendation.
Example 3: DCF Valuation
{
"tool": "calculate_dcf",
"arguments": {
"symbol": "GOOGL",
"currentPrice": 150,
"freeCashFlow": 60000000000,
"sharesOutstanding": 15000000000,
"growthRate": 0.08,
"discountRate": 0.10,
"years": 5
}
}Response: DCF analysis with 5-year projections and intrinsic value calculation.
Example 4: Historical Ratio Analysis
{
"tool": "analyze_historical_ratios",
"arguments": {
"symbol": "KBANK",
"period": "Quarterly"
}
}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
services:
stock-valuation:
build: .
restart: unless-stopped
environment:
- NODE_ENV=production
- SET_WATCH_API_HOST=https://your-api.com
ports:
- "2901:2901"
volumes:
- ./logs:/app/logsEnvironment-Specific Configuration
Development (.env.development):
NODE_ENV=development
LOG_LEVEL=debug
SET_WATCH_API_TIMEOUT=60000Production (.env.production):
NODE_ENV=production
LOG_LEVEL=warn
SET_WATCH_API_TIMEOUT=10000ποΈ Architecture
Project Structure
myMCPserver/
βββ src/
β βββ index.ts # Main MCP server entry point
β βββ config/ # Configuration management
β β βββ index.ts # Environment variable configuration
β βββ types/ # TypeScript type definitions
β β βββ index.ts # All type definitions
β βββ tools/ # MCP tool implementations
β βββ stockValuation.ts # Core valuation models
β βββ setWatchApi.ts # SET Watch API integration
β βββ financialStatements.ts # Financial statement tools
β βββ historicalRatios.ts # Historical analysis tools
βββ scripts/ # Deployment scripts
βββ dist/ # Compiled TypeScript output
βββ docs/ # Additional documentation
βββ tests/ # Test files (when added)
βββ docker-compose.yml # Docker configuration
βββ Dockerfile # Docker image definition
βββ .env.example # Environment variable template
βββ README.md # This fileMCP Server Architecture
βββββββββββββββββββββββββββββββββββββββ
β Claude Desktop β
β β β
β MCP Protocol β
β β β
βββββββββββββββββββββββββββββββββββββββ€
β Stock Valuation Server β
β βββββββββββββββββββββββββββββββ β
β β Tool Registry β β
β β βββββββββββββββββββββββββββ β β
β β β Valuation Tools β β β
β β β Data Fetching Tools β β β
β β β Analysis Tools β β β
β β βββββββββββββββββββββββββββ β β
β β βββββββββββββββββββ β β
β β β Configuration β β β
β β βββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββ β
β β SET Watch API βββββββ
β βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββπ€ 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
# Run unit tests
npm test
# Run with coverage
npm run test:coverage
# Run in watch mode
npm run test:watchπ 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
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.