Credential paths
The MCP endpoint accepts three kinds of credentials, in this priority order. Most users use only the first one.
Grain issues the OAuth tokens from its own OAuth 2.1 server after you click Authorize in the
browser. Read Authentication for the API key.
Scopes
Scopes are the control plane. A client names the scopes it needs when it asks to authorize. You can approve fewer scopes than the client asks for. The consent screen describes each scope in plain English.
If an agent only writes weekly digests, approve
mcp:read and mcp:query and leave
mcp:investigate off. You can connect again later and grant more. Read
Tools for the inputs of each tool.
There is no write scope. No MCP tool creates, updates, or deletes anything: not a segment, not a
track, not a user. You can grant all three scopes to a trusted client without a risk of a change.
Token storage
Connections
Every active MCP client is listed at Settings → Connectors → MCP clients. For each connection the page shows:Revoke a connection
- Open Settings → Connectors → MCP clients.
- Click Revoke on the connection.
- Confirm in the dialog. Grain sets the
revoked_attimestamp of the session at once.
401 with a WWW-Authenticate header. A compliant
client then asks you to authorize again or marks the server as disconnected.
Workspace isolation
An MCP session is pinned to exactly one tenant, chosen at consent.- You cannot switch the tenant in a session. To let an agent read a different tenant, authorize a second connection.
- Every tool call checks the tenant against the session again. A user who is removed from a tenant loses MCP access to it on the next tool call of the client.
- The consent flow checks your membership of the chosen tenant again before it issues an authorization code. A stale membership cannot pass.
Logging
A plaintext token never appears in a log. If you see one, it is a bug.
Checklist for teams
- Connect a test tenant first. Send a low-volume or staging site to Grain, connect the AI client to that tenant, and read a few sessions. Move to production after that.
- Grant the minimum scope that works. If the agent only writes briefings,
mcp:readandmcp:queryare enough. Addmcp:investigatewhen the agent needs it. - Read the MCP clients page every week, and after a team member leaves. Revoke every connection whose “Last used” is “never” or older than your tolerance.
- Rotate the tenant API key every year. This applies only to the
X-API-Keypath. OAuth sessions rotate on refresh.