logout
Invalidate the current session token to securely end access to PI Dashboard resources managed by the MCP server.
Instructions
Invalidate the current token and end the session
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- build/index.js:536-572 (handler)The complete implementation of the 'logout' tool, including registration via server.tool and the handler function that invalidates the session token via API call to /tokens/invalidate, clears local authToken, and handles errors by forcing local logout.// Logout tool 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.` }] }; } });