START_HERE.mdβ’9.45 kB
# π MCP ChatGPT App - START HERE
## π What You Have
A fully functional **TypeScript ChatGPT App** using the **Model Context Protocol (MCP) SDK** with:
β
**Express server** exposing MCP tools via REST API
β
**topMovers tool** that fetches real-time stock data from Alpha Vantage
β
**Beautiful ChatGPT app frontend** with dark mode, responsive tables, and animations
β
**Auto-load functionality** using `window.openai.callTool('topMovers', { limit })`
β
**ngrok integration** for easy external access
β
**Complete documentation** and helper scripts
---
## π― Quick Start (3 Steps)
### Step 1: Get API Key
```bash
# Visit: https://www.alphavantage.co/support/#api-key
# Then set it:
export ALPHA_VANTAGE_API_KEY=your_key_here
```
### Step 2: Start Server
```bash
./start.sh
```
### Step 3: Open Browser
```
http://localhost:3000
```
**That's it!** π
---
## π Project Structure
```
MCPAddIn/
βββ π START_HERE.md β You are here!
βββ π QUICKSTART.md β 3-step quick start
βββ π SETUP_COMPLETE.md β Detailed setup guide
βββ π ARCHITECTURE.md β Technical architecture
βββ π README.md β Full documentation
β
βββ π§ Configuration
β βββ package.json β Dependencies
β βββ tsconfig.json β TypeScript config
β βββ env.example β Environment variables example
β βββ requirements.txt β Package list
β
βββ π» Source Code
β βββ src/
β β βββ server.ts β MCP server + Express + topMovers tool
β βββ public/
β βββ index.html β ChatGPT app frontend
β
βββ π οΈ Scripts
β βββ start.sh β Start the server
β βββ ngrok.sh β Expose via ngrok
β βββ test-setup.sh β Verify setup
β
βββ π¦ Build Output
βββ dist/
βββ server.js β Compiled JavaScript
```
---
## π¨ What the App Does
### Frontend (index.html)
1. **Auto-loads** on page open
2. **Calls** `window.openai.callTool('topMovers', { limit: 10 })`
3. **Displays** three responsive tables:
- π **Top Gainers** (stocks with biggest gains)
- π **Top Losers** (stocks with biggest losses)
- π₯ **Most Actively Traded** (highest volume stocks)
4. **Features**:
- Dark mode with gradient hero
- Color-coded changes (green/red)
- Smooth animations (Anime.js)
- Responsive design (mobile-friendly)
- Adjustable result limits
- Manual refresh button
### Backend (server.ts)
1. **Serves** the ChatGPT app frontend
2. **Exposes MCP tool**: `topMovers(limit)`
3. **Fetches data** from Alpha Vantage API
4. **Formats results** and returns JSON
5. **Handles errors** gracefully
---
## π§ͺ Test Your Setup
Run the verification script:
```bash
./test-setup.sh
```
This checks:
- β
Node.js & npm installed
- β
TypeScript installed
- β
Dependencies installed
- β
Build compiled
- β
API key set
- β
ngrok available
- β
Scripts executable
---
## π Using ngrok
**Terminal 1** (Keep running):
```bash
./start.sh
```
**Terminal 2**:
```bash
./ngrok.sh
```
You'll get a public URL like:
```
https://abc123.ngrok.io
```
Share this URL or use it for ChatGPT integration!
---
## π Example API Call
### Using the Tool
```javascript
// In ChatGPT app context
const data = await window.openai.callTool('topMovers', { limit: 10 });
console.log(data);
// {
// metadata: "Top Gainers, Losers, and Most Actively Traded...",
// last_updated: "2024-01-01T12:00:00",
// top_gainers: [...],
// top_losers: [...],
// most_actively_traded: [...]
// }
```
### Direct HTTP Call
```bash
curl -X POST http://localhost:3000/mcp/tools/call \
-H "Content-Type: application/json" \
-d '{
"name": "topMovers",
"arguments": { "limit": 5 }
}'
```
---
## π― What Each File Does
| File | Purpose |
|------|---------|
| **START_HERE.md** | This overview guide |
| **QUICKSTART.md** | 3-step quick start instructions |
| **SETUP_COMPLETE.md** | Detailed setup and feature list |
| **ARCHITECTURE.md** | Technical architecture and data flow |
| **README.md** | Complete documentation |
| **src/server.ts** | MCP server implementation |
| **public/index.html** | ChatGPT app frontend |
| **start.sh** | Startup script with colored output |
| **ngrok.sh** | ngrok tunnel helper |
| **test-setup.sh** | Setup verification |
---
## π Important Environment Variables
```bash
# Required
export ALPHA_VANTAGE_API_KEY=your_key_here
# Optional
export PORT=3000 # Default: 3000
```
**Make it permanent** (add to `~/.zshrc`):
```bash
echo 'export ALPHA_VANTAGE_API_KEY=your_key' >> ~/.zshrc
source ~/.zshrc
```
---
## π Key Technologies
### Backend
- **TypeScript** - Type-safe JavaScript
- **Express.js** - Web server
- **@modelcontextprotocol/sdk** - MCP implementation
- **Axios** - HTTP client
- **Alpha Vantage API** - Stock market data
### Frontend
- **HTML5** - Structure
- **Tailwind CSS** - Styling
- **DaisyUI** - UI components
- **Anime.js** - Animations
- **Vanilla JS** - Logic
---
## π± Screenshot Preview
When you open `http://localhost:3000`, you'll see:
```
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β π Top Movers Dashboard β
β Real-time stock market gainers, losers... β
β [Results: 10] [π Refresh] β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β π Top Gainers β
β βββββββ¬βββββββββ¬βββββββββ¬ββββββββββ¬ββββββββββββ
β βTick β Price β Change β Change% β Volume ββ
β βββββββΌβββββββββΌβββββββββΌββββββββββΌβββββββββββ€β
β βAAPL β$150.25 β +$5.75 β +3.98% β82,451,920ββ
β βTSLA β$245.80 β+$12.30 β +5.27% β95,234,510ββ
β β... β ... β ... β ... β ... ββ
β βββββββ΄βββββββββ΄βββββββββ΄ββββββββββ΄ββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
[Similar tables for Top Losers and Most Active]
```
---
## π Troubleshooting
### "API key not set"
```bash
export ALPHA_VANTAGE_API_KEY=your_key
./start.sh
```
### Port 3000 in use
```bash
PORT=3001 ./start.sh
```
### Dependencies missing
```bash
npm install
npm run build
```
### ngrok not found
```bash
brew install ngrok
```
---
## π Development Commands
```bash
# Install dependencies
npm install
# Build TypeScript
npm run build
# Dev mode (auto-reload)
npm run dev
# Production mode
npm start
# Watch mode (auto-rebuild)
npm run watch
# Verify setup
./test-setup.sh
```
---
## π Documentation Guide
**New user?** Read in this order:
1. β
**START_HERE.md** (you are here)
2. **QUICKSTART.md** - Get running in 3 steps
3. **SETUP_COMPLETE.md** - Learn all features
4. **README.md** - Full reference
**Developer?** Read these:
1. **ARCHITECTURE.md** - System design
2. **src/server.ts** - Backend code
3. **public/index.html** - Frontend code
---
## π You're Ready!
Everything is set up and ready to go!
### Next Actions:
1. **Get API key** from Alpha Vantage (free)
2. **Export it**: `export ALPHA_VANTAGE_API_KEY=your_key`
3. **Start server**: `./start.sh`
4. **Open browser**: `http://localhost:3000`
5. **See live stock data!** π
### Optional:
- Run `./ngrok.sh` for public access
- Read `ARCHITECTURE.md` to understand the system
- Customize `public/index.html` to change the UI
- Add more tools to `src/server.ts`
---
## π‘ Pro Tips
1. **Permanent API Key**: Add to `~/.zshrc` so you don't have to export it every time
2. **Rate Limits**: Free tier has 5 req/min, 500/day - add caching if needed
3. **Customize UI**: Edit `public/index.html` - it uses DaisyUI + Tailwind
4. **Add Tools**: Extend `src/server.ts` with more MCP tools
5. **Deploy**: Use Heroku, Vercel, or AWS for production
---
## π Useful Links
- **Alpha Vantage API**: https://www.alphavantage.co/documentation/
- **MCP Documentation**: https://modelcontextprotocol.io/
- **DaisyUI Components**: https://daisyui.com/
- **Anime.js**: https://animejs.com/
---
## β¨ Features at a Glance
β
TypeScript for type safety
β
Express.js REST API
β
MCP SDK integration
β
Alpha Vantage stock data
β
Auto-load on page open
β
Responsive dark mode UI
β
Smooth animations
β
Color-coded changes
β
Adjustable result limits
β
Manual refresh
β
ngrok ready
β
Error handling
β
Helper scripts
β
Complete documentation
---
**Happy Trading! ππ**
Questions? Check the README.md or ARCHITECTURE.md!