Human-in-the-Loop Task Manager for AI Agents
Docs / How-To / Token Security
Token Security

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.

Token Properties
  • — 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
MCP endpoint — token placement
https://WORKSPACE_ID.mcp.agentrq.com/mcp?token=YOUR_MCP_TOKEN
                                                           ↑ token is passed here as a query parameter

Token Security Rules

Never Commit to Git
The .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.
Scope Is Per-Workspace
Each workspace has its own independent token. A leaked token exposes only that workspace — not your account, not other workspaces. This limits blast radius. For sensitive projects, use dedicated workspaces with tightly controlled token access.
Treat It Like a Private API Key
Apply the same practices you use for AWS access keys, Stripe secret keys, or database passwords. Rotate it on team membership changes, and never share it over insecure channels.

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.

1
Open the workspace in the AgentRQ dashboard, go to Settings and choose the Danger Zone tab
2
Click Reset ID and confirm
3
On each machine that runs this workspace's agent, delete the working directory's .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 URL
4
Start the agent again from the workspace page, where AgentRQ lands you after the reset. agentrqd writes a fresh .mcp.json with the new MCP URL
Immediate invalidation. The old token stops working the moment you click Reset ID, and links to the workspace and its tasks change too. Any agent still using the old token will fail to connect; its terminal says the entry was kept as it is. Delete the old entry and start the agent again before resuming work.

When to Rotate

Rotate Immediately If...
  • 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
Rotate as Routine When...
  • 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.

MCP Token You manage this
  • Long-lived, workspace-scoped JWT
  • Written into .mcp.json as ?token= by your machine
  • Manually rotated via dashboard
  • Requires your attention for security
MCP Session Token Automatic
  • 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

Never Commit Tokens to Git
If a token ends up in a git commit — even in a private repository — treat it as compromised. GitHub secret scanning will flag it, but even before that, anyone with repo access can see it in history. Rotate immediately if this happens.

Add these entries to your project's .gitignore to prevent accidental commits of files that might contain tokens:

.gitignore
# 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.