My Portfolio MCP Server
Provides automatic sync and daily backups of the SQLite portfolio database to a specified Google Drive folder, enabling data persistence and recovery.
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., "@My Portfolio MCP ServerShow me my open positions"
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.
My Portfolio MCP Server
A Model Context Protocol (MCP) server for managing investment portfolios. Built with Node.js, SQLite, and Google Drive integration.
Quick Start
👉 New? See QUICKSTART.md for setup in 5 minutes
Related MCP server: Alpaca Trading MCP Server
Features
Transaction Management: Track buys, sells, and dividends
Position Tracking: Manage open and closed positions with cost basis
Alerts: Create and store price/gain-loss alerts
Daily Position Snapshots: Record end-of-day portfolio snapshots
Comments with History: Full comment history on positions and alerts
Google Drive Sync: Automatic sync and daily backups
MCP Integration: Use with Claude for natural language portfolio queries
Setup
Prerequisites
Node.js 18+
Google account with Drive access
Railway account (for deployment)
OAuth Setup
This project uses OAuth 2.0 for Google Drive access.
For detailed setup instructions including:
Creating OAuth credentials in Google Cloud
Generating authorization tokens
Creating a Google Drive folder
Configuring environment variables
👉 See OAUTH_SETUP.md
Local Development
Clone and install:
npm installCreate
.envfile from.env.example:
cp .env.example .envSet up OAuth (see OAUTH_SETUP.md):
Create OAuth credentials in Google Cloud Console
Authorize locally to generate
tokens.jsonCreate a Google Drive folder
Set
DRIVE_FOLDER_IDin.env
Build and run:
npm run build
npm startThe first run will prompt you to authorize with Google (opens browser). On subsequent runs, it uses the saved token.
Or for development with auto-reload:
npm run devAvailable Tools
Transactions
list_transactions- Get all transactions with optional filtersadd_transaction- Create a new transaction (BUY/SELL/DIVIDEND)update_transaction- Modify transaction detailsdelete_transaction- Remove a transaction
Positions
list_positions- Get all positions (OPEN/CLOSED)add_position- Create a new positionupdate_position- Update shares or average costclose_position- Mark position as closedadd_position_comment- Add comment to positionlist_position_comments- Get comment historyget_position_summary- Portfolio stats
Daily Positions
record_daily_position- Record single EOD snapshotrecord_daily_positions_batch- Bulk insert for historical datalist_daily_positions- Query snapshots with filters
Alerts
list_alerts- Get all alertsadd_alert- Create alert (PRICE_ABOVE/PRICE_BELOW/GAIN_LOSS_PERCENT)update_alert- Modify alertdelete_alert- Remove alertadd_alert_comment- Add comment to alertlist_alert_comments- Get comment history
Utilities
sync_portfolio_to_drive- Manual sync triggerget_portfolio_stats- Portfolio summary
Deployment to Railway
Complete OAuth setup locally first
Push code to git repository:
git add . git commit -m "Add portfolio MCP server" git push origin mainConnect to Railway.app and link your GitHub repo
Set environment variables in Railway dashboard:
OAUTH_CREDENTIALS_JSON(base64-encoded, see OAUTH_SETUP.md)OAUTH_TOKEN_JSON(base64-encoded, see OAUTH_SETUP.md)DRIVE_FOLDER_IDDATABASE_SYNC_INTERVAL_MINUTES=1(optional, default: 1)BACKUP_TIME_UTC=23:00(optional, default: 23:00)
Railway will auto-build and deploy
Note: OAuth credentials and tokens are NOT stored in git (in .gitignore). They are provided via Railway environment variables. See OAUTH_SETUP.md for detailed instructions.
Data Storage
Primary: SQLite database (
portfolio_data.db)Backup: Synced to Google Drive every 1 minute
Daily Backups: Timestamped backups retained for 7 days
Files: Not encrypted by default (relies on Drive + file permissions)
Architecture
MCP Server (stdio transport)
↓
Tools (Transactions, Positions, Alerts, DailyPositions)
↓
SQLite Database (local)
↓
Google Drive (sync + backups)Using with Claude
Connect this MCP server to Claude and query your portfolio:
"What's my total cost basis?"
"Add 100 shares of AAPL at $150"
"Show me all OPEN positions"
"Create an alert if TSLA goes above $250"
Configuration
Environment variables in .env:
Variable | Description | Default |
| Environment | development |
| OAuth credentials (JSON or base64) | (from file) |
| OAuth token (JSON or base64) | (from file) |
| Google Drive folder ID | - |
| SQLite database path | ./portfolio_data.db |
| Sync interval | 1 |
| Daily backup time | 23:00 |
See OAUTH_SETUP.md for details on OAuth variables.
Security Notes
OAuth tokens are refresh tokens (not passwords)
Both credential files are in
.gitignore(never committed to GitHub)Secrets stored as env vars in Railway, encrypted by Railway
SQLite not encrypted by default (can add SQLCipher for sensitive data)
Backups inherit Google Drive encryption
Use parameterized SQL queries (no injection risk)
You can revoke access anytime in Google Account
Development
Type checking:
npm run buildLicense
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/udaybhasker-ub/my-portfolio-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server