Manage assistant sessions
How an administrator lists and ends the AI assistant sessions of the Datasentinel MCP server with the mcp_oauth_sessions.sh script: who is signed in, with which assistant, and how to disconnect a user
When a user connects an AI assistant to the Datasentinel MCP server, they sign in once on the Datasentinel login page. The platform then keeps a session for that user on that assistant, and the session renews itself (see How authentication works).
The mcp_oauth_sessions.sh script lets an administrator see these sessions and end them. Use it to:
check who is connected, and with which assistants;
disconnect a user who left the company or lost access;
retire an assistant installation that is no longer used;
troubleshoot a sign-in that does not complete.
Before you start
Connect to the Datasentinel platform host.
Run the script as the
datasentineluser. The session store is readable by this user only.The script is in
/datasentinel/soft/datasentinel_backend/scripts.
Commands at a glance
summary
Shows the size of the session store and how many users are signed in.
No
clients
Lists the assistant installations registered on the platform.
No
sessions
Lists who is signed in, one line per user and assistant.
No
pending
Lists the sign-ins in progress.
No
check
Checks the integrity of the session store.
No
revoke
Ends sessions, for a user, an assistant, or both.
Yes
purge
Removes expired entries now.
Yes
Two options go before the command:
--jsonprints JSON instead of a table, for example to feed another script.--db <path>points to another session store. The default isoauth.dbin the directory set byDS_MCP_OAUTH_DIR,/datasentinel/data/mcp_oauthunless you changed it (see MCP Server Setup).
See who is connected
Overview
The last line is the one that matters: the number of active sessions and of distinct users.
Assistant installations
Each assistant registers itself the first time it connects. A user with Claude Code on two laptops has two installations.
client_ididentifies the installation. You need it to end its sessions.sessionsis the number of users currently signed in through it.permanentmarks an installation created by an administrator, such as Microsoft Copilot. The platform never removes it automatically.
An installation with no session that has not been used for 90 days is removed automatically.
Signed-in users
To see one user only:
The expires column moves forward each time the assistant renews the session. A session that is not used for 10 days expires, and the user signs in again.
Add --all to also see the previous tokens of each session. They are marked rotated or expired and grant no access. The platform keeps them for a while to detect a stolen token.
Sign-ins in progress
Use this command while a user tries to sign in and reports a problem.
login page open: the login page was displayed, but the user has not submitted it yet. If the line stays until it expires, the user never completed the form.code to exchange: the user signed in successfully, but the assistant has not collected its session yet. If the line stays until it expires, the assistant could not receive the redirect. Check the assistant side, not the platform.
Both lists are normally empty. An entry lasts 10 minutes at most. For the messages users see during a failed sign-in, see Sign-in problems.
End sessions
Ending a session stops its renewal. The user must sign in again on the Datasentinel login page.
The script asks for confirmation before any change. Add --yes to skip the question, for example in a script. Without a terminal and without --yes, the script refuses to change anything.
Disconnect a user from every assistant:
To prevent the user from signing in again, also remove or disable the user in Datasentinel.
Disconnect a user from one assistant installation only:
The user's sessions on other assistants are not affected.
Disconnect every user from one assistant installation:
The installation stays registered. Users can sign in again from it.
End all the sessions of an installation and delete its registration:
An assistant that registers itself, such as Claude Code or Cursor, registers again the next time someone uses it. An installation created by an administrator, such as Microsoft Copilot, must be created again by hand.
Maintenance
Remove expired entries now
The platform cleans expired entries by itself, but only when a user signs in, at most every 10 minutes. On a quiet platform where assistants only renew their sessions, nobody signs in, and this cleanup can go a long time without running. The purge command runs the same cleanup immediately, with the same thresholds. It asks for no confirmation.
The output gives the number of entries removed, per type:
transactions
Login pages opened and never submitted, older than 10 minutes.
codes
Sign-ins completed but never collected by the assistant, older than 5 minutes.
refresh_tokens
Sessions not renewed for 10 days, and old tokens of renewed sessions once they expire.
clients
Assistant installations unused for 90 days, with no session left and not marked permanent.
Sessions are removed before installations. An installation whose last session is removed can therefore be deleted in the same run.
The purge also compacts the store. It moves pending changes into oauth.db and resets the oauth.db-wal file to zero bytes.
What the purge does not do:
It ends no active session. It removes only expired entries, and an expired entry grants no access.
It does not affect the access tokens assistants already hold. Those are not stored on the platform.
It is never required. It only frees space.
Check the session store
The first line must read ok. The command exits with code 1 otherwise.
Good to know
The script never creates the session store. If the MCP server has never started, every command stops with
No OAuth store at ....The script does not write to the MCP server log. A revocation is visible only in the shell history of the host.
Last updated