# Palantir MCP - Persisting Your Token and Hostname (Linux/macOS) The [official installation guide](https://www.palantir.com/docs/foundry/palantir-mcp/installation) has you run `export FOUNDRY_HOST` and `export FOUNDRY_TOKEN` before running `claude mcp add`. Those exports die when you close the terminal. Here's how to make them stick. --- ## Linux (Ubuntu/Debian) ```bash echo 'export FOUNDRY_HOST="your-enrollment.palantirfoundry.com"' >> ~/.bashrc echo 'export FOUNDRY_TOKEN="your-token-here"' >> ~/.bashrc source ~/.bashrc ``` Verify both took: ```bash echo $FOUNDRY_HOST echo $FOUNDRY_TOKEN ``` If either is blank, check what's actually in the file: ```bash grep FOUNDRY ~/.bashrc ``` Two things break this. First: pasting a placeholder like `<your-token-here>` instead of the real token. The shell accepts it without complaint. Second: running the `echo` commands twice, which creates duplicate entries and the wrong one wins. If you see duplicate lines, clean them out: ```bash sed -i '/FOUNDRY_HOST/d' ~/.bashrc sed -i '/FOUNDRY_TOKEN/d' ~/.bashrc echo 'export FOUNDRY_HOST="your-enrollment.palantirfoundry.com"' >> ~/.bashrc echo 'export FOUNDRY_TOKEN="your-token-here"' >> ~/.bashrc source ~/.bashrc ``` --- ## macOS macOS defaults to Zsh since Catalina. Same pattern, different file: ```bash echo 'export FOUNDRY_HOST="your-enrollment.palantirfoundry.com"' >> ~/.zshrc echo 'export FOUNDRY_TOKEN="your-token-here"' >> ~/.zshrc source ~/.zshrc ``` On older macOS still running Bash, use `~/.bash_profile` instead. --- ## Confirming the MCP Server Can Authenticate Before adding it to your IDE, run the server directly: ```bash npx -y palantir-mcp --foundry-api-url https://$FOUNDRY_HOST ``` A stall with no output means it connected. It's waiting for MCP protocol input over stdio — that's correct. Hit `Ctrl+C` and proceed. A `NoTokenAvailableError` means `FOUNDRY_TOKEN` is empty or wrong. An `Invalid token` error means the token belongs to a different enrollment. --- ## Token Hygiene When a token is exposed, revoke it immediately at `https://your-enrollment.palantirfoundry.com/workspace/settings/tokens` and generate a new one. Don't commit `.bashrc` or `.zshrc` to a repository — the token will be in the diff history even if you delete it later.