Skip to main content
Glama

get_current_web_app_url

Retrieve the connection URL and QR code for the AFK Mode web app to access remote task monitoring and decision prompts from mobile devices.

Instructions

Returns the connection URL and QR code for the AFK Mode web app. Call this when the user asks for the AFK app link or QR code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for 'get_current_web_app_url' tool. It retrieves the current session, gets the web app URL via the getWebAppUrl callback, generates a QR code markdown, and returns a JSON response containing the URL, QR code markdown, and session ID.
    async () => {
      const session = getSession();
      const url = getWebAppUrl();
      const qrCodeMarkdown = await generateQrMarkdown(url);
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(
              {
                url,
                qrCodeMarkdown,
                sessionId: session.sessionId,
              },
              null,
              2,
            ),
          },
        ],
      };
    },
  • Registration of the 'get_current_web_app_url' tool using server.tool(). Defines the tool name, description, empty input schema ({}), and the async handler function.
    server.tool(
      "get_current_web_app_url",
      "Returns the connection URL and QR code for the AFK Mode web app. Call this when the user asks for the AFK app link or QR code.",
      {},
      async () => {
        const session = getSession();
        const url = getWebAppUrl();
        const qrCodeMarkdown = await generateQrMarkdown(url);
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  url,
                  qrCodeMarkdown,
                  sessionId: session.sessionId,
                },
                null,
                2,
              ),
            },
          ],
        };
      },
    );
  • Input schema for the tool - an empty object {} indicating no input parameters are required.
    {},
  • Helper function generateQrMarkdown that creates a QR code data URI from a URL and returns it as markdown image syntax. Used by the get_current_web_app_url handler.
    export async function generateQrMarkdown(url: string): Promise<string> {
      const dataUri = await QRCode.toDataURL(url, {
        width: 256,
        margin: 2,
        errorCorrectionLevel: "M",
      });
      return `![AFK Mode QR Code](${dataUri})`;
    }
  • Definition of the getWebAppUrl callback function that constructs the web app URL using local IP, port, and session token. Passed to registerTools and used by the tool handler.
    const localIp = getLocalIp();
    const getWebAppUrl = () => `http://${localIp}:${port}/?token=${session.sessionToken}`;
    
    // ── MCP Server (stdio) ──
    const mcpServer = new McpServer({
      name: "afk-mode-mcp",
      version: "1.0.0",
    });
    
    registerTools(mcpServer, getWebAppUrl);

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