Skip to the content.

Setup with GitHub and Vercel

Use GitHub for the repo and Pages (chat UI), and Vercel for the API (chat + MCP). All steps can be done with gh and vercel CLIs.


Prerequisites


1. GitHub

Clone (or fork) the repo

gh repo clone F8ai/metrc-mcp
cd metrc-mcp

If you forked:

gh repo clone YOUR_USER/metrc-mcp
cd metrc-mcp

Enable GitHub Pages (docs → site)

Pages serves the docs/ folder (including the chat UI at /chat/).

Option A – GitHub CLI

# From repo root; replace OWNER with your GitHub user/org
gh api repos/OWNER/metrc-mcp/pages -X PUT -f source='{"branch":"main","path":"/docs"}'

Option B – In the browser

  1. Settings → Pages
  2. Source: Deploy from a branch
  3. Branch: mainFolder: /docs → Save

Your site will be:

Chat UI: https://<YOUR_USER>.github.io/metrc-mcp/chat/


2. Vercel (API)

Deploy from GitHub

Option A – Vercel CLI (link existing repo)

cd metrc-mcp
vercel
# Follow prompts: link to existing project or create new one, connect to GitHub

Option B – Dashboard

  1. Go to vercel.com/new
  2. Import the GitHub repo (e.g. F8ai/metrc-mcp or your fork)
  3. Leave Root Directory and Framework Preset as default; deploy.

You’ll get a URL like https://metrc-mcp.vercel.app (or https://metrc-mcp-*.vercel.app).

Set environment variables

Option A – Vercel CLI

One-shot setup (prompts for each secret):

./scripts/setup-vercel.sh

Or run the steps yourself from the repo root (with vercel already linked):

# OpenRouter: prefer Railway edge URL (returns rotated key); else paste key
vercel env add OPENROUTER_KEY_URL production
# or: vercel env add OPENROUTER_API_KEY production

# Required for METRC tools (chat + MCP / Load facilities)
vercel env add METRC_VENDOR_API_KEY production
vercel env add METRC_USER_API_KEY production

# Optional
vercel env add OPENROUTER_MODEL production
vercel env add METRC_API_URL production

Redeploy so new env vars are used:

vercel --prod

To list vars: vercel env ls. To pull into a local file: vercel env pull .env.local.

Option B – Dashboard

  1. Project → Settings → Environment Variables
  2. Add:
Name Value Environments
OPENROUTER_KEY_URL Railway edge URL that returns current OpenRouter key (preferred; we rotate keys) Production, Preview
OPENROUTER_API_KEY OpenRouter key (fallback if OPENROUTER_KEY_URL not set) Production, Preview
METRC_VENDOR_API_KEY your METRC vendor key Production, Preview
METRC_USER_API_KEY your METRC user key Production, Preview
OPENROUTER_MODEL e.g. openai/gpt-4o optional
METRC_API_URL https://sandbox-api-co.metrc.com optional
  1. Redeploy (Deployments → ⋮ → Redeploy).

3. Use the chat UI

  1. Open the Pages chat URL (e.g. https://f8ai.github.io/metrc-mcp/chat/).
  2. In API URL, enter your Vercel URL (e.g. https://metrc-mcp.vercel.app) with no trailing slash.
  3. Click Load facilities, then choose a facility (e.g. SF-SBX-CO-1-8002).
  4. Send messages; the model will use the selected facility for METRC tools.

4. CORS and custom GitHub Pages URL

The API allows requests from https://f8ai.github.io. If your Pages site is on a different host (e.g. a fork at https://YOUR_USER.github.io), you have two options:

A. Keep using F8ai’s Pages

Use https://f8ai.github.io/metrc-mcp/chat/ and only your Vercel API URL in the chat UI.

B. Allow your fork’s origin in the API

In api/chat.js and api/mcp.js, set:

'Access-Control-Allow-Origin': 'https://YOUR_USER.github.io'

(or add logic to allow multiple origins). Commit, push, and redeploy on Vercel.


Quick reference

Item Where
Chat UI GitHub Pages → https://<owner>.github.io/metrc-mcp/chat/
API (chat + MCP) Vercel → https://<project>.vercel.app/api/chat and /api/mcp
Env vars Vercel project → Settings → Environment Variables
Repo GitHub → F8ai/metrc-mcp (or your fork)