Get your API key

Lesson 4 of 5

Keys, scopes and safety

Where each server is saved, how to keep tokens out of shared files, smallest-possible access, approval prompts and prompt injection.

9 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson you will know where each server setting is saved, keep tokens out of files you share, give every server the smallest access that works, and spot prompt injection before it hurts you.

You need: at least one server from the starter servers lesson · Time: 9 minutes

  1. When you add a server, your agent saves it somewhere. Where it is saved decides who gets it and in which projects. Claude Code calls this the scope:

    Three cards. Local (the default): saved in ~/.claude.json, works in this project only, only you get it, private keys OK. Project: saved in .mcp.json in the project folder, works in this project, everyone gets it through Git, keys only as ${VAR}. User: saved in ~/.claude.json, works in all your projects, only you get it, private keys OK.
    Local and user stay on your laptop. Project travels with your code to everyone.

    You pick the scope with --scope local, --scope project or --scope user when you add the server. The other agents have the same idea with different files:

    Agent Only for you Shared with the project
    Codex ~/.codex/config.toml .codex/config.toml (trusted projects only)
    OpenCode your global OpenCode config opencode.json in the project
    Cursor ~/.cursor/mcp.json .cursor/mcp.json
    Match them

    Match each need with the Claude Code scope

    Tap an item on the left, then its meaning on the right.

    Why?

    A file in the project folder ends up on GitHub with your code. Anything written in it, including a token, is shared with everyone who can see the repo, sometimes the whole internet.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. Keep tokens out of shared files
  2. Give every server the smallest access
  3. Approval prompts: when to say yes
  4. Prompt injection: when data gives orders
  5. Recap