logout
Invalidate the current authentication token to end your session. This revokes access and logs you out.
Instructions
Invalidate the current token and end the session
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- build/index.js:537-572 (handler)The logout tool handler. Invalidates the current token by calling /tokens/invalidate API, clears authToken and connectionVerified, and handles errors gracefully.
server.tool("logout", "Invalidate the current token and end the session", {}, async () => { try { if (!apiUrlSet) { return { isError: true, content: [{ type: "text", text: "API URL not set. Please set the API URL first using the set-api-url tool." }] }; } if (!authToken) { return { isError: true, content: [{ type: "text", text: "Not authenticated yet. No need to logout." }] }; } await authenticatedRequest("/tokens/invalidate", "POST"); authToken = null; connectionVerified = false; return { content: [{ type: "text", text: "Logged out successfully. Token invalidated." }] }; } catch (error) { authToken = null; // Force logout even if API call fails connectionVerified = false; return { isError: true, content: [{ type: "text", text: `Error during logout: ${getErrorMessage(error)}. Token cleared locally.` }] }; } }); - build/index.js:537-537 (registration)Registration of the 'logout' tool via server.tool() with description and empty schema.
server.tool("logout", "Invalidate the current token and end the session", {}, async () => {