Claude Code set up

    Store Your MLS API Key in Claude Code

    Where Claude Code keeps secrets, how your project's server code reads the key, and how to check it never reaches the page.

    Part of the Claude Code MLS API Integration guide · Last reviewed 2026-11-20

    Storing an MLS API key in Claude Code secrets

    With Claude Code, the key lives in a .env file at the project root while you build, with .env listed in .gitignore so it never reaches your Git repository. When the site goes live, it lives in the host's secret settings, for example npx wrangler secret put SAIGE_MLS_API_KEY on Cloudflare Workers. CLAUDE.md names the variables, never the values.

    Key takeaways

    • Create .env with SAIGE_MLS_API_KEY and SAIGE_MLS_API_URL.
    • Add .env to .gitignore first.
    • CLAUDE.md names the variables, never the values.
    • Set host secrets for the live site.

    Need the data feed for this? Saige is an approved MLS data vendor in BC. Send a request and our team will contact you.

    Where Claude Code keeps secrets

    CLAUDE.md is shared with your team through version control, so it must never contain the key itself. Write the variable names and the rules there.

    Reading the key in your project's server code

    On Cloudflare Workers, secrets arrive in the env object passed to the handler. In Node frameworks they are in process.env. Only the server module reads them.

    Server module reading the key (Node)
    // src/server/mls.ts
    const key = process.env.SAIGE_MLS_API_KEY;
    const base = process.env.SAIGE_MLS_API_URL;
    
    export async function getListings(query: string) {
      const res = await fetch(`${base}/Property?${query}`, {
        headers: { Authorization: `Bearer ${key}` },
      });
      if (!res.ok) throw new Error(`Feed error ${res.status}`);
      return (await res.json()).value;
    }

    Check before you publish

    Open the published Claude Code site, view the page source, and search for the first characters of your key. It must not be there. Then use the search page with the browser's network panel open: requests should go to your own server code, not straight to the feed address. The full check list is at Keep Your MLS API Key Secret on an AI-Built Site.

    Frequently asked questions

    Should I paste the key into the Claude Code chat?

    No. Put it in .env yourself and tell Claude Code the variable name.

    Can I keep .env out of Claude Code's reach?

    Claude Code's settings docs show a deny rule, Read(./.env), under permissions in .claude/settings.json, for keeping it away from environment files.

    Related pages in this guide

    Sources

    Every claim on this page that could be checked against a primary source is linked below. Where something is not publicly documented by a vendor, the page says so rather than filling the gap with an estimate.

    MLS API for BC

    Put live MLS listings on the site you are building

    Saige is an approved MLS data vendor for Greater Vancouver REALTORS, Fraser Valley Real Estate Board, Chilliwack and District Real Estate Board and BC Northern Real Estate Board. Send a request and our team will contact you to check what your board allows and how to connect your builder.

    Call 604.401.4849