keep-session-alive
Verifies and refreshes your authentication token to maintain an active session.
Instructions
Verify and refresh the current authentication token (also used for token-based authentication)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | No | Optional: Provide a token to use for authentication |
Implementation Reference
- build/index.js:392-457 (handler)Main handler for the keep-session-alive tool. Accepts an optional token parameter, validates/refreshes it via POST /tokens/keepAlive, and updates connection state. If a new token is provided and validation fails, the original token is restored.
server.tool("keep-session-alive", "Verify and refresh the current authentication token (also used for token-based authentication)", { token: z.string().optional().describe("Optional: Provide a token to use for authentication") }, async ({ token }) => { 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 a token is provided, use it instead of the current one const originalToken = authToken; if (token) { authToken = token; logInfo("Token provided via keep-session-alive tool"); } if (!authToken) { return { isError: true, content: [{ type: "text", text: "No token available. Please provide a token or authenticate with credentials." }] }; } try { // Try to keep the session alive await authenticatedRequest("/tokens/keepAlive", "POST"); connectionVerified = true; // If we got here, the token is valid return { content: [{ type: "text", text: token ? "✅ Token validated and set successfully. You are now authenticated." : "✅ Session kept alive successfully. Your token is valid." }] }; } catch (error) { // If validation fails and we were using a provided token, restore the original if (token) { authToken = originalToken; } connectionVerified = false; return { isError: true, content: [{ type: "text", text: token ? `❌ The provided token is invalid or expired: ${getErrorMessage(error)}\nPlease try with another token or use authenticate-with-credentials.` : `❌ Your session token is invalid or expired: ${getErrorMessage(error)}\nPlease authenticate again.` }] }; } } catch (error) { return { isError: true, content: [{ type: "text", text: `Error keeping session alive: ${getErrorMessage(error)}` }] }; } }); - build/index.js:392-394 (registration)Registration of the 'keep-session-alive' tool via server.tool(), with description and optional 'token' parameter using Zod schema.
server.tool("keep-session-alive", "Verify and refresh the current authentication token (also used for token-based authentication)", { token: z.string().optional().describe("Optional: Provide a token to use for authentication") }, async ({ token }) => { - build/index.js:393-393 (schema)Zod schema defining the optional token parameter with string type and description.
token: z.string().optional().describe("Optional: Provide a token to use for authentication")