This guide walks you through setting up OpenAI Codex CLI from a fresh macOS VM, connecting it to the Alpha Vantage MCP server.
💡 At least 64 GB storage is recommended for fresh VMs.
📦 Homebrew is used for installing packages.
📝 VS Code is used for file editing.
You can use your preferred package manager and file editor, but note that commands and syntax may differ from the examples in this guide.
Homebrew is used in this demo to install packages.
To install Homebrew via Terminal, run the following:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
At the end of the Homebrew install, copy-paste the commands generated by the installer to activate Homebrew without restarting your Terminal.
# The below commands are illustrative. Homebrew will replace 'your-username'.
echo >> /Users/your-username/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/your-username/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Verify installation:
brew -v
VS Code is used in this demo for file editing. If you don't already have VS Code installed, install with Homebrew:
brew install --cask visual-studio-code
The code command lets you open files and folders directly in VS Code from the Terminal. To enable it:
- Open VS Code (either manually or type
open -a "Visual Studio Code"in Terminal)- Press Cmd(⌘) + Shift + P
- Search for “Shell Command: Install 'code' command in PATH”
- Press Enter
💡 Tip: You can also open this .md file in VS Code for a cleaner, formatted view.
- Open this
.mdfile in VS Code.- Press Cmd(⌘) + Shift + V to preview the Markdown.
Codex CLI (which will be installed in the next section) runs on Node.js, so install it using Homebrew:
brew install node
Verify installation by checking the versions:
node -v
npm -v
Install Codex CLI.
npm install -g @openai/codex
Or, update:
npm update -g @openai/codex
Verify version (0.34 or later to avoid compatibility issues):
codex --version
uv is used to run the Alpha Vantage MCP server directly via uvx, without needing a separate proxy installation.
curl -LsSf https://astral.sh/uv/install.sh | sh
Add it to your PATH to avoid restarting shell. This command should also appear in the Terminal (commands for sh, bash, zsh):
source "$HOME/.local/bin/env"
Confirm installation:
uv --version
Create a configuration directory and file:
code ~/.codex/config.toml # 'code' will open in VS Code; replace 'code' with your preferred editor.
Paste the following (replace YOUR_API_KEY with your Alpha Vantage API key):
[mcp_servers.alphavantage]
command = "uvx"
args = ["av-mcp", "YOUR_API_KEY"]
Save and close the file.
Create a project directory for Codex-generated projects. You can replace codex-projects with any folder name you prefer. (Tip: ~ refers to your home directory; you can specify a full path if preferred.)
mkdir -p ~/codex-projects
cd ~/codex-projects
Launch Codex CLI from your project directory.
codex
First time users will be guided through additional prompts.
Then, type the following as a prompt into Codex to connect to Alpha Vantage MCP:
/mcp
You now have a fully working Codex + Alpha Vantage setup on macOS.
Continue with the below instructions for a demo.
Build a simple stock portfolio tracker web app using Alpha Vantage MCP.
Use TIME_SERIES_DAILY from the Alpha Vantage MCP Server.
It should fetch live data for 3 tech stocks, display portfolio value over time, and run locally with Node.js. Save it in a folder called “portfolio-tracker”.
Build a Portfolio Tracker web app that runs locally on localhost. Use the Alpha Vantage MCP server to fetch stock data.
Use TIME_SERIES_DAILY from the Alpha Vantage MCP Server.
Requirements Assets / Allocation
- Track the top 3 major tech stocks
- Assume a total portfolio value ≈ $200,000 at today’s prices.
- Distribute the value unevenly across the three stocks (not equal thirds).
Data
- Fetch historical daily data for the past 6 months for each stock.
- Implement a fallback cache:
- If a live MCP API call fails, load from cached JSON.
- Mark cached data clearly by appending “(cached)” to that stock’s legend entry.
Visualizations
- Line chart:
- Toggle between total portfolio value over time and individual stock values over time.
- Stacked Area Chart:
- Show allocation percentages (per stock) over time.
- Add total portfolio value as a secondary Y-axis line.
Other
- Save project in subdirectory called “portfolio-tracker”
- Create a .env file to put in my api key
- Leverage npm start and npm install to launch the web app
ls # look for "portfolio-tracker"
cd portfolio-tracker
ls # confirm files were created
cd portfolio-tracker
cp .env.example .env
code .env # paste in your API key
npm install
npm start # open the URL (e.g., http://localhost:3000) in your browser
node server.js