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 your agent connects to AgentRQ via the 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. You never copy it: the machine that starts the agent writes it into the workspace's working directory for you.
- — 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
- — Stateless authentication — cryptographically signed JWT validated on each request (no DB lookup or token key storage needed)
- — 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 that agentrqd writes holds a live token, and the
daemon keeps it out of commits for you. If it ever ends up in a public (or even
private) repo anyway, treat the token as compromised and rotate immediately.
Where Your Token Is Stored
You do not store it. When you start an agent from the workspace page, agentrqd writes the workspace's MCP URL, token included,
into .mcp.json in the working directory on that machine:
- —
The file is readable only by you (mode
0600). - —
In a git checkout it is added to
.gitignore, and kept out of commits even if the repository already tracks the file. - — The URL is never logged and never put on a command line, where other users of the machine could see it.
The daemon never rewrites an agentrq-workspace entry that
is already in that file. That matters when you rotate, below.
How to Rotate a Token
The token is bound to the workspace ID, so rotating it means giving the workspace a new ID. Every token issued for the old ID stops working at once, and your tasks, memory and skills are kept. Any agent using the old MCP URL loses connectivity until you start it again. For the full incident checklist, read what to do when your .mcp.json is compromised.
.mcp.json (or just
its agentrq-workspace entry). agentrqd never rewrites an entry that is already
there, so a plain restart would keep the old URLagentrqd writes
a fresh .mcp.json with the new MCP URLWhen 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
- Written into
.mcp.jsonas?token=by your machine - 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 the agent's MCP client
- You never see or handle these
The session token is part of the MCP protocol handshake — the agent 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 the working directory's .mcp.json.
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
# Token files
*.token
*.secret
You do not need an entry for .mcp.json:
agentrqd adds it to .gitignore itself when it writes the file.