Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
tokenNoOptional: Provide a token to use for authentication

Implementation Reference

  • 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 }) => {
  • 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")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose all behavioral traits. It mentions 'verify' and 'refresh', implying mutation, but lacks details on side effects (e.g., token invalidation), error conditions, or required permissions. This is insufficient for a tool that modifies authentication state.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that conveys the core purpose without unnecessary words. It is concise and front-loaded, but could be more structured to separate 'verify' and 'refresh' actions or add usage notes.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's role in session management, the description is incomplete. It does not explain return values, behavior on expired tokens, or that it should be called periodically. This lack of context forces the agent to infer important behaviors.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already provides a description for the 'token' parameter (optional, for authentication). The tool description adds no additional meaning or context about this parameter. Since schema coverage is 100%, the baseline is 3, and no extra value is provided.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool verifies and refreshes the authentication token, which is a specific verb-resource pair. It also mentions its use for token-based authentication, giving context. However, it does not explicitly differentiate from sibling tools like 'authenticate' or 'authenticate-with-credentials', lacking a distinct separation statement.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as 'authenticate' or 'logout'. It only implies a use case for maintaining a session, but does not explicitly state when not to use it or specify prerequisites like having an existing session.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mingzilla/pi-api-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server