Skip to main content
Glama

get_afk_status

Check AFK mode status to determine whether to route interactions through mobile notifications or use native chat, ensuring proper handling when away from desk.

Instructions

Returns the current AFK mode status. Call this before every interaction to decide whether to route through AFK MCP tools or native chat. If afkMode is true and clientConnected is true, route through notify_session_progress / get_user_decision. If afkMode is true but clientConnected is false, fall back to native chat and warn the user. If afkMode is false, use native VS Code chat as usual.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for 'get_afk_status' tool. Retrieves the current session using getSession() and returns a JSON response containing afkMode, clientConnected, and sessionId properties.
    async () => {
      const session = getSession();
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify({
              afkMode: session.afkMode,
              clientConnected: session.clientConnected,
              sessionId: session.sessionId,
            }),
          },
        ],
      };
    },
  • The Session interface defines the data structure for session state, including sessionId (string), afkMode (boolean), and clientConnected (boolean) properties that are returned by the get_afk_status tool.
    export interface Session {
      sessionId: string;
      sessionToken: string;
      afkMode: boolean;
      clientConnected: boolean;
      progressHistory: ProgressHistoryEntry[];
      pendingDecisions: Map<string, PendingDecision>;
      pushSubscription: PushSubscriptionData | null;
      reconnectTicket: string | null;
      reconnectTicketExpiry: number | null;
    }
  • Registration of the 'get_afk_status' tool with the MCP server using server.tool(). Includes tool name, description, empty input schema ({}), and the async handler function.
    // ── get_afk_status ──
    server.tool(
      "get_afk_status",
      "Returns the current AFK mode status. Call this before every interaction to decide whether to route through AFK MCP tools or native chat. If afkMode is true and clientConnected is true, route through notify_session_progress / get_user_decision. If afkMode is true but clientConnected is false, fall back to native chat and warn the user. If afkMode is false, use native VS Code chat as usual.",
      {},
      async () => {
        const session = getSession();
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                afkMode: session.afkMode,
                clientConnected: session.clientConnected,
                sessionId: session.sessionId,
              }),
            },
          ],
        };
      },
    );
  • The getSession() helper function retrieves the current session object. It throws an error if the session hasn't been initialized via initSession().
    export function getSession(): Session {
      if (!session) {
        throw new Error("Session not initialized. Call initSession() first.");
      }
      return session;
    }

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/paulbennet/afk-mode-mcp'

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