Token Security & Rotation
Your MCP token is the key to your workspace. Understand what it is, how to store it safely, and what to do if it's ever compromised.
What Is the MCP Token?
The MCP token is a JWT (JSON Web Token) scoped specifically to a single AgentRQ workspace. When Claude Code connects to AgentRQ via the SSE MCP endpoint, it presents this token in the URL query string — the server validates it and grants access to that workspace's tasks, messages, and tools.
- — JWT format — audience claim set to the workspace ID
- — Workspace-scoped — grants access to exactly one workspace, no others
- — Long-lived — does not expire on a schedule; valid until regenerated
- — Encrypted at rest — stored in the database with AES-256-GCM encryption
- — Full access — grants read/write access to all tasks and messages in that workspace via MCP
https://WORKSPACE_ID.mcp.agentrq.com/mcp?token=YOUR_MCP_TOKEN
↑ token is passed here as a query parameter
Token Security Rules
.mcp.json and then commit that file. If .mcp.json contains a live token and it ends up in a public (or even private) repo, treat the token as compromised and rotate immediately.Storing Your Token Safely
The safest approach is to keep the token out of any file that could be committed. Use environment variables and reference them in .mcp.json via Claude Code's env var expansion syntax.
Add the token to your shell profile as an environment variable. Name it clearly so you know which project and workspace it belongs to.
export AGENTRQ_TOKEN_MY_PROJECT="your-token-here"
Claude Code supports ${ENV_VAR_NAME} expansion in .mcp.json. With this approach, you can safely commit .mcp.json — it contains no secret values.
{
"mcpServers": {
"agentrq": {
"type": "http",
"url": "https://WORKSPACE_ID.mcp.agentrq.com/mcp?token=${AGENTRQ_TOKEN_MY_PROJECT}"
}
}
}
If you prefer a local .env file, make sure it's in your .gitignore. Use a .env.example file (without the actual value) to document the required variable for teammates.
AGENTRQ_TOKEN_MY_PROJECT=your-token-here
How to Rotate a Token
Token rotation immediately invalidates the old token and generates a new one. Any Claude Code sessions using the old token will lose connectivity until updated.
.mcp.json URL (or environment variable) with the new tokenctrl+c then claude againWhen to Rotate
- You accidentally committed the token to git
- You shared it over Slack, email, or an insecure channel
- You suspect unauthorized access to the workspace
- A device with the token stored was lost or stolen
- A team member who had the token leaves
- You're doing a quarterly security review
- You're archiving or handing off a project
- You're switching dev machines
MCP Token vs. Session Token
There are two types of tokens in the AgentRQ MCP protocol. You only need to manage one of them.
- Long-lived, workspace-scoped JWT
- Set in
.mcp.jsonas?token= - Manually rotated via dashboard
- Requires your attention for security
- Short-lived JWT, valid for one session
- Created by the server after each
initialize - Managed entirely by Claude Code
- You never see or handle these
The session token is part of the MCP protocol handshake — Claude Code exchanges the MCP token for a short-lived session token automatically. You only ever need to think about the long-lived MCP token that lives in your .mcp.json or environment variable.
Protect Your .gitignore
Add these entries to your project's .gitignore to prevent accidental commits of files that might contain tokens:
# Environment and secret files
.env
.env.local
.env.*.local
# Local MCP config overrides (if you keep secrets in a local copy)
.mcp.json.local
# Token files
*.token
*.secret
.mcp.json uses ${ENV_VAR} syntax for the token (no literal token value), it's safe to commit. This is the recommended approach — teammates clone the repo, set the env var, and connect immediately without any secrets in the codebase.